I’ve run into this issue as well.
I’m changing colors of lights based on my heart rate. I’m retrieving the bpm via API which returns a whole number (string?) 109, 142, 163, etc.
The ranges are as follows:
Aqua: <109 bpm
Olive: 109 to 125
Gold: 126 to 142
Orange: 143 to 159
red: >160
My automation fails or doesn’t act as expected at the border cases. 142 for instance fails when I had my automation ranges set the same as the bpm ranges. If I set one condition to above 141, I’ve created a situation where two conditions are true at the same time which doesn’t seem ideal. A Greater than or Equal to state would alleviate this issue without adding more complexity or thinking to this non-programmer’s automation.
You could trigger on any change in bpm, no conditions and then in the action part determine the color that the light should be set to with an IF-ELIF-ELSE statement or with the choose function.
I’m sure there are a myriad of ways around this, and I’d love to understand them, but mainly I’m reiterating that from the interface, for a non-professional programmer, not being able to specify ‘equal to’ is a surprising lack of functionality.
It’s not really surprising. It’s a fairly simple thing to do with a template. This is most likely the reason it hasn’t been added.
If you want it added to numeric_state, this is not the place to do it. Configuration is for support. Head over to feature requests and make a formal request for this functionality.
But that would only trigger at 160. The API refreshes every minute so it could go from 154 to 162 and never hit 160. So I would be back to using templates similar to this?
I didn’t read your whole automation. I was simply pointing out that an “equals” numeric trigger in your case would the the same as a state trigger. Is this not what you want?
I have a slider to set a Timer for a light I have. After a given time it should turn off. If you slide the slider to “0” it also should turn off the light. That is my problem at the moment, where an “equal to” would help a lot.
I want a condition to check if my thermostat is set to 20. Yes I could use above 19.999 and below 20.001 but why? It would be much simpler to just have equals 20.
This will evaluate it as a string, so it will always return false.
- condition: state
entity_id: ...
attribute: ....
state: 20.0
Without the apostrophes it will evaluate as a number.
The issue is, when setting a condition via the UI, it automatically adds the apostrophes. Combine that with the fact that numeric state doesn’t have an “equal to”, there is currently no way to do this via the UI.
Sure it’s not hard to switch to YAML mode and remove the apostrophes, but is the complete newbie to HA going to know that? Having an “equal to” in the numeric state, even if it converts to yaml as state: 20 would make things much more user friendly.
Even as an HA user for several years, I just made up an automation through the GUI and was scratching my head trying to figure out why it was evaluating as false when it was clearly true. Took me a few minutes to realize it was a string vs a number.