Harmony Hub + Home Assistant + Alexa set up help

Hello!

Please forgive me if this is a redundant question, but I can really use some help here. I’m seeing all kinds of tutorials for scripts and what not, but I’m struggling to find some solid documentation on tying these 3 services together. I’ve used Harmony for years. But I’m new to HA and Alexa. I’ve seen tutorials on how to create scripts for the Harmony Hub, but I’m struggling to understand how to add that to Alexa or just test the scripts in HA. Can I just add whatever I need to configuration.yaml, or do I need to break out scripts in different files? How can I test this script(s)? Where do I need to put this script or config for Alexa to recognize? Do I need to create skills for these activities? Right now I just have a Watch Roku and Play PS3 activities that I care about. I use my activities to control my tv, sound bar, and roku.

Thanks in advance!

Which Roku do you have? If you have a Roku TV you might not need the Harmony Hub at all. I’m not sure though.

In order to use voice commands with Alexa to control Roku and/or Harmony Hub you have to make a separate script for each command you want and you have to have Nabu Casa or the Amazon Alexa manual setup and make your scripts visible to Amazon Alexa then you have to create a separate Routine in Alexa for each script.

In order to find the Harmony Hub commands you have to go to your config folder and look for the conf file that looks like harmony_12345678.conf then open it with a text editor. It will have all of the commands that you can use for your scripts.

I don’t know if the Activities actually work but I do know the other commands work. The commands are listed under each device in the conf folder.

Once you have identified the Activity and/or commands you want to use make a separate script for each of them. The Harmony page at https://www.home-assistant.io/integrations/harmony/ has Service Call examples that you need to include in your scripts.There is also an automation example for activity: "Watch TV" which should be adjustable for a script as the following.

service: remote.turn_on
entity_id: remote.harmony_hub
data:
  activity: "Watch Roku"

I don’t know if that will change your HDMI input or not since I don’t have any Activities setup because my TV has to cycle through inputs inputs instead of jumping directly from one specific input to another.

In my case to change HDMI input I have the following in a script.

data:
  command: InputHdmi
  device: TV
  entity_id: remote.harmony_hub
entity_id: remote.harmony_hub
service: remote.send_command

Once you have the scripts created you can test them by selecting Execute within the page of the specific script or going to the Script page in Configuration then clicking on the Play icon next to the Script that you want to test. If you want to test scripts before creating them you can do that in Services in Developer Tools.

Then either Reload Scripts under Server Controls or restart HA then make sure the scripts are enabled in Alexa in Nabu Casa under Home Assistant Cloud in Configuration. Then Sync Entities. If your script doesn’t show up there it won’t show up in the Amazon Alexa app.

Then on your cellphone or tablet to the Amazon Alexa app then select Routines then click on the plus sign on top right then enter Routine name, when this happens, then Add Action then Smart Home then Control Scene then click on the desired script from HA that shows up in the list.

You don’t need Harmony Hub to control Roku since Roku has it’s own integration and can be controlled directly by HA.

These are the Roku commands that are available to be used in a script using remote.send_command

back
down
forward
left
select
info
play
replay
reverse
right
up
home

I use the Harmony and Roku scripts as buttons for Mini Media-Player I copied the setup here and here

You can also use the media_player.select_source in a script to jump to a specific app within Roku. I have separate scripts for Youtube, Netflix, Prime, and so on, so I can tell Alexa or Google to switch to what I want to watch.

Thanks so much! I think you’re getting me somewhere. I did test the command for activity and it seems to work. I prefer using the harmony hub so I can actually turn the TV on or off as needed, as well as adust the volume, play, pause, etc. However, now that you mention it, I may actually add scripts to talk to the Roku directly for more control. Question about the scripts: do I use trigger or switch? Or sensor? I’ve seen variations of that. Do you have a full example of one, just a power on script, using something like below?

service: remote.turn_on

entity_id: remote.harmony_hub

data:

  activity: "Watch Roku"

If you use the UI to create a script there is no option or need to use trigger, switch or sensor. There is only name, entity id, and sequence. You choose whatever you want for name and entity id. In sequence the Action type should be Call service. Then the rest depends on which command and which service you want to use and so forth.For remote.send_command you have to include entity_id and command. To turn on or off you would use remote.turn_on or remote.turn_off For changing the source you would use media_player.select_source

To find the Roku entity name go to Integrations under Configuration then click on the name of your Roku then 2 entities to see the name of the entities you can control with Scripts through a Call service. The Roku remote will be named remote.name which is what is used in remote.send_command

So for my Play script on my Roku which is a Roku Express and therefore the entity name is remote.express I have the following for the full script

alias: Express Play
sequence:
  - data:
      entity_id: remote.express
      command: play
    service: remote.send_command
mode: single

Just the sequence part is

data:
  entity_id: remote.express
  command: play
service: remote.send_command

So to change that to a power on script like you asked it would be

service: remote.turn_on
data: {}
entity_id: remote.express

If your Roku is named Roku then it would be

service: remote.turn_on
data: {}
entity_id: remote.roku

I imagine that if you wanted you could have two service calls in the same script to turn on then change input or source or turn on then play. I hadn’t thought about that until now.You might also have the option to use templates within the script but I don’t know how to do that.

If you practice changing between Edit with UI and Edit with Yaml you’ll see what goes where in each editing type.

Some additional information - you can use scripts in Automations. So you can automatically have the TV turned off at a specific time or turned off at a specific time with an automation within HA or you can use Alexa routines to automate that.

To power on the TV through Harmony this is what I have as the Yaml. Vizio is the TV brand.

vizio_pwr_on:
  alias: VizioPwrOn
  sequence:
  - data:
      command: PowerOn
      device: Vizio TV
      entity_id: remote.harmony_hub
    entity_id: remote.harmony_hub
    service: remote.send_command

Success!! I can’t believe how easy it is. I even set an automation to press DirectionUp/Down every 3 hours so my dog doesn’t get bored while I’m at work. Thanks so much for your help!

1 Like

One more question: to interact with the hub using Alexa, do I really have to have a remote.send_command script per button, i.e. a script for direction up, a script for direction down? Or is there a way to have all buttons available to Alexa?

Yes, each button needs it’s own remote.send_command script