Switch state not false or true

A trigger calls this function with parameters Agent and some int ID. Switch is a switch_device in an array of Switches.

But when I check the state it is not true and it is also not not true. It always prints the final ‘else’

For whatever reason, GetCurrentState has a void return type so it’s comparing void to true every time. It seems like a bug, I would report it.

1 Like

GetCurrentState[] is a <decides> function which means that it either fails or succeeds - the tipoff is that it is called with square brackets []. The function documentation isn’t clear - it doesn’t return a logic (true/false), the call itself is all that is needed.

if (Switch.GetCurrentState[Agent]):
    Print("meow")
else:
    Print("meow!")

Alternatively:

Print(if (Switch.GetCurrentState[Agent]) {"meow"} else {"meow!"})
2 Likes

I didn’t see until now that this question was double posted.

So essentially the same answer.