Basic automation: not working switch.turn_on (Newbie)

First of all, greetings to all. I’m new with HA and I’m trying to get my first automation. It’s very basic, but it’s not working:

# Encender luz al llegar
- entity_id: device_tracker.xxxxxxxxxx (correct device, I tested)
  platform: state
  from: 'away'
  to: 'home'
- service: switch.turn_on
    - switch.xxxxxxxxxxxxxxxxxxx (correct number, I tested)

I can see the smartphone going from away to home, but automation is not released. If I run the trigger the switch goes to on and I have light.

Any help?

Normally, the state change would be from ‘not_home’ to home not from ‘away’ because it’s not a valid state for the device tracker.

You might also want to format the code properly (see blue box at the top) so that formatting errors are visible!


1 Like

Glups…It was so simple. Not_home was the solution.