nicoduj / homebridge-harmony

Harmony websocket plugin for homebridge
The Unlicense
214 stars 23 forks source link

Feature Request: Expose Home Control buttons (I know it's a longshot!) #67

Closed mikesalz closed 5 years ago

mikesalz commented 5 years ago

First let me say - This is one of the best homebridge plugins I have used! Thank you for all of your hard work! Question: Is it possible to expose the physical Home Control buttons to HomeKit? I am assuming the answer is a big fat no, since it has not yet been done. But just hoping to get your thoughts on it!

nicoduj commented 5 years ago

Hi, thank you for feedback. Could you tell me more on what you expect ? Not sure to fully understand your request :)

Sent with GitHawk

mikesalz commented 5 years ago

Oh, sorry for the vague request! Some of the higher-end Harmony remotes have physical "Home Control" buttons that can be configured to control Philips Hue lights, Lutron Caseta switches, etc. That's all fine and dandy, but they could really be useful if they were exposed to HomeKit so that they could be configured to trigger a scene. For example, it would be great if you could press a button to trigger your "Movie Night" scene. Thoughts?

image

nicoduj commented 5 years ago

Ok so you want a switch in homebridge linked to the action associated to those buttons in harmony app right ? I don’t have one can you post the config of your hub that uses this es buttons with homebridge launch in debug mode ?

Sent with GitHawk

mikesalz commented 5 years ago

So, forgive me if I'm kind of dumb here... How do I run homebridge in debug mode? I'm running it using Docker on a Synology. And once in debug, how do I get the config of the hub?

nicoduj commented 5 years ago

through config UI you can activate debug mode (top right docker icon, settings) image

mikesalz commented 5 years ago

Hmm... That looks like the UI from here: https://www.npmjs.com/package/homebridge-config-ui-x The problem is, I get all sorts of ugly errors when I try to install that one. Sorry to be so difficult when you are going out of your way to help me! Any other suggestions?

nicoduj commented 5 years ago

stopping the container, adding env variable HOMEBRIDGE_DEBUG=1 and restart should do it.

mikesalz commented 5 years ago

I think I've got it. Please see attached. I have three Harmony hubs. The remotes associated with the Family Room Harmony Hub and the Master Bedroom Harmony Hub both have the Home Control buttons. And again, thanks for your help!! Homebridge.xlsx

nicoduj commented 5 years ago

Thanks i will try to read this on something that handle excel files :) will let you know

Sent with GitHawk

mikesalz commented 5 years ago

Oh man, sorry about the format. It initially exported as CSV, but github wouldn't let me upload that format.

nicoduj commented 5 years ago

The file is completely messed up, I can't read it . Please give it to me as a text file . You should have something beginning with "INFO - Hub config :"

nicoduj commented 5 years ago

I have search a bit on this function, not really sure it is possible since it seems that those buttons are not available inside the mobile APP ...

nicoduj commented 5 years ago

maybe a clue in harmony app code : I really need a config file from the hub that has this feature enable, might be defined in something called haConfig ...

mikesalz commented 5 years ago

I will look for the haConfig. Any suggestions where I would find it? In the meantime, I am attaching a cleaner version of the Homebridge log which may be of assistance. Log.txt

nicoduj commented 5 years ago

Better :) . I took a quick look, I fear there is nothing there. I can try to put some effort into this, but can you tell me if you can trigger those buttons inside harmony app (Android / IOS) ?

mikesalz commented 5 years ago

