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
trigger:
- entity_id: device_tracker.xxxxxxxxxx (correct device, I tested)
  platform: state
  from: 'away'
  to: 'home'
action:
- service: switch.turn_on
  entity_id:
    - 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?
Thanks.

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!

HomeAss_CodeMarking_From%40finity

1 Like

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