Trigger Automation after a certain time if humidity high

In the cellar I have a room where I sometimes dry washing during the winter. I have a dehumidifier in the room connected to a smart plug. What I would like to automate it so that during a certain time period (low energy tariff at night) if the humidity in the room goes above a certain level, then the dehumidifier is switched on. Also if the humidity is already high when the set time period begins, the dehumidifier is switched on.

Looked at various automation examples, but unfortunately not able to get my head around how to set this up.

Any thoughts?

Please share what you have created and we can help you build on it.

Not sure what your exact entities are, but I should think it might look something like this:

- alias: Dehumidifier on
  trigger:
    - platform: time
      at: 'HH:MM:SS'
    - platform: numeric_state
      entity_id: sensor.HUMIDITY
      above: NN
    - platform: homeassistant
      event: start
  condition:
    - condition: time
      after: 'HH:MM:SS'
      before: 'HH:MM:SS'
    - condition: numeric_state
      entity_id: sensor.HUMIDITY
      above: NN
  action:
    service: switch.turn_on
    entity_id: switch.DEHUMIDIFIER

That would be the “turn on” part. You’ll also want a “turn off” part that turns it off either when the humidity drops below another threshold or when the time period ends. There might be more elegant ways to do this, but at least this gives you an idea of how you might start.

Thanks for the suggestion. I have basically taken over your code and will test the results overnight.

p.s. Kept getting an error when checking my new automation until I finally noticed that ‘homeassistant’ was misspelled. :grin:

Looks fine to me! :wink: