Help with creating a timed automation

I’m new to Home Assistant, and just starting to hit my stride with it. Unfortunately, I’ve fiddled with one particular automation, and cannot figure out how to format it.

The scenario: I have a misting humidifier hooked up to a terrarium containing plants, and I’d like to use my smart plug to turn the humidifier on every 105 minutes, remain powered on for 45 minutes, shut off, wait another 105 minutes, and repeat. I used to have an ancient digital timer performing this function, but I figured this could be a nice automation to have.

Home Assistant is currently running on Hass.io on Raspberry Pi. I’ve figured out other simple automation, such as turning an air conditioner on and off at specific temperatures, but for some reason, I don’t even know where to begin with this one.

Any help would be appreciated!

I would do this with two automations. One to turn on, another to turn off.

automation:
  - alias: Turn on Humidifier
    trigger:
      platform: state
      entity_id: switch.humidifier
      from: 'on'
      to: 'off'
      for: '01:45:00'
    action:
      - service: switch.turn_on
        entity_id: switch.humidifier

  - alias: Turn off Humidifier
    trigger:
      platform: state
      entity_id: switch.humidifier
      from: 'off'
      to: 'on'
      for: '00:45:00'
    action:
      - service: switch.turn_off
        entity_id: switch.humidifier
3 Likes

Thank you, this was perfect! Worked like a charm.

Or add a delay service.

- service: switch.turn_on
  entity_id: switch.humidifier
- delay: 00:45:00
- service: switch.turn_off
  entity_id: switch.humidifier

But 45mins delay is a long time, so i would create 2 automations aswell.