Don't turn off the lights when I am at home (tracker)

So, at this moment the lights in a part of my home shut off at 22h. Works great. At least when I am not at home. When I am at home, it’s quite annoying.

Solution : I have a device tracker “device_tracker.xiaomi_13” that can track if I am at home or not.

afbeelding

How can I merge those together so that my lights won’t turn off when I am at home?

alias: Lichten Living Uit
description: ""
trigger:
  - platform: time
    at: "22:00:00"
condition: []
action:
  - service: light.turn_off
    target:
      entity_id: light.groeplichtlivingstaanlamp
    data: {}
  - service: light.turn_off
    target:
      entity_id: light.groeplichtlivingleeslamp
    data: {}
mode: single
alias: Lichten Living Uit
description: ""
trigger:
  - platform: time
    at: "22:00:00"
condition:
  - condition: state
    entity_id: device_tracker.xiaomi_13
    state: away
action:
  - service: light.turn_off
    target:
      entity_id: light.groeplichtlivingstaanlamp
    data: {}
  - service: light.turn_off
    target:
      entity_id: light.groeplichtlivingleeslamp
    data: {}
mode: single

Hi Tom,

I tried it, but that wasn’t the solution. Lights were still on when I arrived home.

Check the automation trace.



So i tmust be something with the two groups i’ve created ( light.groeplichtlivingstaanlamp and light.groeplichtlivingleeslamp)?

No it’s pretty clear in the trace - automation stopped because condition failed. That means as far as Home Assistant is concerned - the state of the device tracker was NOT away. So that’s where you need to look.

1 Like

Hi Andrew Jones,

Thanks for your answer.
Very strange behavior, as you can see on this screenshot, I was away at 22h.

Somebody else got any idea?

away, is not the state.
not_home is the state for not at home AND not in any other configured zone.
If you have any other configured zones then you will want to use a not before this condition, and check for the state home.

condition:
  - condition: not
    conditions:
      - condition: state
        entity_id: device_tracker.xiaomi_13
        state: home

Hi Andrew Jones,
Thanks for your advice! I’ve corrected it and i’ll let you know if this solution works for me this evening. I’m not at home, so the lights should go out at 22h. I’ll keep you posted!

1 Like

Can you click the button

So I can see the properly formatted code - because as you can see in the snippet you posted - action is in completely the wrong place.