Difference between testing for on / off /open / closed / etc (string) Vs true / false (boolean)

I have written many node red sequences for automations around the house and most of them rely on event state nodes testing the state of something. I am having trouble understanding when I should use the specific state that the device uses (such as on/off/open/closed/etc) versus a simple true and false. The confusing bit is that switching a motion sensor from on/off to true/false appears to work in some cases, but not all. What am I missing? I prefer true/false over the myriad of other string based states but it doesn’t seem to always work.

Below is an example of what I am talking about:

You should use whatever state that is shown under dev tools.

1 Like

and states in Home Assistant it always strings. So boolean true wont happen (unless typecasted automatically), but “true” can be true.

1 Like

Ok, I was hoping I could just stick with T/F but while some sequences were working, I am reverting them all back to using the strings. When I have time I will try to figure out why some were working and some not.

This is one example of an automation that works perfectly using T/F instead of on/off for the motion sensor group. Puzzled on why that would be…

I changed it back to string on/off but am just trying to understand the innerworkings…

EDIT: There are 2 sets of counter lights. The left/middle/right lights are LIFX, while the ones I called ‘Kitchen Counter Lights’ are just 3 dimmable white LED flush mount lights. The goal here is for the automation not to turn on the regular counter lights when my LIFX lights are on. When those are off, the kitchen main light state determines how bright the kitchen counter lights will be if the home is in night mode otherwise 100% brightness. I added the failsafe when some other error was causing the lights to stay on all night… it may not be needed now other than in the unlikely case the counter lights get turned on remotely and with nobody around (so motion events can’t start the timer to turn them back off)

Not sure about your exact issue but wanted to give some information about state type.

In the server config, there’s a field State Boolean, Config Server | node-red-contrib-home-assistant-websocket. It takes a list of values that will translate an entity state when the State Type is set to Boolean from the original entity state to a true value if it exists in the State Boolean list. All other entity state values that don’t exist in the State Boolean list will return a false value.

@Kermit - If I understand correctly, then what you are saying would confirm what I had observed. In other words, a state of on, or open was being translated to true, and given the list of strings it can convert to true is limited, I was having issues when I ran into such exceptions.

If my understanding is correct, then it all makes sense now! Thank you!

In essence, it is safer to stick with using the string, but in a subset of cases, one can opt for the Boolean approach as long as you are sure the strings get converted properly.