Hope everyone is well. I a trying to set up a automation to turn on a smart plug when the humidity reaches a certain point and turn off after it reaches a certain point. I used the automation tab in HA. But it doesn’t work. If i execute it it it turns on but not automatically. Any help will be great.
Hi, it is difficult to diagnose a problem when the code & indenting is not formatted correctly. I think it would be much appreciated if you could edit your post and insert ``` before and after the code segment.
Certainily the last four lines of your automation look a bit odd as you have “mode” duplicated as parallel when it is already defined above as single. The fact that it works when you manually execute it would indicate that there is something wrong with your Trigger definition.
For comparision this is my dehumidifer automation however it differs from yours in that I have a sensor that activates on a sharpe rise in humidity (which means someone is using the shower) and it only runs between certain times of the day:
alias: Bed1 Dehumidifier On-Off
description: Control based on high increase in EnSuite humidity
trigger:
- platform: state
entity_id: binary_sensor.ensuite_shower_occupancy
to: 'on'
condition:
- condition: state
entity_id: switch.gosund01
state: 'off'
- condition: time
after: input_datetime.dehumidifer_on_time
before: input_datetime.dehumidifer_off_time
action:
- service: switch.turn_on
entity_id: switch.gosund01
data:
entity_id: switch.gosund01
- wait_for_trigger:
- type: humidity
platform: device
device_id: 43c5cd70ad3249a1bdda6e9be91dfd80
entity_id: sensor.ensuite_humidity
domain: sensor
below: 55
timeout: '01:00:00'
- service: switch.turn_off
data:
entity_id: switch.gosund01
entity_id: switch.gosund01
initial_state: 'on'
mode: single
OK, I don’t know why this is not working but I suggest as a test you try a Numeric State as the Trigger rather than a Device. If that works then consider using a Numeric State in the wait_for_trigger as well.
If I look at my config I tend to use Numeric States in the Triggers and Devices (where available) in the Actions.
EDIT: I have justice noticed that the Type for my wait_for_trigger is “humidity” whereas yours is “value”. What options do you get in the UI editor for this (mine is shown below for an Aqara Zigbee sensor):
The automation’s trigger is designed to trigger when the humidity increases and crosses the threshold value of 58. If the humidity is already above the threshold, the automation will not be triggered.
After the trigger occurs, further increases in humidity do not re-trigger the automation. The humidity must first decrease below the threshold and then rise above it in order to re-trigger it.
Hi. Thank you for the reply. That seems to be what I needed to change it to. It has been along time between using hassio due to a house move and I have forgotten nearly all of the little knowledge I had!
For future reference, there’s no difference in the behaviour between the first example’s trigger and the second one (Numeric State Trigger). They both trigger at the moment the humidity increases above the threshold value of 58. They will not trigger when the humidity is already above the threshold. They will re-trigger only when the humidity first decreases below 58 and then rises above it.
When you triggered the automation manually, it skipped the automation’s trigger and executed its action. You said that part worked because it turned on the switch.
What didn’t happen was that the Automation didn’t trigger automatically. Do you remember what was the humidity level when you created the automation and waited for it to trigger automatically?
You should also know that restarting Home Assistant will ‘reset’ a Numeric State Trigger.
HI, this is the code I use and I posted it just as an example, the automation is for a heater (smart plug) which is turned on when temp is below X and turns off when is above Y for Z time.
Also I have a Boolean input to skip this automation when it is OFF (For example when we’re out)
Actually i don’t have this automation any more, but those fields were auto-filled by selecting in UI. By the way, mode was default and device_id is optional if entity_id is specified
Can this be done dynamicly, because the humidity changes a lot between summer and winter
so for instant if the humidity increases with 10% within 1 min turn on the fan and if it increases 10% within 30 min turn off the fan
Look at the second post of this thread, the trend plateform.
Edit: I actually changed for the statistic sensor, the trend plateform was reset on every restart… so not very practical !