Help with automation and triggers to turn on switch


Totally new to all this but having a lot of fun. I am trying to set up a trigger to turn on a light when I get home.
I have a Tado thermostat which seems to work as a device tracker (it knows when I am home by using my iPhone for geolocation and I have a TP-link switch as a switch.
I am trying to create an automation which links the two together. I know the Tado location works and I know the switch works so I am trying something like…

# Switch light off automatically
automation 4:
  alias: Switch light on when I get close to the house
  initial_state: True
  hide_entity: False
    platform: tado
   event: home
    service: switch.turn_off  

All help welcome… I think I am making a mistake with the event statement?


You need to remember to use the preformatted text markup when posting yaml sections.

You’re missing the entity_id to track, and turn on, and you’ve selected turn_off rather than turn_on :wink: Here’s what I use, which includes using sunset as a condition:

alias: 'Light turns on at sunset'
  platform: state
  entity_id: device_tracker.my_mobile
  state: home
  condition: sun
  after: sunset
  after_offset: '-01:00:00'
  service: switch.turn_on
  entity_id: switch.light_switch_2_0

Yours should be very similar, replacing just the 2 entity_id lines with your entities, and changing the offset from an hour before sunset to whatever works for you.

1 Like

Thanks for the quickhelp… I will try it.

I have an automatic sunset switch which works but no entity statement… Perhaps that’s why my log is full of errors. :slight_smile:

# Switch light on automatically
  alias: Turn on light when sun sets
  initial_state: True
  hide_entity: False
    platform: sun
    event: sunset
    service: switch.turn_on