harmony-api
harmony-api copied to clipboard
Activities working, but unable to get commands working.
I'm able to run GET commands without issue such as
http://192.168.128.59:8282/hubs/harmony-hub/status runs fine.
Even PUT commands to turn off works great as follows:
http://192.168.128.59:8282/hubs/harmony-hub/off
But for some reason, I'm unable to get any of the POST commands to work correctly. Can someone sanity check that I'm calling these correctly, and also review the error I'm receiving in Postman when trying to run POST commands.
http://192.168.128.59:8282/hubs/harmony-hub/devices/sony-tv/commands/volume-down
Returns the following error:
at sendAction (/home/pi/harmony-api/app.js:373:19)
at /home/pi/harmony-api/app.js:532:5
at Layer.handle [as handle_request] (/home/pi/harmony-api/node_modules/express/lib/router/layer.js:95:5)
at next (/home/pi/harmony-api/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/pi/harmony-api/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/pi/harmony-api/node_modules/express/lib/router/layer.js:95:5)
at /home/pi/harmony-api/node_modules/express/lib/router/index.js:281:22
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:354:14)
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:365:14)
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:365:14)
http://192.168.128.59:8282/hubs/harmony-hub/commands/volume-down
at sendAction (/home/pi/harmony-api/app.js:373:19)
at app.put.hubSlug (/home/pi/harmony-api/app.js:483:5)
at Layer.handle [as handle_request] (/home/pi/harmony-api/node_modules/express/lib/router/layer.js:95:5)
at next (/home/pi/harmony-api/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/pi/harmony-api/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/pi/harmony-api/node_modules/express/lib/router/layer.js:95:5)
at /home/pi/harmony-api/node_modules/express/lib/router/index.js:281:22
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:354:14)
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:365:14)
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:365:14)
As i know you can't issue POST commands like GET and PUT directly in a browser. This only works via a REST client in the browser or scripts because you have to format the body information to send (and other parameters). See https://wiki.selfhtml.org/wiki/HTTP/Anfragemethoden
E.g. you can find a good working REST client plugin for firefox here: http://restclient.net/
P.S.: the easier and more flexible way is to use MQTT. Install mosquito on the PI as broker and issue command directly per MQTT publish; you can use a mqtt client here on windows like MQTTFX for testing. MQTT is also very easy to integrate into home-automation frameworks (like pimatic with the mqtt-plugin).