KraigM / homebridge-wink

Wink hub plugin for HomeBridge
54 stars 37 forks source link

Wink Relay Button Integration #3

Closed blaineam closed 8 years ago

blaineam commented 8 years ago

This is a feature request to provide home bridge support for the two buttons on the wink relay so that siri can turn these buttons on or off in a similar manner to a normal light/fan switch.

davidgruhin commented 8 years ago

Seconded!

pdlove commented 8 years ago

When you first run home bridge, it displays "[Wink] Fetching Wink devices.", has two lines starting with "response in http:" of which the second one is REALLY long and should include something like this: "{"data":[{"desired_state":{"pairing_mode":null" near the beginning. Can someone please attach a text file that is a copy/paste of the second line along with the name of the relay so that I can see how it displays? The first line is your authentication token and I recommend NOT including it. If not, we can wait and see if my other changes fix it. It seems like the relay is the one device that can't be shared out.

blaineam commented 8 years ago

http://pastebin.com/GaCZPgT0 text file gathered from that long text with the current version of home bridge-wink. I don't know how to update the version once you release it though @pdlove

blaineam commented 8 years ago

also the name is Wink Relay and a few of my devices just turned off and on lol '(^,^)'

pdlove commented 8 years ago

Sorry if that was me. I think Siri was a bit confused. You can go ahead and un share. I'm done with the coding for all of your devices that were shared. I'm not able to find HomeKit services to assign to the piggy bank but I'm ordering some of them for my kids. :) That dump is exactly what I needed. The relay is presented as a binary_switch which I'm supporting. You have a lot of other device types I haven't even thought of yet. I'll get the complete list together of what still won't be supported later and we'll see what we can do further.

blaineam commented 8 years ago

@pdlove cool I think I for you odd of all the devices so should be good. thanks for all the awesome work. and yeah the piggy banks are cool just you have to decapitate the pig to replace the batteries :D glad that dump worked ok.

pdlove commented 8 years ago

@techyowl I just re-read this request... by supporting the buttons... are you meaning to toggle the devices connected or to expose button presses to apple? the first one is already in my updates, but the second one, while possible, will likely be too delayed to be helpful.

blaineam commented 8 years ago

@pdlove I think just toggle devices connect. They can act as physical in wall light switches and that's what I have them setup as that control the in-wall lines to the ceiling fan and light. I think what you did will work fine. I hope. I've been working on a web app to pin to my macs menu at to access shortcuts and lights and switches and I used some publicly shared got from the original WinkPost v2.0 and modified it quite Beverly as portions were ugly and not functional. I'm still working on refining the design but I had to add binary_switch support to enable the wink relay and such. So it should be supported.

pdlove commented 8 years ago

@techyowl That web app sounds useful. Is it on Github or something different? I've got devices now over 3 different automation platforms and I'd love to centralize all of those into a simple web interface and track metrics of all of them in a simple database with pretty graphs.

blaineam commented 8 years ago

well I got the original version from a google plus account that appears to be abandoned but the dropbox link functioned. It has been modified quite a bit to support the quirky outlets and provide support for binary switches I'm still actively developing it and I plan on launching a version to github but currently its hosted on my web server at link to WinkWeb maybe you'd like to help with development? I'm new to Github but I know how to create a repo so I'll try to set one up here soon with what I have. One main thing though is we need to keep in responsive so that the menu bar works as intended.

screen shot 2016-01-08 at 12 13 12 pm
blaineam commented 8 years ago

@pdlove just in case your curious the original stored the login credentials for the whole thing in a variable in the js file I added a method that instead prompts the user for it and stores it locally as a cookie. I'd like to encrypt it but not sure the benefit really seeing as the api requires it unencrypted.

pdlove commented 8 years ago

I would implement it by storing it encrypted in a database and log the state changes of devices and who did it/when. With my smart things devices I love the history, especially related to temperature sensors and motion detectors. I feel that credentials at rest should always be encrypted to discourage quick access to them by crawler bots. I'm just not sure how to define the program so that anyone with access to the source can't figure out your encryption key and decrypt it.

pdlove commented 8 years ago

Everything on the Wink Relay should be good starting with PR #11

blaineam commented 8 years ago

@pdlove yea a database is always better its just majority of the original script was done with javascript and that is easier to deploy in a mac app as local javascript and html can be rendered in a web view but anyhow I finally got what I was trying to work on to work check it out at WinkWeb on Github it wouldn't be too difficult to modify it to use a database and log activity its just not what I feel like doing. I wonder if there is a way to access the activity via the wink api like their iPhone app does? That might be a great way to do it and maintain the optional database characteristics. I mean if a database was wanted one could simply include a php directory and using javascript attempt to check for php availability and then enable the database portion of the script. anyhow just thought I'd reference what I have done so far with the basis of a few other scripts.

blaineam commented 8 years ago

with version 1.0.1 I can confirm wink relay support does work but siri sends an error in response right as the action actually does complete with iOS version 9.2 its specifically says Sorry, I wasn't able to find any devices this time even though it did turn of my light connected to my wink relays in wall lines. not sure what the issue there is.

blaineam commented 8 years ago

that saying appears after any device call but the device does actually turn on and off so not sure what the issue there is. I will add due to the sirens being adding and siri misinterpreting my command of turn on harmony instead turned on everything which sound the siren which happened to be right by my ear. '(@,@)' ouch '(X,X)'

pdlove commented 8 years ago

It looks like it isn't doing it on locks. I'll trace back and see what is going on. I recommend you add "sirens" to the hide_groups part of your config.json file unless you really want to use them.

pdlove commented 8 years ago

@KraigM Sorry man, but I'm going to have to make a few more changes. Apparently I'm failing to return the correct value to homebridge when I do the callback. It expects the original value to be returned, but I'm returning the value that I sent to Wink.

KraigM commented 8 years ago

@pdlove Ok, we can make a 1.0.2. If it is unrelated to #3 then write up a new issue briefly describing what is happening (so we can look it up later).

KraigM commented 8 years ago

And make sure to comment your commits with the number of whatever issue is used (i.e. "[#3] Fixed...")

pdlove commented 8 years ago

K. @techyowl I'm going to create a new issue on this one since it isn't related specifically to this enhancement.

blaineam commented 8 years ago

@pdlove year I kind of figured the issue was more broad thats why I was trying to test siri for devices that worked prior to the version 1.0.1 and I blocked the siren id so all is good there. and good to know that I can just hide the group sirens I might do that instead.

blaineam commented 8 years ago

The original issue of wink relay button support has been resolved in version 1.0.1 wink relay buttons are now supported through means of binary switch support.