Offering to implement the Wink Hub 2 bindings

I am really interested in this and already have a wink hub 2.

Sorry for being slow/silent on this! Iā€™ve been really busy recently and didnā€™t had a chance to work on this :(, Iā€™ll try to get a ā€˜shipableā€™ version soon-ish!

Thanks for your patience!

Just got my wink 2 hub delivered as my old one was being flaky. Ready to test whenever you want me to!

@sebmarchand I too have a Wink Hub 2 and would be happy to do some testing when everything is ready.

I could help with testing as weel

Hi,
stumbled on this thread after spending a day trying to get the hang of this openHAB thing on windows.
Iā€™ve got a V1 un-rooted wink hub, and I was looking to dabble into using openHAB via the wink API. Iā€™d like to try out your repo, but thereā€™s pretty much little to zero information in the documentation on how to integrate external add-ons into openHAB. Do I really need to rebuild the entire distro just to use your addon?
I started trying to use the built in http binding and hard-coding the URLā€™s to turn a single light on and off, but it seems that the inability to specify application/JSON in the request headers means that Wink ignores the request. It seems there is a lot of power here, but if I have to re-compile the whole distro for something this simple, it seems a bit convoluted

Hey SĆ©bastien - any update? Would really,
really,
really,
really,
like to try itā€¦

I was able to compile SĆ©bastienā€™s code and create a JAR file. I tried it on my test setup and it worked with my couple zigbee bulbs. I have a wink 1 hub and it worked fine with it. The Wink Hub 2 thing should work with both hub types. To generate an access_token and refresh_token, I used the Home Assistant webapp located here. If other people want to try my JAR file the link is below.

https://drive.google.com/file/d/0Bx6EpCMtJQHVU1dFZnlSWEtmSDA/view?usp=sharing

Thanks Scott! Sorry for the silence here, Iā€™m extremely busy trying to finish some renovations at my home (otherwise my family will have nowhere to sleep when theyā€™ll visit me next month :slight_smile: ) so I didnā€™t had any time to spend on thisā€¦

I think that the last remaining things were to fix/simplify the authentication (Iā€™d love to have something like what Home Assistant does baked in, i.e. you enter your username/password and it do the query for you) and to document the code a little bit more, after that itā€™s ready to submit to the main OpenHab repo.

Right now it only support light bulbs / dimmers (iirc thereā€™s no notion of Dimmer in the Wink API, every lighting device is a light bulb) but adding support for more should be pretty easy! (Iā€™ve tried to add a prototype for a remote and it only took me 10-15 mins to get something functional).

If someone want to help with the authentication part that would be appreciated! The fact that we can use the the Home Assistant WebApp make me think that we could almost release this binding as it is right now and improve it later, but itā€™d be ideal to simplify this if itā€™s not too tricky.

Is there any developers here that would be willing to take a look at my code to see what should be done before sending a PR to OpenHab? Everythingā€™s here: https://github.com/sebmarchand/openhab2-addons/tree/master/addons/binding/org.openhab.binding.wink

Thanks everyone, and sorry again for the silence/delays! I would love to finish this asap but Iā€™ve been extremely busy recently :frowning: , thereā€™s really not much left to do, so hopefully weā€™ll be able to get it done quickly together.

1 Like

Hi,
so even if I have a JAR file, (which I assumed I needed to begin with), how do I go about integrating the add-on into an off-the-shelf install of openhab? There doesnā€™t seem to be a folder with a list of all the add-on JAR files sitting in it. The only method of installing additional add-ons at the moment through the openHAB interface is to install add-onā€™s that were included in the compiled repo.
In short, what is the process here? Can you build the openhab core separately from the add-ons? Can you build single add-onā€™s at a time? How do I integrate a .JAR file into my openHAB install? Can someone point me towards the documentation that I am very clearly missing.
Iā€™m happy to test, tinker, code, and contribute to this effort, but wink is the only home automation product that I have, and I was hoping to mess around with the add-on piece of the install, not have to re-compile the entire openHAB core just to get a proof of concept working.

I added support for binary switches(GE Tapt Switch) on my github but I am still trying to figure out how to create a pull request to your repo. Hopefully I get it figured out soon. I want to add support for properties for things so you can see the radio type, etc.

You have to copy the JAR file to the addon folder of your current openhab install. On a linux system like a raspberry pi the addon folder is ā€œ/usr/share/openhab2/addonsā€. Only manually installed addons will be in this folder. If you are using Samba for openhab configuration, the addon location is normally not accessible remotely. I SSH into my pi, stop the openhab service, change directory to the folder mentioned before and use wget to download the binding. I have a hard time using wget with google drive links so I also uploaded the JAR to my personal web server here. Iā€™ll include all the linux commands below. If you need anymore help please let me know.

sudo systemctl stop openhab2.service
sudo cd /usr/share/openhab2/addons
sudo wget http://pictures.scott-hanson.com/org.openhab.binding.wink-2.0.0-SNAPSHOT.jar
sudo systemctl start openhab2.service
1 Like

@sebmarchand I cannot get the PubSub status updates to work. Do I need to configure it or will it ā€œjust workā€. Maybe you could include polling and pubsub for status update and make it user configurable if needed.

It should ā€œjust workā€, Iā€™ve tried locally with a few devices and I was able to control them from OpenHab2 and the status was updated in the Wink App (after reloading the deviceā€™s page).

You can try adding this to registerToPubNub::status :

if (status.isError()) {
  logger.info("error");
} else {
  logger.info("status: " + status.getStatusCode());
}

to see if thereā€™s an error when registering to the PubNub notifications.

The wink app is updating correctly, but when I control the lights from wink app it doesnt update the status in openhab2.

Iā€™m unsure where to put the code you included. There is no status object in the registerToPubNub method in the WinkHandler.java file.

Sorry, itā€™s called arg1 in this file (see https://github.com/sebmarchand/openhab2-addons/blob/master/addons/binding/org.openhab.binding.wink/src/main/java/org/openhab/binding/wink/handler/WinkHandler.java#L227)

I told you I had some cleanup to do :slight_smile:

All the important PubNub code is in this registerToPubNub function, so it should be pretty straightforward to add some logging to it to debug this issue. Let me know if youā€™d like to have a build with more logging enabled.

Iā€™m getting the following error:

2017-05-27 10:36:16.500 [WARN ] [b.api.workers.SubscribeMessageWorker] - take message interrupted
java.lang.InterruptedException
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(Unknown Source)[:1.8.0_131]
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)[:1.8.0_131]
	at java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)[:1.8.0_131]
	at com.pubnub.api.workers.SubscribeMessageWorker.takeMessage(SubscribeMessageWorker.java:51)[211:org.openhab.binding.wink:2.0.0.201705270412]
	at com.pubnub.api.workers.SubscribeMessageWorker.run(SubscribeMessageWorker.java:42)[211:org.openhab.binding.wink:2.0.0.201705270412]
	at java.lang.Thread.run(Unknown Source)[:1.8.0_131]

I would encourage you to create a PR better sooner than later - you can mark it with ā€œ[WIP]ā€ to state that it isnā€™t ready for a review yet - but having a PR out there makes all your efforts more visible and it will also directly make the binary available on our Artifactory to anyone who wants to test it. Thanks for all your efforts!