Automation "or" function not working like intended?

I made an automation to turn on lights in the garden, I want the lights to turn on after that the sun has set, but if the sun sets after 9:30 p.m. I don’t want them to turn on at all. This bit is not a problem, and that part of the automation works fine. But… I also want the lights only to turn on when my wife, myself or we both are home. So in the automation is an or statement to make that work, but it doesn’t. When we are both at home the lights goes on, but when just one of us is home the lights stay out.

The code I use is shown below, can anyone see any error in it that causes the lights to not turn on when only one of us is at home?

- id: turn_on_garden _lights
  alias: Turn on garden lights
  trigger:
  - event: sunset
    offset: '+15'
    platform: sun
  condition:
  - condition: and
    conditions:
    - condition: time
      before: '21:30:00'
    - condition: or
      conditions:
      - condition: state
        entity_id: device_tracker.mobiel_wife
        state: home
      - condition: state
        entity_id: device_tracking.mobiel_me
        state: home

Last condition entity_id is incorrect. (should be tracker not tracking)

Or you could put both of your device trackers into a group and use the state of the group in the condition.

By default if either member of the group is home then the group is home. And if both members are not_home then the group is not_home.

So it should work exactly as you want.

THANK YOU!! really I read the damn thing a 100 times and I didn’t see it.

1 Like

Thanks for the idea, that should work too indeed :slight_smile:

1 Like