So close to new automation need some help!

- alias: Turn off electronics
  initial_state: 'on'
  trigger:
    platform: state
    entity_id:  device_tracker.hostname1
    to: 'Away'
  action:
    - service: switch.music_upstairs
      data:
        entity_id: remote.harmony_hub
        activity: 'PowerOff'

Eventually i want to turn off all electronics but for now it sould just turn off my switch (harmony activity), is there a reason why this doesn’t work?

A couple. You have the wrong to: state in the trigger, and I have no idea what you’re trying to do with that service call. Maybe you want this???

- alias: Turn off electronics
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: device_tracker.hostname1
    to: 'not_home'
  action:
    service: switch.turn_off
    entity_id: switch.music_upstairs
1 Like

i tried the not home too, maybe it is the switch.turn_off, standby

Instead of guessing what the state should be, if you go to your states page and look for the device_tracker entity, look at its history and see what the state changes to. Automations are case sensitive I believe, so make sure it’s all lower case if that’s what it shows on the states page.

History usual shows the “pretty” version, so not_home would show as Away.

True… But you could at least put the device outside of the zone and look there to see what the state changes to.

1 Like

Your harmony activity service isn’t correct. Turning on any harmony activity requires the remote.turn_on service, even if you are using the PowerOff activity. Harmony is weird.

- alias: Turn off electronics
  trigger:
    - platform: state
      entity_id:  device_tracker.hostname1
      to: 'not_home'
  action:
    - service: remote.turn_on
      data:
        entity_id: remote.harmony_hub
        activity: 'PowerOff'