Hello.
I have one input field - target temperature. Additional object “myroomtargettemp”. In all automations it appears as “myroomtargettemp”.
So, I want to make two conditions.
switch off some Switch when sensor_temp is below myroomtargettemp. This condition is simple, I solved it via numeric_state.
swith on some Switch when sensor_temp is above or equal to myroomtargettemp.
And it is really crash.
Please, help me to write this simple condition.
Numeric_state has only above and below conditions.
I read that state condition can help, but I see only state = some fixed string or number. But I want a condition with a variable myroomtargettemp.
How can I do that? Thanks.
Can you clarify what you mean by “object ‘myroomtargettemp’” and “variable myroomtargettemp”? Also, please post your automation so we can see what you have tried and how it is structured.
It’s not only thermostat, it’s a part of another automation. But it must works as I wrote.
“myroomtargettemp” - it’s “input_number.myroomtargettemp”.
So I simply need a condition “if sensor <= input_number.myroomtargettemp”. How can I do that without HACS or another additional components, just with standard language? And I have no desire to rewrite whole automation. “<=” is very simple, why I can’t do that in HA standard terms? For now I must hold two input_numbers: for above and below conditions. But when temperature or another parameter stays at edge value - automation doesn’t work because, e.g. “24 is below 24,5 and 25 is above 24,5” - good, but “24,5 is not above and not below 24,5, it’s equal”.The problem is that I need some actions when it stays at 24,5 (or another value in input_number.myroomtargettemp), but I can’t call it because no conditions with “equal to input_number.myroomtargettemp”.
So many words for simple thing. How can I make a “if sensor <= input_number.myroomtargettemp”?
There are multiple ways to do this, here are three methods…
Using a State trigger with two conditions:
trigger:
- platform: state
entity_id: sensor.YOUR_SENSOR
not_from: unknown
condition:
- or:
- alias: Are they Equal?
condition: state
entity_id: sensor.YOUR_SENSOR
state: input_number.myroomtargettemp
- alias: Is sensor lower?
condition: numeric_state
entity_id: sensor.YOUR_SENSOR
below: input_number.myroomtargettemp
Note on State condition: The state option accepts the entity ID of helper entities (also known as input_* entities). The condition will pass if the state of the entity matches the state of the given helper entity. This method does not work with entities from all domains.
I already tried this. But condition doesn’t wotk, in trace it says “wanted input_number.myroomtargettemp”, state “24.5”.
It treats “input_number.myroomtargettemp” as string (treats just as words “input_number.myroomtargettemp”, not as value of this input_number.myroomtargettemp).
What I doing wrong?
Sorry, I checked my automation. I copied object ID like myroomtargettemp without input_number. My mistake. input_number.myroomtargettemp works like a charm. Thank you guys.
In HA all states are strings. It is definitely possible to run into issues doing string comparisons the way the State condition option does, especially if your sensor is from a custom integration. Of the options I posted, I find Template triggers to be the easiest to understand.