Wink Hub integration with OpenHAB for local control
by electronichamsters
.
Lighting Automation.
The best smart bulb on the market (price & performance) is probably the GE Link bulb. For $15, you get a dimmable 800 lumen, 12W LED light bulb that’s controlled via Zigbee. Problem is, how do you control it? How do you automate it?
Mi Casa Verde’s Vera hub? No. No Zigbee radio (as of December 2014 anyways).
SmartThings hub? It’ll work, but you’re forced to use “the cloud”, so if you lose internet (or if ST cloud goes down) you can’t control your lights. But the combination of the ST hub and their Arduino shield gives some alternative methods of lighting control without having to pull out a smart phone.
Wink hub? Same problem as the SmartThings hub (cloud required). That is, until I ran into this and this. So now you can root the hub, and have a means of controlling connected bulbs locally, without haivng to go through Wink’s servers. Since I already have so much stuff integrated with OpenHAB, I wanted to do local control via OpenHAB. And I really don’t like having to depend on the internet to control lights.
Follow the previous two links to root the hub. Next, do the OpenHAB integration using the configuration below.
.
.
You can get fancy with the scenes and control both the bulbs that are on and the individual brightness.
Once the lights are integrated with OpenHAB, they can be used in conjunction with Arduino wireless motion sensors or door sensors to do automation. Or maybe use the lights to indicate that the laundry is complete. The Hub can be completely blocked off from the internet (and Wink servers) with your router’s access restrictions.
If you’re looking for a quick way to control the lights without having to pull out a smart phone or open up a browser, an Arduino or Pi with a IR sensor can be used to receive lighting control from a TV remote. The same shell commands can be activated via MQTT. There’s not very many options in the market for hand-held or wall mounted automation remotes.
Voice Control, Star Trek Style, without any button press.
Voice control is also possible with OpenHAB. Normally, this requires pressing a button prior to giving the voice command, but it’s also possible to do voice control without any prior button presses. An Android phone/tablet with Tasker and the Autovoice plugin can be used to run HTTP post commands directly to the OpenHAB items. Autovoice allows full time voice recognition, so you don’t have to press any buttons to initiate the command. And newer version of Android have the option of downloading the language to the device, so you can keep things local, no internet required. This would be a nice setup for a wall-mounted interface.
1. Create two tasks, lights-on and lights-off. Each task sends a HTTP GET command like this:
Server:Port
openhabuser:openhabpassword@192.168.x.x:8080Path:
CMDAttributes:
itm_lights_livingroom=OFF
or
itm_scene_livingroom=2
2. Create two profiles. Event > Plugin > AutoVoice > Recognized. Edit the configuration with filter word (“on” or “off”), and go down to Trigger word. I used the trigger word “computer” so I feel like Captain Picard. The trigger word is important because I’m running Autovoice recognition continuously. It’s the equivalent of “Simon saids”. This prevents you from accidentally turn off lights while in conversation.
As commentary, I’m pretty uncomfortable with Wink amassing a database of wifi passwords and locations where they can be used. When you setup the hub, you need to enter your wifi password. And the Wink app gets your phone’s GPS signal (it’s one of the permissions) to do geofencing. OpenHAB can do most of these types of automation tasks, but gives you more control over sensitive data.
The downside to this method is that it’s unidirectional. I can control the lights, but I can’t get the status of the bulbs. Or of other z-wave or zigbee devices connected via the hub. If anyone knows of a way to catch call backs from devices, or install a daemon on the hub itself to perhaps parse aprontest commands and send results via MQTT to the Raspberry Pi, that would be cool.
I hope some company will use open source firmware for their home automation hub, and spawn the first WRT54G of home automation hubs.
Configuration:
Item Definition
Switch itm_lights_livingroom "Living Room Lights" Number itm_scene_livingroom "Scene" Number itm_lights_lvl_livingroom "Level [%.1f]" Switch itm_livingroom_night_light_enb "Auto Night Night" Switch itm_livingroom_motion_enb "Motion Control"
Sitemap Definition
Frame label="Lights" { Text label="Living Room Lights" icon="light-on" { Frame label="Living Room Lights" { Switch item=itm_lights_livingroom label="Living Room Lights" mappings=[OFF="Off"] Selection item=itm_scene_livingroom label="Bulb Pattern" mappings=[1=Bright, 2=General, 3=Evening, 4=Dim] Switch item=itm_scene_livingroom label="Bulb Pattern" mappings=[1=Bright, 2=General, 3=Evening, 4=Dim] Selection item=itm_lights_lvl_livingroom label="Brightness" mappings=[1="1%", 10="10%", 30="30%", 60="60%", 80="80%", 100="100%"] Switch item=itm_livingroom_night_light_enb Switch item=itm_livingroom_motion_enb } }//end text label livingroom lights }//end frame label lights
Rules Definition
/* living room lighting */ rule "Living Room Lights Off" when Item itm_lights_livingroom received update then executeCommandLine("/opt/myscripts/LivingRmOff.sh"); say("Lights Off") end rule "Living Room Lights Pattern" when Item itm_scene_livingroom received update then if(itm_scene_livingroom.state == 1) { executeCommandLine("/opt/myscripts/LivingRmPattern_1_bright.sh"); say("Bright") } if(itm_scene_livingroom.state == 2) { executeCommandLine("/opt/myscripts/LivingRmPattern_2_general.sh"); say("General") } if(itm_scene_livingroom.state == 3) { executeCommandLine("/opt/myscripts/LivingRmPattern_3_evening.sh"); say("Evening") } if(itm_scene_livingroom.state == 4) { executeCommandLine("/opt/myscripts/LivingRmPattern_4_dim.sh"); say("Dim") } end rule "Living Room Lights Dimming" when Item itm_lights_lvl_livingroom received update then if(itm_lights_lvl_livingroom.state == 1) { executeCommandLine("/opt/myscripts/LivingRmDim_1.sh"); say("One Percent") } if(itm_lights_lvl_livingroom.state == 10) { executeCommandLine("/opt/myscripts/LivingRmDim_10.sh"); say("Ten Percent") } if(itm_lights_lvl_livingroom.state == 30) { executeCommandLine("/opt/myscripts/LivingRmDim_30.sh"); say("Thirty Percent") } if(itm_lights_lvl_livingroom.state == 60) { executeCommandLine("/opt/myscripts/LivingRmDim_60.sh"); say("Sixty Percent") } if(itm_lights_lvl_livingroom.state == 80) { executeCommandLine("/opt/myscripts/LivingRmDim_80.sh"); say("Eighty Percent") } if(itm_lights_lvl_livingroom.state == 100) { executeCommandLine("/opt/myscripts/LivingRmDim_100.sh"); say("One Hundred Percent") } end rule "Living Room Auto Night Light" when Time cron "0 0 23 * * ?" // Every day 23:00 hours, evaluate sunset then if (itm_livingroom_night_light_enb.state == ON) { executeCommandLine("/opt/myscripts/LivingRmPattern_4_dim.sh"); say("Turn On Night Lights") } end
Shell scripts. Change the devices to match your bulb’s designations and Wink Hub IP address.
LivingRmDim_1.sh
curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m1 -t2 -v 1;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m2 -t2 -v 1;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m3 -t2 -v 1;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m4 -t2 -v 1;"
LivingRmDim_10.sh
curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m1 -t2 -v 25;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m2 -t2 -v 25;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m3 -t2 -v 25;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m4 -t2 -v 25;"
LivingRmDim_100.sh
curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m1 -t2 -v 252;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m2 -t2 -v 252;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m3 -t2 -v 252;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m4 -t2 -v 252;"
LivingRmOff.sh
curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m1 -t1 -v OFF;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m2 -t1 -v OFF;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m3 -t1 -v OFF;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m4 -t1 -v OFF;"
LivingRmPattern_3_evening.sh
curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m1 -t1 -v OFF;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m2 -t1 -v OFF;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m3 -t1 -v ON;" curl "http://192.168.2.32/set_dev_value.php" -d "nodeId=a&attrId=aprontest -u -m4 -t1 -v ON;"
Nice work, Eric! Note that if you only want to control the GE bulbs, there is a much simpler solution: Using the Philips Hue bridge for it! That’s how I did https://www.youtube.com/watch?v=qb3FYB37l0I&index=8&list=PLGlxCdrGUagz6lfgo9SlNLhdwI4la_VSv.
Hey Kai. Yes, I saw your Hue integration. I got the Wink hub when I bought the GE bulbs. Recently, retailers have been practically throwing the hubs at people, so it’s a cheap option compared to the Hue hub. I also have z-wave wall switches that I will integrate with this.
Eclipse Smart Home seems to be coming together very nicely. Thanks for all your work on OpenHAB!
I bought a wink hub and then paired it with my Amazon Echo to make it voice activated. I found some good set up instructions at http://www.winkeasy.com/voice-activation/
This could be done without root (cloud still required though) using the Wink API.
[…] cloud’ for some strange reason. There is no middle ground. At least there wasn’t until [Eric] started poking around and looked at a few hardware […]
I’m hoping to do the same with my rooted Wink hub… Currently I’m not able to get it to see or talk to either of my GE Link bulbs… You are using the api? Did you have to add them to the hub first?
Look at the GE bulb documentation. You power cycle the bulb a few times to put it into pair mode, then tell the hub to look for it via app. During this time, let the hub have access to the API server, obviously. Aprontest also allows a way to add bulbs w/o Wink server, but I haven’t tried it.
Once the bulb has been added, you can block the hub’s access to the internet entirely. And no, I am not using the API to control the bulbs. The API calls go the the Wink server, and the whole point of all this is to not need the Wink server for everyday control.
I take it this currently only works with the Hue Bulbs? Meaning the other radios aren’t actually controllable. Or am I mistaken? Either way very cool, i’ll be following your progress with this.
Did you mean zigbee GE Link lights, not Hue? It also works with my zigbee wall switches too. Same method for turning it on/off. I suspect all the radios are controllable the same way, but can’t confirm as all I have are zigbee and z-wave devices.
With this setup are you able to control a Philips Hue directly with a rooted Wink hub ? Do you still need the Philips Hue hub ?
I have no idea, I don’t have any Phillips Hue bulbs.
I noticed that the lights come on one by one rather than simultaneously when activating all of them. Is that by design or is that the lag typical of the Wink bridge?
I’ve seen other demos of the Wink with similar (or much worse) delay in all lights in a group coming on and was wondering if that lag would be eliminated by local control rather than commands coming down from the cloud.
With local control, there’s really no delay. The lights come on one at a time because I’m addressing them one at a time. You can put them in a group, and tell the group to turn on and it all goes on at once, very fast. Same with group brightness level commands.
However, if you to have all 4 bulbs at different brightness levels, it’ll have to do it one at a time with a 1/2 second delay in between like you see.
I have 17 color devices and 28 ge link lights on my Hue Hub. I got tired of fighting with a crappy wink hub and losing connection to the GE bulbs. I have 17 z-wave devices on it now only. now I have an internet have it and I can’t control it. not only that ever since the point 77 update the Wink hub has been very unstable continuously offline a lot I have to reset it all the time
ROFL, I have a wemo switch programmed to restart my wink hub every morning so I can at least control my lights in the morning. I was getting tired of the inconsistency. Thought it was their cloud but seems right after the reboot it runs flawless, maybe its going to sleep.. PITA
Eric,
I was wondering/hoping you could maybe share your voice rules? I seem to be struggling in how to get voice control working on the rooted wink hub, and how your various ‘say’ commands work in your main rules file.
Do have a separate voice rules file and String VoiceCommand in your items file?
Oh, I think I forgot to explain how the OFF and ON translate to OpenHAB? That’s being done the “itm_lights_livingroom=OFF” line. It’s really OpenHAB interpreting the voice to text. You’re sending OpenHAB the “OFF” command, which is mapped to an openhab item to “click” the off button.
So, I’m using the same off button you see on the interface. When the voice command comes in, the off button is “clicked”, just as if you tapped the off button for real. And OpenHAB rule monitors for a “update”, which is what’s activated when the off button is clicked either via voice or via smart phone interface.
I have a question, with the app that you’re using, is it possible to control non-smart device? For instance, open a port, read variables, and set values to Digital I/Os on the Raspi itself?
If so, then I theoretically should be able to tap into my security reed switch sensors to arm alarm? Is that a capable function? How expandable is the app itself?
I’m running PHP, MySQL, and Javascript + Jquery now on a raspi, but it would probably work better through an actual app. But I really don’t feel like developing a whole app again and having to keep updating it.
Also thanks for the IFTTT idea and how to use it with voice control! That’s a great idea!
Definitely. Easily done with OpenHAB. Or an Arduino on ethernet plus OpenHAB running on a Pi. OpenHAB does have binding to the GPIO pins on the Pi, so you can turn those pins on/off, or use the pins as sensor inputs.
See OpenHAB wiki for GPIO binding.
Hi, nice project! But…For instance, if you have a bulb switched off via openHAB and you decide to switch it on manually (via the phisical switch) will not work, right?
Well, if the bulb is switched on manually via switch, it means you went through a off-on cycle, and the bulb will be on 100% brightness. But it’s still powered, so you can still turn it off/dimm via the app. That works fine. It’s only when you turn off the bulb via the wall switch by cutting off power that you can no longer turn the bulb on remotely.
I’ve been able to use the $15 Lutron pico remotes control the lights by polling the wink hub. They can be mounted on wall switches. It works pretty good, but the setup is clunky because it requires some kind of lutron “target” to bind the remote to. I’m going to post my progress with that soon.
Can you post a guide on how you got the pico remotes working?
I have gotten a few of these remotes with exactly that intention
Hello… Just want to tell you what a great job you did on this, as well as your OpenHAB->Arduino project that I am working on as well. I have one of the new Wink Hubs that came patched – no exploit. So the NAND glitch was the only way to gain access, which worked ok of course. So I added a remote outlet and a GE link bulb and no problems controlling them via a homemade aprontest.php file I made (as the updated versions of the hub have absolutely nothing in /var/www except index.php) . This pipes back the result of the command just as you had entered it on the command prompt. So, since you have interest in finding the status of your connected devices, it seems easy to me to parse the results of aprontest -l, and iterate through this list to get the status of each. I wasnt sure what the best way to go about it – do it client side with OpenHAB, or server side with Winkhub and a script that could create a JSON object that could be cached and stored like I am doing with my 3M Filtrete Radiothermostat (http binding over wifi) – like so:
https://community.openhab.org/t/how-to-return-current-temp-from-my-thermostat/3141/4
-Has anyone seen any code to iterate this aprontest output to get it to OpenHab?
-Can someone post the old .php files (set_dev_value.php, as well as the ones for adding devices, etc. Maybe those work locally?) If not, these seem easy to duplicate to me – if I get time I’ll write new ones to add devices via the web page locally.
Sorry, I’m better with .net and linux and php…the JSON side seems to be the best way to go about it to me but i’m not very skilled there and am new with OpenHAB. I see many people going about it with the cloud and API and to me this is highly unnecessary for complete local control.
Hope someone has some insight how to parse output of aprontest and I can be on my way. I’d be happy to post my setup