Offering to implement the Wink Hub 2 bindings

oh2bindings
wink
Tags: #<Tag:0x00007fd30edcd690> #<Tag:0x00007fd30edcd550>

(Shane Grieve) #21

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


(Sébastien Marchand) #22

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!


(Jason) #23

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


(Achaiah) #24

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


(Shawn Crosby) #25

I could help with testing as weel


(kuli) #26

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


(Jason) #27

Hey Sébastien - any update? Would really,
really,
really,
really,
like to try it…


(Scott H.) #28

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


(Sébastien Marchand) #29

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.


(kuli) #30

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.


(Scott H.) #31

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.


(Scott H.) #32

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

(Scott H.) #33

@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.


(Sébastien Marchand) #34

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.


(Scott H.) #35

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


(Scott H.) #36

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


(Sébastien Marchand) #37

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:


(Sébastien Marchand) #38

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.


(Scott H.) #39

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]

(Kai Kreuzer) #40

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!