Home/Away state trigger does not work - attribute missing?

I am trying to always shut off certain devices when I leave my home. I tried that using he sate trigger. Strangely when I select the device trigger for my phone, I an only select unrelated attributes (IP address, hostname, etc.) Leaving the attribute field blank an only specifying the From and To values I get:

alias: LichtAusWennNichtZuhause
description: ''
trigger:
  - platform: state
    entity_id: device_tracker.galaxy_a40_von_michael
    from: Home
    to: Away
condition: []
action:
  - type: turn_off
    device_id: 150b679d3eeaf90e737200b81e2c2ab9
    entity_id: switch.steckerschrankbeleuchtung
    domain: switch
mode: single

This however does not trigger the action when I leave.

The sensor seems to be working because the dashboard correctly reports that I am home/away when I turn the phone’s WiFi on/off.

The smart switch also works when I use it manually in the dashboard.

What am I doing wrong? How can I switch off devices when I leave?

Thanks in advance and best regards.

Try removing the uppercase letters and put the states in quotes:

alias: LichtAusWennNichtZuhause
description: ''
trigger:
  - platform: state
    entity_id: device_tracker.galaxy_a40_von_michael
    from: 'home'
    to: 'away'
condition: []
action:
  - type: turn_off
    device_id: 150b679d3eeaf90e737200b81e2c2ab9
    entity_id: switch.steckerschrankbeleuchtung
    domain: switch
mode: single

Also, are you sure it goes to ‘Away’? Mine goes to ‘not_home’, but that could just be due to using a different Integration.

1 Like

If the device tracker lags and you go from home to the zone “store at the end of the street” then it won’t trigger.

Either only from home, or template {{ state() != "home" }}

You’re using the translated states that appear in the frontend. Use the untranslated states that are in the backend. To see these, use the developer tools → states page. The correct states are: home and not_home.

  - platform: state
    entity_id: device_tracker.galaxy_a40_von_michael
    from: home
    to: not_home
1 Like

It should be “home” and “not_home” instead of “Home” and “Away”.

the latter is only for UI display

EDIT: cross posted with Petro…

1 Like