I recently upgraded to 2020.12.2 (from 0.116) and 1 of my entity filters has stopped rendering when my state filter uses “==”:
The entity:
sensor.bin_calendar_event_0_custom_state: {
state: Black
eta: 0
friendly_name: bin_calendar_event_0_custom_state
}
This doesn’t work:
state_filter:
- operator: "=="
value: "0"
attribute: "eta"
But this does:
state_filter:
- operator: "<="
value: "0"
attribute: "eta"
NB this isn’t actually useful as a workaround because I really want to filter for exactly “1”
petro
(Petro)
January 4, 2021, 2:50pm
2
The value isn’t "0"
it’s 0
.
state_filter:
- operator: "=="
value: 0
attribute: "eta"
unfortunately:
unquoting the value like you suggest doesn’t fix the problem
the documentation (https://www.home-assistant.io/lovelace/entity-filter/#options-for-state_filter ) says explicitly the value is a string, not an integer.
If I unquote the value (ie 0, not “0”) then the workaround with “<=” doesn’t work either
works:
“<=” and “0”
“<” and 1
“regex” and “^0$”
doesn’t work:
“==” and 0
“==” and “0”
“<=” and 0
petro
(Petro)
January 4, 2021, 3:18pm
4
Attributes are typed, states are strings. This has always been how it works.
See proof:
petro
(Petro)
January 4, 2021, 3:38pm
5
FYI, there does appear to be an issue specifically with == 0. wrote it up https://github.com/home-assistant/frontend/issues/8087
in the meantime use the following config
state_filter:
- operator: in
value: [ 0 ]
attribute: eta
I can confirm that where the value isn’t the numeral 0, == works on my config. I was only using 0 because that is the current value of the attribute I’m testing. Not sure if that is lucky or not. A bug was found after all.
FWIW
- operator: "=="
value: "1"
Did work in 0.116, but doesn’t now (2012.12.2), although I appreciate I might well have been exploiting some undesired/unexpected behavior.
Thanks.
petro
(Petro)
January 4, 2021, 4:07pm
7
states are strings, attributes are typed.
so if your state is 1 then this would work:
- operator: "=="
value: "1"
but if your attribute is 1, then this would work
- operator: "=="
value: 1
attribute: my_attribute
To clarify the difference between a state and an attribute, checkout your dev tools states page.
it was literally the same attribute (eta). I have the git history. It previously worked every week (it’s a reminder to put the bins out).
I’m sure you’re right about the correct config and it isn’t worth working out why it was working for me before.
petro
(Petro)
January 4, 2021, 4:32pm
9
Most likely a bug got fixed with incorrect typing passing results