Tv control via harmony hub

I have created the following switch template:

  - platform: template
switches:
  watchtv:
    friendly_name: Watch Tv
    value_template: "{{is_state_attr('remote.upstairs', 'current_activity', 'Watch Tv')}}"
    turn_on:
      service: remote.turn_on
      entity_id: remote.upstairs
      data:
        activity: "34966859"
    turn_off:
      service: remote.turn_off
      entity_id: remote.upstairs
      data:
        activity: "-1"

While this will turn on the desired activity, the switch will then immediately goes to an off state.

Any suggestions on how to make this behave like a normal switch?

I also setup a input_boolean with scripts and automation, however I cannot get those to work with alexa so I thought I would give this switch a try.

Thanks in advance for any suggestions.

I’ve got some switches like this and can confirm it should work. I’d verify the current activity is exactly how you spelled it (case sensitive) because the value_template should return it to the on state as soon as the remote component updates.

@Jer78

Thanks, the activity was not entered correctly; it should have been “Watch TV” instead of “Watch Tv”.