Harmony send_command

Hi

What is the right syntax to send a command to a device?
I can only se examples to send an activity not a command.

I think this would be useful in the documentation.

Should i use a script or is it possible to send directly from the automation?
Is someone having a working example to share?

Grabbed from another thread:

  service: remote.send_command
    data_template:
      command: Mute
      device: 29753204
      entity_id: remote.living_room

Is this a script or automation?

So you tried and got an error?

Both.

- alias: 'Turn on LED Candles'
  trigger:
    - platform: state
      entity_id: light.candles
      to: 'on'
  action:
    service: remote.send_command
    data_template:
      command: PowerOn
      device: 39544037
      entity_id: remote.livingroom

This dont work. Gives no errors.

1 Like

Have you ruled out an issue with the trigger? What happens when you trigger it manually?

According to the logbook the automation is triggerd so there must be something with the action.

There are a lot of things to debug here.

  • Do you have the right entity_id and device #?
  • Are other remote.turn_on activities working correctly?
  • Do you see the light blink on your hub?

also, have you taken a look at the harmonyhub thread? Lots of examples there.

I have confirmed that the entity_id and device is right.
The remote.turn_on is working fine with my activities.
The led on the hub is not blinking when i trigger the action.

I think the config examples in this forum is very confusing. Some are using quotes around the device and command values and some use data: instead of data_template:. I have also seen examples where the entity_id is directly under the service line and not under data:

So an working example in the documentation would be helpful for all of us using the remote.

The variations you mention are all valid syntax. There are many ways to do the same thing and HA is flexible in places. “data_template” would be required if you were passing any templated data, which you’re not, but it’ll still work.

I’d experiment with the services dev tab to see if you can get things working. The service will want JSON, so you’ll send it something like:

{“entity_id”:“remote.livingroom”,“device”:“39544037”,“command”:“PowerOn”}

Yes, this is doing the same thing as your action, but it’ll let you test settings combinations. If it’s not working in the dev tool, it definitely won’t work in an action.

I found the source to my problems.
When i added the device in myHarmony i manualy teached the remote the on and off command.
I named the commands “Power On” and “Power Off”. That worked when i used the remote, but not from the API.
I removed the device and added it again but now i named the comands “PowerOn” and “PowerOff”. Now everything work fine.
So naming the commands without spacing is required.

1 Like

Weird. I don’t have any, but I’ve seen examples where someone has spaces in their command names.

That is activities and that is working fine with spaces even for me.
When i had spaces in my commands they show upp without spaces in the .conf file.
I guess that messed up everything.

I am having an issue where my pioneer receiver will not respond to PowerOn and both PowerOff and PowerToggle only turn the device off.

Anyone run into this before?

Edit: turns out that things get out of sync, I have to have the scripts send the power command twice to have it jive with harmony. Testing now…

Hi,
Just in case anyone else has similar struggles with send_command.
I’ve just spent hours trying to find out why I could not get this to work, and
turns out my problem was also with how I named the command when I taught it to Harmony.
I called the harmony command ON and also tried On.
This command would work through the dev interface
{“entity_id”:“remote.living_room”,“device”:“42178528”,“command”:“On”}
But I could never get it to work as an action no matter what I tried
Changed it to PowerOn vola it works.

1 Like

You have to fetch the command names and the device ids from harmony_[name].conf file created by HASS. Also don’t put the command name in additional quotes.

wrong: ‘PowerOn’
right: PowerOn