alias: Licht aan na zonsondergang
description: ""
trigger:
- platform: sun
event: sunset
offset: "15"
condition: []
action:
- type: turn_on
device_id: 967b5a9aa969aa530af52b1fa3cb2138
entity_id: c0bf20fb04447f5ea66cdac0419a68fa
domain: switch
- type: turn_on
device_id: 42e4308597b6dc1ed7ed8a259429436a
entity_id: fd7b3c7772198d1c03a41d8c52cd1c51
domain: switch
- type: turn_on
device_id: 4385e7992aa5caa688d44c07bae2e975
entity_id: 12dbb70078c7013ab51cbc9917cd06e3
domain: switch
mode: single
Worked fine for years, since a couple of versions errors out with “automation not available”. All lights work fine when testing the actions. The sun goes up and down as usual, so what gives?
Automations using device ids become unavailable if any of the devices they depend on do.
Background
When you start writing automations, a device trigger seems the obvious choice. Everybody knows what a device is and it comes at the top of the UI dropdown list.
[image]
It works… but it is certainly not a “great way to start” because it is storing up problems for the future. Far better to use entity, with state or numeric_state.
Device_id problems
The yaml will be longer and harder to follow, which may make maintenance difficult, especially a few months down the line when you h…
If so, why does HA write this YAML if I configure using the GUI? And; why do the devices respond instantly while testing?
Change it to:
action:
- service: switch.turn_on
target:
entity_id:
- switch.entity1
- switch.entity2
- switch.entity3
…and I bet it will work.
It writes that yaml if you pick a device instead of picking an entity. that is the right yaml for devices. but the article specified why you should be pickig entities instead