Alexa will turn on TV but not turn it off

Hi,
I have set up 2 scripts in HA, that work when executed directly from HA to start and stop TV.

alias: Turn_On_TV
sequence:
  - service: remote.turn_on
    data:
      activity: Watch TV
    target:
      entity_id: remote.harmony_hub
mode: single
icon: mdi:television
alias: Turn_Off_TV
sequence:
  - service: remote.turn_off
    data: {}
    target:
      entity_id: remote.harmony_hub
mode: single
icon: mdi:television

When I ask Alexa to start TV it works but when I ask Alexa to turn it off, the Turn_Off_TV script is not getting called.

In the logbook, it seems like asking Alexa to turn off the TV is only deactivating the Turn_On_TV scene but not calling the second script…

This is what I see in the logbook:
[I ask Alexa to turn on TV]

Amazon Alexa sent command Alexa.SceneController/Activate for Turn_On_TV triggered by service script.turn_on
Turn_On_TV started triggered by service script.turn_on
Turn_On_TV turned on triggered by service script.turn_on
Harmony Hub Activites changed to Watch TV
Harmony Hub  turned on triggered by service script.turn_on

[I ask Alexa to turn off the TV]

Turn_On_TV turned off

Any clues on how to get Alexa to run the Turn_Off_TV script when I ask it?

I’m not sure that you actually need script in home assistant for alexa to turn on/off tv. I can turn my tv on or off using alexa without any script in home assistant. Just ask alexa to turn on or off tv by calling tv by it’s name used by alexa.

Hi,
I’m not just turning on TV but my cable box, AV amplifier through the Harmony Activity. The script basically enables me to run all the actions configured within Harmony Hub. Home Assistant is not able to manage my cable tv box directly since I don’t have any IR device set up outside of Harmony Hub.

Hi.
Alexa is probably confusing the scripts. I would suggest one of these two approaches:

  • Make a routine for each script and set a specific command. Alexa usually prioritizes these commands.
  • Make a TV entity in Home Assistant through Universal Media Player. Here you can combine all the services you need into one entity, which you expose to Alexa. You can see an example for a Harmony remote at the bottom of the docs I linked.
1 Like

I believe you need to ‘turn on scripts’ even if it is the turn off the TV etc. For the Harmony it is usually a call service, script.turn_on and the data would be “PowerOff” (no space).

Option 1 worked:
I renamed my scripts to something more obscure to avoid duplicates and created 2 routines to call the specified scripts within the Alexa app.

Thanks!

Hi Justin, I had also tried this approach but it did not solve my issue.
Option 1 from Florian solved my issue.