I’m just starting with HA and automation and struggling badly with getting automations to work. I’ve got a theme switcher working, but initially I setup an “arrive after sunset, turn on the outside light” automation that worked fine until I changed it from and individual to a group for the trigger entity_id. Now it is no longer working. I should also say that I don’t see anything being triggered in the log/logbook:
- alias: 'Turn on back light if arriving home after sunset/before sunrise'
trigger:
- platform: zone
# previously this was...
#entity_id: device_tracker.life360_kevin
entity_id: group.all_devices
zone: zone.home
event: enter
condition:
condition: or
conditions:
- condition: sun
after: sunset
after_offset: "-00:30:00"
- condition: sun
before: sunrise
action:
- service: switch.turn_on
entity_id: switch.back_light_40
I’ve also attempted to get a couple of other rather simple automations to work, the configuration validates fine with out errors but nothing seems to be working. A couple of examples…
# Evening Lights
- alias: 'Turn on Living Room lights before sunset'
trigger:
- platform: sun
event: sunset
offset: '-00:40:00'
action:
- service: light.turn_on
entity_id: light.lr1_3, light.lr2_34
# I've also tried this here...
#entity_id:
# - light.lr1_3
# - light.lr2_34
I’ve done a lot of searching and reading on the forums, but have been unable to figure this out. I’m guessing it’s something rather simple…perhaps something that should/shouldn’t be prefaced with a “-” which I still don’t completely understand when it’s required and when it’s not. Any help would be appreciated. Thank you.
Try a state trigger with the group. I don’t think the zone trigger will work with a group.
The dash is when you have multiple services, triggers, or conditions. Use the documentation to your advantage. There are a lot of examples that you can learn from.
Thank you, this fixed most of my issues. I misunderstood initial_state when I first read the docs and thought it only applied to what happens after a reboot. Actually enabling the them to run makes them run. Suprise!
I’ve updated the arrival lights to use a state trigger…
initial_state: true
trigger:
- platform: state
to: 'home'
entity_id: group.all_devices
…but it’s still not triggering. I have the exact same routine except with the zone trigger (like I initially had here) and an individual device which is working so I know it is related to triggering a group as you suggested. And actually, I’m wondering if I might have just fixed it by adding "from: ‘not_home’ in there. I guess I’ll see this evening. Thank you for your assistance.
I’ve got the known_devices cleaned up and all_devices shows those 8 devices (4 - Life360, 4 - phones). Yet I still can’t get it to work. I’m almost to the point of just using individual entities, but that’s not as clean or as easy to maintain moving forward.
I suggest to not use group.all_devices. This might have the issue that if one is already home, the entire group is set to being home -> no new triggering happens because “everyone” is already at home.
Instead do this as one line: entity_id: device_tracker.example1, device_tracker.example2, device_tracker.example3
Seperate your devices you want to track using a comma, that way each device will be tracked and can therefore trigger the automation.
Alternatively you can place several trigger events with one entity id for each.
trigger:
platform: states
entity_id: device_tracker.001
to: ‘home’
platform: states
entity_id: device_tracker.002
to: ‘home’
Etc
Well, I think I have read somewhere that you can add an option to groups, which makes them behave the other way.
Usualy groups act the way that if one member is ‘home’ that the entire group updates to ‘home’.
That option, which I am sure you can find somewhere here, switches that behaviour. It means that the group is only then ‘home’ when all members are ‘home’. However, I don’t know if it runs a trigger when one member comes home. It could very well be that it only triggers, when everyone is home.