So I’m at the point where I’ve set up groups and views, dns, encryption and so on. Thanks to many great guides and this forum. So now I’m kind of stuck in the automation section. I made my first automation that was pretty easy to set up.
Trigger was time both for on and off. The easy part was that it included only one switch.
Now I’m trying to add more switches in my second automation that is gonna be sun-triggerd.
- alias: 'Turn off Garden Cams at night' <------ change alias to whatever you like
initial_state: 'on'
trigger:
- platform: sun
event: sunset
action:
- service: switch.turn_off <------- Change to turn_on
entity_id: switch.rfl_garden_cam_rhd, switch.rfl_garden_cam_lhd <----- put your own entity_id's here separated by ',' commas
All my automations are in a separate automations.yaml file called fromthe configuration.yaml with
It’s not a test, its many switches I want to turn on and the question is how I separate them correctly. If I do it in the web-tool I seem to need separate them differently from when I do it directly in the automation.yaml-file. Is that correct?
@insideout Yes, you are correct. In the web, it’s mostly for testing. I personally don’t use it often, I build my automations in it’s own yaml file.
So as @keithh666 pointed out, the format for automations is triggers, (conditions are optional), and actions. If you want to have the same service (in this case switch.turn_on) you list the switch entities under entity_id:
- alias: 'Switch on at Sunset'
initial_state: 'on'
trigger:
- platform: sun
event: sunset
action:
- service: switch.turn_on
entity_id:
- switch.bokhyllor_arbetsrum
- switch.dags_fonsterlampa
That might be a valid point - I’ll try and see. Another stupid question, what does the “inital state” -do. Isn’t the initial state off, since I want them to turn “on”?
@insideout Actually it’s not a stupid question. Initial_state: is completely optional, but I use it because on occasion, when I restart HA, automations don’t run because they are somehow turned “off”. Think of it like enabling/disabling automations rather than on/off. You want your automation enabled so that it can run when triggered. If it’s “off” its basically disabled from running even when triggered.
Very close…1) make sure the action is lined up with the trigger in terms of spacing (YAML is very picky.) and 2) you’ll want to use a different service for switches and lights. Alternatively, I think you could use home_assistant.turn_on for all of them together, but I haven’t tried it. Here it is properly formatted:
LOL. Happy to help, as I’ve received lots of help myself over the last year, so I just try to help in return. HA is a little bit of a learning curve, but learning is half the fun!
well - I guess I got too happy too fast. The system didn’t like it event thoug it said it was valid. I tried to check it with YAMLint and get this response - any ideas?