Hello, everyone,
and I apologize in advance - I’m a complete beginner and I’m also new here on the forum - so I apologize for any naive questions and for any possible transgressions against forum ethics.
I wrote my first automation to do this: When the humidity reaches “X” in the room, turn on the outlet where the dehumidifier is plugged in, turn the outlet off again when the humidity drops to “Y”. Do this only between H1H1:M1M1 and H2H2:M2M2 each day.
Yaml file is here:
To turn on:
Automation “dehumidifier ON” works fine, but only on one day. The following day, starting from H1H1:M1M1, the automation “dehumidifier ON” does not start, even though all conditions (humidity, hour, day) are met. If I start the automation manually, the cycles ON and OFF works normally throughout the day until H2H2:M2M2.
It’s obvious that I have a logical error somewhere, or that there must be a completely different way to do such an automation - and I can’t figure out how. Note: I could use some of the blueprints posted here, but I want to figure out how to go about creating my own scripts. Thank you very much for your help!
Using numeric_state with an above or below will only trigger when the humidity passes that threshold. Ie if your humidity is already above 55 at 6am, you will not get a trigger to turn this on.
Therefore, you need a slightly different logic.
In addition to what you already have, you could can add a trigger for for time at 6am and a condition that humidity is above 55 for your on and likewise a trigger for 21.30 in your off (presuming you dont want it running over night).
If you still have patience with me …:-). I tried to find a way to add a “switch on at 06:00 in the morning” trigger, but I couldn’t figure it out. The time condition can only be specified as an interval of time after and time before, but not as if the time value reaches just 06:00 then trigger the switch.
Thus, I need to write in YAML notation: If the time is 06:00 and the humidity is >=55% then trigger the switch. How is this syntactically correct? For example, I tried this:
condition: time
# here I want to express "is just equal to"
is: "06:00:00"
weekday:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
but this syntax is not valid. Apparently, the time condition always has to be before and after (Conditions - Home Assistant)
Could you please give me an example of how to specifically implement your proposed condition in my existing YAML? Thank you very much, it would help me to understand the logic of HA…
To Troon: yes, defining “trigger” makes sense, I didn’t know which way to go. Perhaps an even better way was suggested by Hellis81. Thank you both very much for the inspiration!
I’ve also already defined the generic hygrostat, I see it as an entity, but so far I haven’t managed to build it into any automation. Maybe the approaches you suggest will help me.
I have not set up a hygrostat, but I assume it has service calls for turn on and off.
If it does, then you just need to set it up to be between 50 and 55 and then have time triggers to turn on and off and that is all.
As @Hellis81 mentioned, the Generic Hygrostat integration can handle a lot of the repetitive functions in the automation examples shown so far. Once configured, the integration will create an entity with humidifier as its domain. The following automation for a humidifier entity would replace your two existing automations from the original post:
alias: Humidity Control - Time based
trigger:
- platform: time
at: "06:00:00"
id: 'on'
- platform: time
at: "22:00:00"
id: 'off'
condition: []
action:
- service: humidifier.turn_{{trigger.id}}
data:
entity_id: humidifier.EXAMPLE
- service: notify.persistent_notification
metadata: {}
data:
message: dehumidifier {{ trigger.id | upper }}
- service: notify.notify
metadata: {}
data:
message: dehumidifier {{ trigger.id | upper }}
mode: single
It also makes changing the targeted humidity level easier from both the frontend and other automations since you can use the dashboard card and/or service calls.
Yes, this script works very well, the inclusion of the “generic hygrostat” or the entity “humidifier.XXXXX” created by it is very effective, moreover this entity can be placed in the UI and temporarily manually controlled - great, thank you very much @Didgeridrew for the inspiration! Especially valuable for me is the insight on using humidifier.turn_{{trigger.id}} variables - I have almost no programming experience (although I’ve been around computers for several years) - I’m a complete self-taught amateur. Thanks again!