Is there a way to have an "on / off " automation

Hello, new HA user coming from Smartthings. Im used to ST automations having triggers like on at ___ and off at ___ All in one automation. I have not found a way to have 1 automation work like that in HA. Instead, what I see is having to create 2 (like with Alexa) and it’s annoying. Am I missing something?

An automation can have multiple triggers and action logic can be branched using If/Then or Choose actions.

Here’s an example from the Community Cookbook

That example uses templating with trigger IDs, but it could be done with If/Then with Trigger conditions as follows:

description: "Turn on lights at sunset and off at sunrise"
trigger:
  - id: 'on'
    platform: sun
    event: sunset
  - id: 'off'
    platform: sun
    event: sunrise
action: 
  - if:
      - condition: trigger
        id: 'on'
    then:
      - service: light.turn_on
        target:
          entity_id: light.your_light 
    else:
      - service: light.turn_off
        target:
          entity_id: light.your_light
mode: single
1 Like

ohh, ive just been going to create new automation, I need to edit the yaml, got it. Thanks

You don’t need to edit the YAML, all of the things I mentioned are available using GUI Automation Editor. YAML is just the best way to share stuff (and it can be copy/pasted directly into the Automation editor)

haven’t come across the GUI-AE, will search and read up on it. thanks

The thing that you are taken to when you click “Create Automation” button is the GUI Automation Editor…

Ahh, now youre talking my language. thanks for being patient, HA’s mechanics are still sinking in. totally different from my previous platforms.