Controlling Humidifier at certain times of the day

Hi,

I have an MQTT sensor that reports Humidity to HA every 30mins and a WeMo switch connected a humidifier. What I want to do:

Between the hours of 19:00 and 06:00 maintain a humidity of ~50% in the room and not at other times of the day. This is what I currently have :slight_smile:

Automation1.yaml

alias: Humidity Trigger On
trigger:
  platform: numeric_state
  entity_id: sensor.humidity
  below: 50
condition:
  condition: time
  after: '19:00:00'
  before: '06:00:00'
action:
  service: homeassistant.turn_on
  entity_id: switch.humidifier

Automation2.yaml

alias: Humidity Trigger Off
trigger:
  platform: numeric_state
  entity_id: sensor.humidity
  above: 51
action:
  service: homeassistant.turn_off
  entity_id: switch.humidifier

This does what I think it’s meant to, however if the humidifier is on, but the humidity remains below 51 after 06:00:00 say for example because the bedroom door is open an the target can never be achieved then the humidifier will remain on. When in practise during the day I do not care what the humidity is, just that the humidifier shouldn’t be on.

Thanks

You don’t have the time condition to turn it off. Maybe something like this will work.

alias: Humidity Trigger Off
trigger:
  platform: state
  entity_id: switch.humidifier
  state: 'on'
condition:
  condition: or
  conditions:
    - condition: time
      after: '6:01:00'
      before: '18:59:00'
    - condition: numeric_state
      entity_id: sensor.humidity
      above: 51  
action:
  service: homeassistant.turn_off
  entity_id: switch.humidifier
1 Like

Thanks for your help. Can I just check I understand this correct.

This automation will trigger as soon as the humidifier is switched on ? Would that not have the effect of the humidifier being switched on then off very quickly ?

It will trigger when the switch is on but the switch won’t turn off until one of the conditions is met.