Thanks @Maddox and @rpitera But I can’t take the credit for your work Jon. I’m impressed how fast you cranked it out! You got skills my friend!
Just found out in order for me to use the scripts I had to symbolically link the token file to the root directory /
Otherwise I’d get homeassistant.components.switch.command_line: Command failed: /home/hass/.homeassistant/harmony/HarmonyHubControl ur ps 10.0.1.16 issue_device_command 37313947 PowerOn
sudo ln -s /home/hass/.homeassistant/harmony/HarmonyHub.AuthorizationToken /HarmonyHub.AuthorizationToken
@rpitera thanks for the great instructions!
I’m having an issue installing the api itself. I’ve copied the files from github into the /home/pi/harmony-api-master directory. When I try to run script/bootstrap (even with sudo) I get a “command not found” error. I’m guessing its a dependancy issue perhaps because no one else seems to have had this issue, or am I just missing something really obvious here…?
I’m running npm 3.10.9 and have run all the commands you listed in your instructions.
Sorry, I’ve been down with the flu.
The only thing I can think of at the moment is that you should be in the root of the harmony directory when executing the command.
I am using the maddox Harmony API in combination with a local MQTT broker.
My setup is using switches as follows:
- platform: mqtt
name: "Radio"
state_topic: "harmony-api/hubs/marno/activities/radio/state"
command_topic: "harmony-api/hubs/marno/activities/radio/command"
qos: 0
payload_on: "on"
payload_off: "off"
- platform: mqtt
name: "Kodi"
state_topic: "harmony-api/hubs/marno/activities/kodi-tv/state"
command_topic: "harmony-api/hubs/marno/activities/kodi-tv/command"
qos: 0
payload_on: "on"
payload_off: "off"
I have noticed that the state of these switches is updating very slowly/badly in HA. Usually I have to F5 the page to get the proper state to show, I have streaming updates enabled.
Anyone have a similar issue?
Maybe something introduced in the newer versions? I don’t have this issue - it either works right away or doesn’t at all and requires a reboot - but then I am still on the original version that didn’t have support for the extended attributes on MQTT logins (specifying a port, etc.).
Could be related to an issue I’'m having.
For the past week or so, the Maddox Harmony API I have running in a Docker just stops updating the status of my Harmony Hub. So, if I am watching TV and turn the TV off, Home Assistant won’t receive an update from MQTT that the TV has been turned off. I also then can’t use Home Assistant to control my Harmony Hub via MQTT.
I’m going to upgrade my version of the Maddox API today, to see if that makes it more stable, but there’s an issue on GitHub that might be related: https://github.com/maddox/harmony-api/issues/29
@philhawthorne - we must be using the same old version; you’re describing what happens to me to the letter.
Also, I am using CloudMQTT - are you using a local server? I’m wondering what similarities we may have.
I’m using a local MQTT server.
I’ve just upgraded my version of the Harmony API to 2,0, and noticing the following
- v2.0 requires net discovery to discover each Harmony Hub. While watching the output of the app, it seems to lose connection to my Harmony Hub every couple of minutes, with an error message
Hub lost: Harmony Hub at 192.168.1.5.
. It then takes about 10-20 seconds to re-establish connection to the Hub. During this time, commands won’t work over MQTT. So if HASS tries to turn on the TV, it won’t work. - In 1.x there was the ability to specify the
hub_ip
, this seems to be removed from v2.x but still documented in the readme.
My harmony-api instance also crashed with a similar trace that was in the GitHub issue I linked above.
Overall, I think the harmony-api at the moment isn’t as reliable as it used to be. I know Harmony recently announced support for Amazon Echo, so I’m guessing a software update has gone out to everyones hubs, and now API connections are unstable.
Yeah, I was following the updates via github messaging and was worried about the same thing which is why I stayed with the older version. Mine is working fine tonight, ironically enough.
I’m fairly happy with the Echo integration, but couldn’t change any settings from my tablet so I ended up disabling the skill and then enabling it again using the desktop web version of the Alexa app (alexa.amazon.com) where I was able to access all the settings. I still need to go back and edit some of my favorites but overall I am happy with it. But I only have one hub; apparently the skill will only work with one hub and a lot of folks are complaining about that.
Yeah, I am still waiting for my Echo Dots to arrive before I start playing with that. Another alternative I’ve heard of is called Yonomi which can handle multiple hubs.
Not sure what I can do for the time being with my Harmony Hub. This API, and the new component being tested aren’t too reliable. I mainly just need it for knowing when my TV is on or off, so might look at other ways to detect that for the time being.
I still use Yonomi for some things but with the Harmony Skill, I’ll probably be phasing that out. But Yonomi is a pretty neat app.
I am on the new version of Maddox’s API, using 2 hubs, CloudMQTT and having no issues. I wonder if it’s related to the local MQTT server?
New HA user and trying to integrate maddox harmony api with this. I have HA and harmony api both running. I can query and control my activities and devices through the harmony api. My question now is how do I add it to HA. Going through the thread, there seems to be couple options, restful vs mqtt vs command line. I would think since I can make rest GET/PUT calls to harmony api, I should be able to add those as command switch to HA. But not sure how would I go about doing this, specially where I want to do device commands like volume up/down/mute/channel up/down/play/pause/stop commands etc. Can you please point me on how to go about doing this.
Thanks
Scroll up. A number of examples were provided in this thread.
Hi,
I was running version 2.10 on a raspberry pi2. Home assistant was installed using the all-in-one installer (including mosquitto for mqtt) @maddox harmony-api has been working very well for me until I decided to move everything over to a Pi3.
Using the latest version (2.3.1) of harmony-api I receive feedback from activities fine:
But when I send the mqtt command from the switch is HASS harmony-api crashes with the following and then restarts:
pi@raspberrypi:/home/hass/.homeassistant/plugins/harmony-api-master $ script/server
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
Starting discovery.
Hub discovered: HarmonyHub at 192.168.1.187.
Updating activities for harmonyhub.
Updating state for harmonyhub.
Updating devices for harmonyhub.
Updating state for harmonyhub.
/home/hass/.homeassistant/plugins/harmony-api-master/app.js:101
activitySlug = harmonyHubStates[hubSlug].current_activity.slug
^
TypeError: Cannot read property ‘current_activity’ of undefined
at MqttClient. (/home/hass/.homeassistant/plugins/harmony-api-master/app.js:101:45)
at emitThree (events.js:116:13)
at MqttClient.emit (events.js:194:7)
at MqttClient._handlePublish (/home/hass/.homeassistant/plugins/harmony-api-master/node_modules/mqtt/lib/client.js:792:12)
at MqttClient._handlePacket (/home/hass/.homeassistant/plugins/harmony-api-master/node_modules/mqtt/lib/client.js:282:12)
at process (/home/hass/.homeassistant/plugins/harmony-api-master/node_modules/mqtt/lib/client.js:238:12)
at Writable.writable._write (/home/hass/.homeassistant/plugins/harmony-api-master/node_modules/mqtt/lib/client.js:248:5)
at doWrite (/home/hass/.homeassistant/plugins/harmony-api-master/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/home/hass/.homeassistant/plugins/harmony-api-master/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Writable.write (/home/hass/.homeassistant/plugins/harmony-api-master/node_modules/readable-stream/lib/_stream_writable.js:194:11)
error: Forever detected script exited with code: 1
error: Script restart attempt #1
Starting discovery.
Hub discovered: HarmonyHub at 192.168.1.187.
Updating activities for harmonyhub.
Updating state for harmonyhub.
Updating devices for harmonyhub.
This is my config which is still working with the older version on my Pi2 (no I’m not running both together, switched off to test the Pi3)
switch:
- platform: mqtt
name: “TV”
state_topic: “harmony-api/hubs/harmonyhub/activities/tv/state”
command_topic: “harmony-api/hubs/harmonyhub/activities/tv/command”
payload_on: “on”
payload_off: “off”
qos: 0- platform: mqtt
name: “Plex”
state_topic: “harmony-api/hubs/harmonyhub/activities/plex/state”
command_topic: “harmony-api/hubs/harmonyhub/activities/plex/command”
payload_on: “on”
payload_off: “off”
qos: 0- platform: mqtt
name: “Xbox ONE”
state_topic: “harmony-api/hubs/harmonyhub/activities/xboxone/state”
command_topic: “harmony-api/hubs/harmonyhub/activities/xboxone/command”
payload_on: “on”
payload_off: “off”- platform: mqtt
name: “Apple TV”
state_topic: “harmony-api/hubs/harmonyhub/activities/appletv/state”
command_topic: “harmony-api/hubs/harmonyhub/activities/appletv/command”
qos: 0
payload_on: “on”
payload_off: “off”- platform: mqtt
name: “Android TV”
state_topic: “harmony-api/hubs/harmonyhub/activities/androidtv/state”
command_topic: “harmony-api/hubs/harmonyhub/activities/androidtv/command”
qos: 0
payload_on: “on”
payload_off: “off”- platform: mqtt
name: “PC”
state_topic: “harmony-api/hubs/harmonyhub/activities/pc/state”
command_topic: “harmony-api/hubs/harmonyhub/activities/pc/command”
qos: 0
payload_on: “on”
payload_off: “off”- platform: mqtt
name: “Xbox 360”
state_topic: “harmony-api/hubs/harmonyhub/activities/xbox360/state”
command_topic: “harmony-api/hubs/harmonyhub/activities/xbox360/command”
qos: 0
payload_on: “on”
payload_off: “off”
This is what my config.json file looks like for harmony-api (same on both the old and new versions on harmony-api), I know this is working as I’m getting status reports on activities:
{
"mqtt_host": "mqtt://127.0.0.1",
"mqtt_options": {
"port": 1883,
"username": "pi",
"password": "password",
"rejectUnauthorized": false
}
}
Has anyone else experienced this with v2.3.1? Would really appreciate your help. I have been using v2.1.0 and older for a while now and it’s been absolutely rock solid!
Thanks
Fixed with 2.3.2
Wow that was quick! Thanks @maddox
Good news is I don’t get the crash anymore but the on and off commands aren’t doing anything. I’m still getting feedback on which activity is on though.
Is there anyway I can output a log to see what’s going on?
Thanks again!
I’ve been running mosquitto_pub/_sub from command line to take HASS out of the loop, I’m seeing the state from _sub but sending command on via _pub doesn’t seem to be doing anything. Just updated to the latest version on the working pi and I’m getting the same results:
pi@raspberrypi:~ $ mosquitto_sub -u pi -P password -t harmony-api/hubs/harmonyhub/activities/tv/state
on
^C
pi@raspberrypi:~ $ mosquitto_sub -u pi -P password -t harmony-api/hubs/harmonyhub/activities/androidtv/state
off
^C
pi@raspberrypi:~ $ mosquitto_pub -u pi -P password -t harmony-api/hubs/harmonyhub/activities/androidtv/command -m on
pi@raspberrypi:~ $ mosquitto_sub -u pi -P password -t harmony-api/hubs/harmonyhub/activities/androidtv/state
off
^C
pi@raspberrypi:~ $
I have been trying to get harmony-api updated to 2.0. I seem to have done so, but now my switches in Home Assistant aren’t working anymore. So I need to troubleshoot.
First step, I would think, is to make sure harmony-api is working from the command line. So if I do 'mosquitto_sub -v -t ‘#’ -u -P ’ then I get:
harmony-api/hubs/freds-harmony-hub/current_activity watch-xbox-one
harmony-api/hubs/freds-harmony-hub/state on
harmony-api/hubs/freds-harmony-hub/activities/watch-a-disc/state off
harmony-api/hubs/freds-harmony-hub/activities/play-xbox-360/state off
harmony-api/hubs/freds-harmony-hub/activities/listen-to-radio/state off
harmony-api/hubs/freds-harmony-hub/activities/play-nintendo-wii/state off
harmony-api/hubs/freds-harmony-hub/activities/listen-to-record/state off
harmony-api/hubs/freds-harmony-hub/activities/watch-xbox-one/state on
harmony-api/hubs/freds-harmony-hub/activities/use-roku-stick/state off
harmony-api/hubs/freds-harmony-hub/activities/poweroff/state off
So it can read states; that’s a good sign. Problem is that the switches that I had defined, such as:
- platform: mqtt
name: "Snowman"
state_topic: "harmony-api/hubs/freds-harmony-hub/activities/watch-xbox-one/state"
command_topic: "harmony-api/hubs/freds-harmony-hub/activities/watch-xbox-one/command"
payload_on: "on"
payload_off: "off"
…aren’t working anymore.
So is it mosquitto_pub that I use to execute the activity manually? I don’t know how to do that but it seems like that would be the first step to getting this working again, to make sure harmony-api can in fact get the activities to execute and not just watch before I worry about tying it back into Home Assistant.
Can someone help?