Fires when the numeric value of an entity’s state (or attribute’s value if using the attribute property, or the calculated value if using the value_template property) crosses (and only when crossing) a given threshold. On state change of a specified entity, attempts to parse the state as a number and fires if the value is changing from above to below or from below to above the given threshold.
So, your automation will only trigger if sensor.boiler_temp_sonoff goes from above 33 to below 33 between 18:00 and 22:00.
the automation assumes some initial conditions for it to trigger:
That the state is above 33 and that the time is before 1801.
If those initial conditions aren’t met (say it’s now before 1801 but below 33) then the automation won’t trigger until those conditions change to cross the threshold of the triggers (in this case it becomes later than 1801).
The code @123 posted will trigger the automation if the sensor drops below 33 at anytime of the day or night - BUT the condition will ensure the automation only does anything if the time is between 6pm and 10pm. The automation will also trigger at 6:01pm and the condition will check if the sensor is below 33.
There is no problem with that code, please post the automation trace if you believe it is not working.
I think there may be some confusion here as what @123 posted would work but as explained if the time is already passed 18:01 hours and the temp is already below 33 then it will not trigger.
Have you tried what was suggested by 123 and used the developer tools to set the state of the temp entity to something above 33 then either let it update or wait a few seconds and then set it to any value below 33 to check if 123’s automation actually works?
This is a really important point that should not be overlooked for any thermostat-type automation.
I recall a GitHub issue describing the same thing for a users beer cooler. Basically this is expected behaviour and we need to consider a ‘missed trigger’ scenario when writing automations.
I have changed all my thermostat-type automations to trigger at every temperature change and no longer use numeric state as the trigger.
The temperature check then goes in the condition.
This solves the trigger state change from being missed at the expense of added log volume.
You can either wait till it is after 1801 when the automation should trigger on its own or if you really want the heater to turn on right now then just turn on the heater switch manually via it’s entity.
but also be aware that the automation as written will only ever turn on the switch. it will never turn it off.
if you want the heater to turn off at certain triggers/conditions automatically then you will need another automation or modify the existing one to do that.
Sure thing. We take the code from @123 and make one change. The trigger changes from numeric_state to just plain’ol state with no attributes, values, etc. We can also remove the time trigger as that is no longer needed as it is already in conditions.
I have one of the Sonoff temp/humidity sensors. They appear to update every five minutes or so. Therefore expect for this automation to trigger every five minutes to evaluate if the boiler needs to turn on.
PS. This same automation can also be used to turn off the boiler if you used a choose action and individual temperature conditions.