After checking this again, yes I am sure.
is and is not operators are equivalent to = and !=, but hold a stronger meaning of equivalence in the python language. entity-state = 0 implies a test against the value held in the entity state. entity-state is 0 implies a test for the computer memory space for entity-state and for the constant literal 0 being identical.
In practice, I suspect that the use of is and is not rather than = and != is to help us differentiate more easily between operators that logically can be applied to both strings and numbers, from those that can only be applied to numbers.
<, <=, >, >= (as Kermit reminded me) work with numbers, but fail most of the time with strings. Hence 10 > 2 returns true, but â10â > â2â returns false. In the update, in conditional tests, using one of the numeric operators ( <, <=, >, >= ) will
- remove the option for a string literal [and boolean, regex]
- automatically cast the entity state to a number just for the purpose of the test
is, is not will
- provide options for number, string, boolean, regex literals
- test the entity state
- as a string against a string literal
- cast to a number and test against a number literal
Specifically for your case of zone, which Home Assistant holds as a numerical count of the number of persons currently seen in the home-zone.
This is just for the Current state node, and I have updated to version 0.80.3:
- The (deprecated) State Type I have set back to âstringâ, hence no up-front state casting will take place
- The If State test is set to
isand 09 number and literal1 - The entity state value remains as â1â throughout the node, and the output property field
datacontains the entity object with state value as a string â1â - The msg.payload property has been cast (only at the very end of the node-processing) to a number 1
- The conditional If State test has, in this case, passed as
true
In this case, the test, using a numeric literal, has auto-cast the entity string value to a number for the comparison test. The test is 1 == 1 and it works.
Notes:
It is possible to use a string literal for this test, so the If State test can be set as az string and 1 (no need for " ") and this works, since the test is "1" == "1"
I canât say why your test is not working for you, but I suggest upgrading to the latest version since there have been a number of updates recently. You could also try using the string comparison, testing for is â0â since this (should) work just as well - HA holds the state as â0â, we donât convert the state, and we can always test state is "0"
Extra points:
I have only checked the Current State node this morning, as I think that is one you refer to above.
No I have not tested for any of the other literal options J: expression, msg., flow., global., entity. My assumption is that each of these must return a number, for a numerical test. JSONata can return a number, msg.property flow.name and global.name can hold a number. Quite what happens for entity.name remains to be tested, but I would expect that both entity state values (the node entity and the conditional test literal/constant entity) are likewise auto-cast to a number for the test.
No I have not tested for the in and not in operators. These, inclusive and not inclusive tests, should apply to arrays (or sets or lists). Hence for Boolean tests, testing an HA entity with a state value of âopenâ or âclosedâ [cover] the inclusive test can be set as in ["open", "on", "yes"] or similar.
Using in and az 1, 2, 3 does appear to work, since the string â1, 2, 3â is treated (converted?) as an array, and the inclusive test runs. Hence it would be possible to easily test for no people or two people, but not just one person, being home as:
If State in az 0, 2
so you could also use in az 0 as your test