Hmmm... No, those buttons do not appear in the app. The app is centered more around activities. When you start an activity, you see all of the buttons that are associated with that activity. But these Home Control buttons are really outside of activities. They are physical buttons on the remote, and always perform the same function regardless of what activity you are in. I guess that means it is available inside of the API? :(

nicoduj commented 5 years ago

Hi, I won’t be able to go further on this since especially I can’t configure this myself on harmony. There might be a solution if I refer to the code I saw in harmony app for Android but it would involve specific request to the hub and not sure of their format and even if everything will be possible at all. Sorry !

Sent with GitHawk

mikesalz commented 5 years ago

I can't express to you how much I appreciate your help! If this had worked, it would have been a very clean process. As of this morning, I found a (much messier) workaround and got it to work. But it involved using Home Assistant rather than Homebridge. For your reference (or anyone else who might be trying to achieve the same goal), here is what I had to do:

  1. Install Home Assistant
  2. Add the HomeKit component
  3. Add the Emulated Hue component
  4. Add dummy bulbs to your Emulated Hue
  5. Create HomeKit actions on the dummy bulbs, which trigger your scenes
  6. Add the Emulated Hue Bridge to your Harmony Hub
  7. Configure your Home Control buttons to turn the dummy Hue bulbs on/off
  8. Enjoy!

Helpful links: https://www.home-assistant.io/components/emulated_hue/ https://community.home-assistant.io/t/hacking-the-harmony-home-control-buttons/71954

BetoRn commented 5 years ago

You can achieve this with ha-bridge and homebridge-http-webhooks ....which is essentially the same you described, but instead of lights on the home app, you can publish them as stateless switches which is nicer

mikesalz commented 5 years ago

@BetoRn This sounds interesting. Do you think it would work better than what I have done? Any chance you can provide some examples? I don't really have any experience with webhooks.

BetoRn commented 5 years ago

If you are using Home Assistant for this sole purpose, it may be lighter on system resources, but like I said is essentially the same, but the final result looks nicer:

bulb on: http://yourHomebridgeServerIp:51828/?accessoryId=harmonyRemote&buttonName=Top&event=0

bulb off: http://yourHomebridgeServerIp:51828/?accessoryId=harmonyRemote&buttonName=Top&event=2

photo_2019-02-26_10-17-09

mikesalz commented 5 years ago

Thanks! I wish my Spanish was better! I just want to make sure I follow what you're doing... It looks like you are creating the dummy bulbs as well as the stateless switches. The stateless switch has multiple "fake" buttons on it. Then you pair the switch with the Harmony? Would each button show up as a different option to select in the Harmony configuration screen?

BetoRn commented 5 years ago

It looks like you are creating the dummy bulbs as well as the stateless switches.

yes, you have to create 1 bulb per button on the harmony remote ha-bridge allows you to do anything when you turn on/off that fake bulbs, so we configure ha-bridge to call this url's when turned on and off

bulb on: http://yourHomebridgeServerIp:51828/?accessoryId=harmonyRemote&buttonName=Top&event=0 bulb off: http://yourHomebridgeServerIp:51828/?accessoryId=harmonyRemote&buttonName=Top&event=2

you need to do this for every button you want to use with your harmony remote, changing the buttonName parameter (top and bottom are the names i use for the buttons with the outlet icon on the right side of the remote, the 2 remaining buttons are mapped to real lights)

The stateless switch has multiple "fake" buttons on it.

yes. that config.json creates 1 switch with 2 buttons and 2 types of "events" (single press and long press) for each button, each of this buttons will be mapped to physical buttons on the harmony remote (you can create 4 of course) ...double press is disabled because harmony remotes does not support it

Then you pair the switch with the Harmony?

Then you pair the hue emulator to the Harmony Hub, and assing each fake bulb to a button on the remote, single press to turn on and long press to turn off

and that's it , you can configure all 4 harmony remote buttons in 1 single homekit stateless switch

jimsmt commented 5 years ago

If the home control button on the physical remote can be simulated as a wireless button in homekit, that will be great

BetoRn commented 5 years ago

it is great, albeit a little complicated, very much like having a hue dimmer switch or a Logitech pop.

by the way you can complicate your life a little more and use any tv remote, with a IR receiver on a raspberry pi

nicoduj commented 5 years ago

If the home control button on the physical remote can be simulated as a wireless button in homekit, that will be great

@gitgayhub unfortunately I found no way to handle them through the api . If anyone has any clue on how to do this if possible, let me know !

Sent with GitHawk

jimsmt commented 5 years ago

thanks everyone, I managed to get what I want by using fake emulated hue lights, I use this home assistant component https://www.home-assistant.io/components/emulated_hue/

here's my config for the HA componet

`emulated_hue: host_ip: ip address of HA server listen_port: 8300 off_maps_to_on_domains:

light:

Aafter restarting HA service, it will add 4 emulated fake switches in the HA homebridge, the you can do whatever automation either in HA or in the iOS Home App

jimsmt commented 5 years ago

I have search a bit on this function, not really sure it is possible since it seems that those buttons are not available inside the mobile APP ...

I don't have a real Philips hue light, but I just tested with emulated hue, all the 4 buttons are inside the Harmony iOS App, within the "devices" tab. I can turn it on/off and set brightness

I did run homebridge in debug mode, but there isn't the config file

jimsmt commented 5 years ago

I did find the config json file, in both traditional and the new TV mode, unfortunately there are only the common devices, the emulated hue lights are not included in the found devices

nicoduj commented 5 years ago

Hi, as I said I didn’t find a way through the api to discover home functions. So you cannot use them in the plugin unfortunately

Sent with GitHawk

nicoduj commented 5 years ago

From what I see it might be http requests and not websocket . Will try to see the detail info you sent !

Sent with GitHawk

nicoduj commented 5 years ago

Could you try to use postman with ssl proxy and your phone while you launch the app and send request ? Some tuto there : https://learning.getpostman.com/docs/postman/sending_api_requests/capturing_http_requests/ . Check that ssl proxy is active : https://i.stack.imgur.com/msWWj.png

Sent with GitHawk

jimsmt commented 5 years ago

I'm really sorry I made a big mistake, those responses are not from the Harmony hub, they are from the homeassistant Hue plugin which is installed on the router.

Wireshark didn't capture the websocket traffic between my iPhone and the Harmony hub, I'm still trying to find a way to do that

nicoduj commented 5 years ago

Ok :)

Sent with GitHawk

jimsmt commented 5 years ago

Could you try to use postman with ssl proxy and your phone while you launch the app and send request

I did, but https traffic is not proxyed, and when I open the harmony app, nothing happen on postman.

I also tried fiddler4, but the https certificate is wrong, still trying to use tshark on my Debian server as the route gateway to caputre the websocket traffic

jimsmt commented 5 years ago

Sorry for the mistake, I finally captured the websocket traffic

GET /?domain=svcs.myharmony.com&hubId=10169766 HTTP/1.1
Host: 192.168.2.163:8088
Sec-WebSocket-Key: removed==
Sec-WebSocket-Version: 13
Upgrade: websocket
Origin: http://192.168.2.163:8088/
Authorization: removed;removed
Connection: Upgrade

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: upgrade
Sec-Websocket-Accept: removed+removed=

.....z...X.d.3.3.X.!.L.&.L.=...|...e.@.!.X.s.   .+.X.u.@.%.H. .N.).V.r...+...u...v...r.T.~...r.&.g...}...e...?...e...v. .....3.X.~...3.X.X.*.(...A.N.H...!.N.P.K.$.H.%.C.*.5.h.4.b.".G.4.T...!..."...3.X.p...b.@.3...s.@.v...=...c...3.X.b...l.............h...?...-...*...1...h...f...?...(...-.../...~...'...o...d...i...i..."...n...x...i...s...O...[...Z...~...M...E...(...%...*...L...l..._...$...v...V...v...m...p...f....~..{"cmd":"vnd.logitech.connect\/vnd.logitech.statedigest?get","code":200,"id":"462015468","msg":"OK","data":{"sleepTimerId":-1,"runningZoneList":[],"sequence":false,"activityId":"25262564","errorCode":"200","syncStatus":0,"discoveryServer":"https:\/\/svcs.myharmony.com\/Discovery\/Discovery.svc","stateVersion":58,"tzOffset":"28800","mode":3,"hubSwVersion":"4.15.250","deviceSetupState":[],"tzoffset":"28800","isSetupComplete":true,"activitySetupState":false,"runningActivityList":"25262564","configVersion":198,"time":1553254599,"activityStatus":2,"wifiStatus":1,"tz":"HKT-8","updates":{"106":"4.14.112","100":"4.14.112"},"IPIRConversionDate":"2018-08-13T23:07:55.774Z","hubUpdate":false,"contentVersion":74,"accountId":"9321133"}}.~..{"cmd":"harmony.automation?getstate","code":200,"id":"1555605542","msg":"OK","data":{"hue-light.harmony_virtual_button_3":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":false,"status":0},"hue-light.harmony_virtual_button_4":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":false,"status":0},"hue-light.harmony_virtual_button_1":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":false,"status":0},"hue-light.harmony_virtual_button_2":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":false,"status":0}}}.....h.^.J.+.!.|.J.n.^.i.^.r...+.J.%...|.J.i.\.m.Y.n.D.=...d...,...'.   .*...*...a.
.-. .;.D.*...0.R...+...&...".=.>...,...S.k.[.f.P.i.#...../.....$.g.Y.5._...Z.5.D.....3.J.%...?.
.d.J.+.E.7...p. .3.......*. .....*...m.R.|...d...;...#..M{"cmd":"harmony.automation?setstate","code":200,"id":"1794236100","msg":"OK"}.~..{"type":"automation.state?notify","data":{"hue-light.harmony_virtual_button_3":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":true,"status":0}}}....Oi..4K..- ..uK..~_..y_..m...<K..m...uK..w\..vQ..cK..+K..'... ......."... ...*.......cK..$...uK...9.......].......]..tX..|[..wP...&..+'.. 1...'..~=..x...}...cK..=...mS..<...*K..m...b...'.......!...&.......:...!6..u...!K......2...2.L{"cmd":"harmony.automation?setstate","code":200,"id":"968549983","msg":"OK"}.~..{"type":"automation.state?notify","data":{"hue-light.harmony_virtual_button_3":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":false,"status":0}}}
jimsmt commented 5 years ago
{
    "cmd": "harmony.automation?getstate",
    "code": 200,
    "id": "1555605542",
    "msg": "OK",
    "data": {
        "hue-light.harmony_virtual_button_3": {
            "color": {
                "mode": "xy",
                "xy": {
                    "y": 0,
                    "x": 0
                },
                "temp": 300,
                "hueSat": {
                    "hue": 0,
                    "sat": 0
                }
            },
            "brightness": 254,
            "on": false,
            "status": 0
        },
        "hue-light.harmony_virtual_button_4": {
            "color": {
                "mode": "xy",
                "xy": {
                    "y": 0,
                    "x": 0
                },
                "temp": 300,
                "hueSat": {
                    "hue": 0,
                    "sat": 0
                }
            },
            "brightness": 254,
            "on": false,
            "status": 0
        },
        "hue-light.harmony_virtual_button_1": {
            "color": {
                "mode": "xy",
                "xy": {
                    "y": 0,
                    "x": 0
                },
                "temp": 300,
                "hueSat": {
                    "hue": 0,
                    "sat": 0
                }
            },
            "brightness": 254,
            "on": false,
            "status": 0
        },
        "hue-light.harmony_virtual_button_2": {
            "color": {
                "mode": "xy",
                "xy": {
                    "y": 0,
                    "x": 0
                },
                "temp": 300,
                "hueSat": {
                    "hue": 0,
                    "sat": 0
                }
            },
            "brightness": 254,
            "on": false,
            "status": 0
        }
    }
}
{
    "cmd": "harmony.automation?setstate",
    "code": 200,
    "id": "1794236100",
    "msg": "OK"
}
{
    "type": "automation.state?notify",
    "data": {
        "hue-light.harmony_virtual_button_3": {
            "color": {
                "mode": "xy",
                "xy": {
                    "y": 0,
                    "x": 0
                },
                "temp": 300,
                "hueSat": {
                    "hue": 0,
                    "sat": 0
                }
            },
            "brightness": 254,
            "on": true,
            "status": 0
        }
    }
}
{
    "cmd": "harmony.automation?setstate",
    "code": 200,
    "id": "968549983",
    "msg": "OK"
}
{
    "type": "automation.state?notify",
    "data": {
        "hue-light.harmony_virtual_button_3": {
            "color": {
                "mode": "xy",
                "xy": {
                    "y": 0,
                    "x": 0
                },
                "temp": 300,
                "hueSat": {
                    "hue": 0,
                    "sat": 0
                }
            },
            "brightness": 254,
            "on": false,
            "status": 0
        }
    }
}
jimsmt commented 5 years ago

And I found the commands to get and set status for home control devices

{"hubId":"hubid_removed","timeout":30,"hbus":{"id":"462015468","cmd":"vnd.logitech.connect\/vnd.logitech.statedigest?get","token":"removed;1553284897;removed","params":{"verb":"get","format":"json"}}}

{"hubId":"hubid_removed","hbus":{"id":"1555605542","cmd":"harmony.automation?getstate","token":"removed;1553284897;removed","params":{}}} This will return the config file for all home control devices

{"hubId":"hubid_removed","hbus":{"id":"1794236100","cmd":"harmony.automation?setstate","token":"removed;1553284897;removed","params":{"state":{"hue-light.harmony_virtual_button_3":{"on":true}}}}}

This will turn on the device hue-light.harmony_virtual_button_3. The hub will first return a "200" code, then followed by the new status of the controlled device with a new json file as shown in the previous comment '"type": "automation.state?notify"'

{"hubId":"hubid_removed","hbus":{"id":"968549983","cmd":"harmony.automation?setstate","token":"removed;1553284897;removed","params":{"state":{"hue-light.harmony_virtual_button_3":{"on":false}}}}}

This will turn off the device hue-light.harmony_virtual_button_3

The token can be removed, it still works

nicoduj commented 5 years ago

Ok, thank you I have everything I need . I will try to integrate and keep you informed for testing purpose since I don’t have those options :) will need a modification of harmonylib also will propose a pull request to @lopelex

Sent with GitHawk

jimsmt commented 5 years ago

please feel free to ask me to test your plugin, I'm happy that I can help

I don't have a physical hue light either, I used this home assistant component to emulate fake lights https://www.home-assistant.io/components/emulated_hue/

nicoduj commented 5 years ago

Work in progress , will do it in blind mode :) I have hue lights, but my harmony does not have those features ;)

Sent with GitHawk

mikesalz commented 5 years ago

Glad to see this is still in motion! @nicoduj, please let me know if there is anything I can do to help test. I did get the home control buttons to control HomeKit indirectly by using Emulated Hue lights, but it would be much cleaner if a direct connection to HomeKit could be made!

nicoduj commented 5 years ago

I pushed a first try : You have to set 2 new parameters :

For manual update, take the following files and replace : harmonyConst.js harmonyBase.js harmonyAsSwitch.js harmonyAsTVPlatform.js

nicoduj commented 5 years ago

currently I get this : INFO - got Home Control : {"cmd":"harmony.automation?getstate","code":583,"id":"0.9864325494403279","msg":"Failed to retrieve automation state"}

Let me know if at least you get a config ! or an error

nicoduj commented 5 years ago

Done in master branch (not yet in beta branch with dynamic platform mode)

Sent with GitHawk

jimsmt commented 5 years ago

got this error message, buttons not published to the Home app, publishHomeControlButtons set to be true

[My Harmony] INFO - got Home Control : {"cmd":"harmony.automation?getstate","code":200,"id":"0.11199321450018873","msg":"OK","data":{"hue-light.harmony_virtual_button_3":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":false,"status":0},"hue-light.harmony_virtual_button_4":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":false,"status":0},"hue-light.harmony_virtual_button_1":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":false,"status":0},"hue-light.harmony_virtual_button_2":{"color":{"mode":"xy","xy":{"y":0,"x":0},"temp":300,"hueSat":{"hue":0,"sat":0}},"brightness":254,"on":false,"status":0}}}
[3/23/2019] [My Harmony] INFO - Discovered Home Control : hue-light.harmony_virtual_button_3
[3/23/2019] [My Harmony] ERROR - getHomeControlsAccessories ReferenceError: homeControl is not defined
nicoduj commented 5 years ago

ok, you can try again by replacing harmonyBase.js :)

jimsmt commented 5 years ago

There's no error message this time, but still no button published to the Home app, I deleted the accessories and persist folder, deleted the bridge in Home app and add again, still no button

[3/23/2019] [My Harmony] INFO - Discovered Home Control : hue-light.harmony_virtual_button_3
[3/23/2019] [My Harmony] INFO - Adding Accessory : My Harmony-hue-light.harmony_virtual_button_3
[3/23/2019] [My Harmony] INFO - Discovered Home Control : hue-light.harmony_virtual_button_4
[3/23/2019] [My Harmony] INFO - Adding Accessory : My Harmony-hue-light.harmony_virtual_button_4
[3/23/2019] [My Harmony] INFO - Discovered Home Control : hue-light.harmony_virtual_button_1
[3/23/2019] [My Harmony] INFO - Adding Accessory : My Harmony-hue-light.harmony_virtual_button_1
[3/23/2019] [My Harmony] INFO - Discovered Home Control : hue-light.harmony_virtual_button_2
[3/23/2019] [My Harmony] INFO - Adding Accessory : My Harmony-hue-light.harmony_virtual_button_2

[3/23/2019] [My Harmony] checkOn : 27059913/hue-light.harmony_virtual_button_3/false/false
[3/23/2019] [My Harmony] Got status for hue-light.harmony_virtual_button_3 - was false set to false
[3/23/2019] [My Harmony] checkOn : 27059913/hue-light.harmony_virtual_button_4/false/false
[3/23/2019] [My Harmony] Got status for hue-light.harmony_virtual_button_4 - was false set to false
[3/23/2019] [My Harmony] checkOn : 27059913/hue-light.harmony_virtual_button_1/false/false
[3/23/2019] [My Harmony] Got status for hue-light.harmony_virtual_button_1 - was false set to false
[3/23/2019] [My Harmony] checkOn : 27059913/hue-light.harmony_virtual_button_2/false/false
[3/23/2019] [My Harmony] Got status for hue-light.harmony_virtual_button_2 - was false set to false
jimsmt commented 5 years ago

Plugin will seek for homecontrol device only if publishHomeControlButtons is set to be true, no matter whether the publishHomeControlsAsIndividualAccessories option set to be true or not, there's no log info about home automation device in debug

nicoduj commented 5 years ago

hum ... your log seems to add the accessories ... aren't they in default room ? concerning the config, yes, publishHomeControlsAsIndividualAccessories is ignored if publishHomeControlButtons is false can you try with publishHomeControlButtons : true and publishHomeControlsAsIndividualAccessories : false ?