One Automation for two events?

Long delays is generally not a good solution since HA could be restarted or automations reloaded which makes the automation break

I tried to mock up what you had, but got sidetracked in the choose conditions phase.

What am I doing wrong here?

- id: '1638287241495'
  alias: New Automation
  description: ''
  trigger:
  - platform: time
    at: 06:30:00
    id: 'off'
  - platform: time
    at: '20:30:00'
    id: 'on'
  condition: []
  action:
  - choose:
    - conditions:
      - condition: trigger
        id: 'on'
      sequence:
      - service: switch.turn_on
        target:
          entity_id: switch.fan_controller
    - conditions:
      - condition: trigger
        id: 'off'
      sequence:
      - service: switch.turn_off
        target:
          entity_id: switch.fan_controller
    default: []
  mode: single

You only have one choose.
I don’t think that would work.

You could have one choose, and use the other as default.

Did you make that in the GUI?

I actually copied yours into the GUI just to see how it formatted it.

Once i figured that out, went back into the yaml and edited my original. I think it’ll work now, I"ll let you know when the fan kicks on tonight.

Thanks for your help. as @tom_l mentioned, I’ve since started using the Visual Studio editor with the rainbow tabs and that really helps me visualize the code better…

You could just set a different time and see if it works and then switch it off

The start of the process worked so I assume the whole automation will work…

Thank you!

Please mark Hellis81’s post as the solution.

This will work in this case, but you only need one Choose action for this automation.

Just to point out, the automation can be further simplified by simply adding an id to the other trigger too. If the one that turns the fan on has the id ‘on’ and the one to turn the fan off has the id ‘off’ then you can use:

service: switch.turn_{{ trigger.id }}

And then you don’t need to do any of the if stuff.

1 Like

When I had this in my Automations I kept getting errors, so I went with the slightly more complex idea…