I have a humidity detector (netatmo weather station) and a smart plug. I am trying to have the plug switch on when the humidity is above a certain threshold.
I’m not sure from is the correct approach here. Either look at using a numeric_state trigger and above: 58 or perhaps use the Generic hygrostat.
You can use state but I would leave both to: and from: blank and use a condition for the threshold.
Also be aware that if the current sensor value is already above the trigger threshold, it will not trigger. The trigger is only caught when crossing the threshold.
Thanks. Indeed, this is why I used “state” (I though it would launch the script if the sensor is in a certain state i.e. above 58%). The thing is that I would like to add a condition that it does not trigger at night.
I was under the impression that if I put this condition, then, if the sensor goes above 58% during the night, it would also not trigger during the day (since already above 58%).
I have to conditions for the switch to goes on: 1. time is between 8:30am and 5pm AND 2. the humidity is above 58%.
As others have mentioned, you need to use a numeric state trigger. Using a state trigger in cases like this requires that the sensor’s value hits 58% exactly… not 57.9% or 58.1%, exactly 58%. The numeric state trigger allows for “above” and “below”.
But you also need to incorporate other triggers to handle the case you mentioned:
As well as to handle turning it off. Like the “turn on” part, you need to account for turning it off based both on humidity and on time.
The automation above will turn it on between 8:30am-5:00pm when the humidity goes from below 58% to above 58%. In case the humidity is already over 58% at 8:30am, there is a trigger at that time as well.
It also handles turning the dehumidifier off when the humidity hits below 57% as well as a timed turn off at 5pm.
Correct. The issue of your original code is that the temperature would have to move from exactly 58 so that to trigger actions.
Meaning, if your sensor reporting 57.9, and then the next reading being 58.4, it would not trigger.
Also even if your sensor reporting 58.0, it would not trigger either… because 58.0 is still not exactly 58.