Debugging Automation

I’ve tried to setup a simple automation to turn off an MQTT socket when I leave.

Individually by setting up the appropriate cards I can see my own presence working, and I can toggle the state of the socket. So individual pieces are working.

What I can’t get is the automation to work on being away for 5 minutes to turn the socket off. It’s all in place, the automation shows up in the UI including history as apparently valid, but it never seems to work.

I’ve read various instructions/examples though none of them seem to be a complete example similar to what I’m trying to do.

I have other automations which work, change of state of one thing changing the state of another.

I have turned up logging, but get nothing useful, either it’s not doing anything or it’s not logging - hard to tell.

Anyone got any ideas. Here is the automation.

- id: '1550396606995'
  alias: Left House
  trigger:
  - entity_id: device_tracker.v20
    for:
      minutes: 5
    from: 'Home'
    platform: state
    to: 'Away'
  condition: []
  action:
  - service: homeassistant.turn_off
    entity_id: switch.iron_power

In the examples I’ve seen, the device_tracker’s states are shown in lower-case. Try changing Home to home and Away to away.

- id: '1550396606995'
  alias: Left House
  trigger:
  - platform: state
    entity_id: device_tracker.v20
    from: 'home'
    to: 'away'
    for: '00:05:00'
  condition: []
  action:
  - service: homeassistant.turn_off
    entity_id: switch.iron_power

Thanks, you set me on the right track, but had to resort to digging through the code.

The states are it seems ‘home’ and ‘not_home’

I had assumed it would be Home and Away (as the front end displays) as that seems logical, admit I hadn’t thought about being case sensitive.

Working now.

Oops! I missed that one. I don’t use device_tracker so I was unfamiliar with its valid states. Glad to hear it’s working for you now.