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.
Didgeridrew & sonite
First of all thank you for pointing me in the right direction. I’m a noob in yaml codes and not really interrested in it. The reason I use the visual editor in home assistant only.
Above or equal exist in the visual editor, I use it for my zone heating in the house,
Each room has a helper to set the target temperature, each room is equiped with a temperature sensor by ESP home ( wemos mini “Huis temp”)
This is the script with conditions to allow switch off "CV uit / boiler off " only if no zone is demanding heat.
Translation: slaapkamer voor = sleeping room front of the house
What you have posted is exactly what @sonite posed in their second example.
While I understand the sentiment of not being interested in YAML as a new user, it is the only efficient method for sharing and editing HA configuration. That is why the Question Guidelines for this forum expressly state to not use screenshots for things that can be shared as text.
Read the guidelines and dived a litle more in YAML, result understand your point. Second: I replied earlier before testing fully, woke up next morning with a faulty heating system and my wife high in the curtains.
I tried to copy paste sonite’s code again, as already stated I’m a noob in YAML, 2 hours trial with all kind of additions without succes. After sufficient coding & testing in visual editor it was finally working with some small but effective changes resulting in the next (yes YAML ):