Harmony Hub

Can you have switches that can only be turned on? I guess you could have the switches for non-active activities automatically turn off if you turn another one one but it feels like the switch model is not quite a perfect fit for Harmony activities, especially since you would have to turn all of them off in order to “turn Harmony off”. Or what do other people think?

@emil-e With the config I use (you can see an example below), you only have to turn off one switch to turn harmony off, as the switches updates themselves with the state of the activity.

example config:

switch:
  - platform: mqtt
    name: "TV Salon"
    state_topic:   "harmony-api/activities/ver-tv/state"
    command_topic: "harmony-api/activities/ver-tv/command"
    payload_on: "on"
    payload_off: "off"
  - platform: mqtt
    name: "Plex"
    state_topic:   "harmony-api/activities/htpc/state"
    command_topic: "harmony-api/activities/htpc/command"
    qos: 0
    payload_on: "on"
    payload_off: "off"
  - platform: mqtt
    name: "Radio"
    state_topic:   "harmony-api/activities/radio/state"
    command_topic: "harmony-api/activities/radio/command"
    qos: 0
    payload_on: "on"
    payload_off: "off"

1 Like

Yeah, it is not that inconvenient, obviously. But since this is a custom component I’m thinking we have the option to model it in the way that is closest to how Harmony actually works, not only the way that fits into the switch metaphor.

Then maybe the closest thing are the scripts, since they show in the UI as a “push button”.

Either that or https://home-assistant.io/components/input_select/

Not answering the question directly, but FYI there is a feature request (that I created) for Harmony Hub integration at Logitech Harmony API and a previous work on implementation at https://github.com/home-assistant/home-assistant/issues/1003; this looks to have gone some way but has been stalled now for a couple of months.

D

1 Like

Nothing to contribute - but letting you know that I’d be interested in your implementation. I have yet to implement the harmony-api MQTT component, but native platform integration sounds fantastic to me!

1 Like

Me too; I’ve been following this thread and would be willing to help in any testing.

That’s great! I’m currently a bit focused on actually making my Home Assistant setup work in genera but I have gotten some way on modifying pyharmony (a lot) to support asynchronous modifications among some other things. I will make a PR and post in this thread once I have anything working at all.

1 Like

I have 2 hubs and would welcome any testing.

Btw, has anyone done anything about integrating with the Harmony Hub in the other direction? That is, be able to control lights in HA using the device buttons on the harmony remote.
I was able to do that in OpenHAB by using this: https://github.com/armzilla/amazon-echo-ha-bridge but I haven’t looked into if I can still use this for HA. I’d also prefer not to have to run another process for this.

1 Like

I’ve gotten the basics up with non-polling notification about activity change and basic config retrieval.

@balloob
Could I get your input on how to fit this in the HA model in a good way? I don’t think the activities make sense as switches since only one can be active at the same time. You could see the hub as a “multi switch” that can have multiple states, not just on/off but there’s no such component. I could make a custom component with its own state card (dropdown list and power button I’m thinking) but that would be a domain and state card only for a single type of component.

1 Like

any updates on this?

1 Like

@emil-e any updates on your progress? I’m finding harmony-api by Maddox is a little to daunting for me. I think I could figure out the MQTT part, but I still can’t figure out how to install it in the first place. I managed to get the scripts over and executed bootstrap, but it requires forever and the command “sudo npm install forever -g” suggested by the script doesn’t work in Raspian. And pip can’t find forever to install it.

Still no progress on getting the harmony API to work. With some help I got it installed but can’t get it to start… :disappointed_relieved:

Finally got it running; turns out I needed to update my npm install, which I did by running the following command, twice:

sudo npm install npm -g

then I reinstalled the harmony-api using the command:

sudo script/bootstrap

I could instantly tell this was going to work as the installer looked completely different. It requires npm 3.0.0 or greater, BTW. Finally I can see it running and I can get to the API web page! Now I just have to get it to start on reboot, by doing the following… Open the crontab:

sudo crontab -e

and get the Pi to wait 60 seconds, then start the server by adding this line at the bottom:

@reboot sleep 60 && sudo /home/pi/harmony-api-master/script/server

So I ended up answering most of my own questions, but I thought I’d document them here to help someone else that may be having trouble getting it to work. :sweat_smile:

2 Likes

Cheers for this. Finally got me over the hump and now I have it running on my Ubuntu nas server.
You can get this running as a service using forever
sudo npm install -g forever
then
sudo npm install -g forever-service
once that is installed cd into the harmony api directory that contains the app.js file and run
sudo forever-service install harmony
you can then interact with harmony like any other service
sudo start harmony
forever looks after the init.d scripts and making sure it run when the machine is rebooted etc.

1 Like

Thanks for the pointers; my main problem now is getting it to communicate with MQTT. I use CloudMQTT and harmony-api currently doesn’t support username/pw/port so I’m not sure what to do next. I’ve asked if you can run two MQTT instances in HA with the idea of running the embedded MQTT just for harmony but I haven’t gotten any response from the forum or reddit on it.

I suppose I could use http communication but not sure how to use that in my automations to do things like turn on a light scene when a harmony activity fires…

I have fallen at this hurdle too. I have a local mqtt broker running on port 1883 with no auth and cant seem to get harmony-api to talk to it. No errors are reported but nothing is getting published onto the topics i’m watching and the switches I have configured in HA do nothing :anguished:

Actually just got this working and talking to HA. All you have to do is edit the app.js file and the line that has mqtt.connect & change it to
mqtt.connect(config.mqtt_host, {username: 'username', password: 'password', port: 1883})

I’m using mosquito on my local box and it is using protocol 3.1. mqtt on npm uses v4 so just add the following to your connection
var mqttClient = mqtt.connect('mqtt://127.0.0.1',{protocolId: 'MQIsdp', protocolVersion: 3 });
that issue is detailed here
Once i did that it all started working perfectly

1 Like