I’m currently working on a Harmony Hub integration for Home Assistant but I’m not sure how I should model all of it in terms of HA entities. Harmony has a couple of concepts:
Devices - these are the individual devices controlled by Harmony. I could see these becoming a switch platform so that you can turn them on/off individually. There should probably also be a service like harmonyhub.send_command in order to send IR commands to that device.
Activities - these are essentially like scenes for Harmony controlled devices. I see a number of ways you could model this:
Have each activity be a separate entity in the harmonyhub domain just like scenes. harmonyhub.turn_on would turn them on. I guess this would require a custom state card? Or could I reuse the scene state card?
Have each activity be switch that only be turned on. To turn it all off, the hub itself would also be a switch that can only be turned off.
Only have the hub itself be an entity whose state is the currently active activity. To switch activity you would do harmonyhub.start_activity and to turn it off you do harmonyhub.turn_off. This would probably require a custom state card, if I understand correctly? Perhaps a dropdown menu?
I’m currently using @maddoxHarmony API, which gets me a switch for every activity of my hub, and another “sensor” for the current activity. Maybe you can take a look to get an idea on this.
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.
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.
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.
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!
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.
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.
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.
@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.
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:
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.
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.
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…