Hello. Very excited with my new HA setup, using a Mini PC + proxmox VM. I have a Zigbee humidity sensor that I would like to cause a dehumidifier to turn on when the humidity value is above 50%, and turn off when it is below 50%. I would like it to make it happen when the value has existed for about 10 mins to stop the dehumidifier turning on and off frequently as it makes a loud beep. I tried 3 things.
I initially tried to use a trigger when the sensor’s humidity went above 50%, and putting in a time value, but this didn’t work as the humidity was already above 50%. From researching forum I read that this would only happen when the humidity crossed the threshold above 50. This didn’t seem suitable if I restarted the HA when the humidity was higher than 50% (e.g. from a powercut), the trigger would not be fired.
I then tried to use a condition without a trigger, because I was prompted by the UI to do this
However this didn’t seem to work, and doing the research several forum posts said you can’t use an automation with a condition only and without a trigger - instead you would need to use a script. this seemed excessive for what I thought was quite a simple scenario.
I then asked ChatGPT to help me, and it suggested I use a “state” of the sensor as the trigger, and then to use “numeric state” to check for the values. I assume once HA received the latest humidity reading from the sensor that is the trigger to check the condition.
My questions are
(a) was approach #3 the right/simplest way to do it? (I am trying to use the UI to keep it simple) If so, how do I put the 10 min delay?
(b) Was I missing something in #2 with the UI prompt, or is it potentially misleading that you can have an automation without a trigger?
HA triggers are event driven, something just being is not an event. Not all automations need to be robust against restart. If that’s something you need, there are different strategies to do that. Add a trigger for the event of home assistant restarting and mirror your numeric state trigger in a numeric state condition.
For additional robustness, at the cost of more complex automations, you can also use timers which can be set to restore after restart.
No you are not missing anything, automations must have triggers in order to function.
No. The reason the Numeric state trigger exists is to handle the cases where the State trigger isn’t really appropriate. A state trigger without a defined to or from value will fire every time the state changes. With either of them defined, it becomes very literal… the targeted value must exactly match for the trigger to fire.
A third option is to use a threshold helper as the trigger. This allows you to define a hysteresis - a zone on either side of the threshold where nothing happens - to stop the dehumidifier turning on and off so often when humidity is around 50%. You would still need Drew’s HA restarting trigger, though.
The template condition checks if the switch was last changed in the last 10 minutes. The automation will simply not run if the switch was changed more recently than 10 minutes ago.