yashsingh1/xdaforums huggingface dataset:
[Off-topic] electronichamsters:
[MENTION=1037693]Descention[/MENTION], that's awesome work. I don't follow how you figured that out, but it's impressive. So once you're ssh-ed into the Wink hub, you just type in

insert into zwavedevicestate (nodeid, endpoint,attributeid) select 2, 0, attributeid from zwaveattribute;

What does that do? I probably just don't understand how the database works. Any pointers on where you figured this out would be appreciated. Thanks!
[Off-topic] comp3v:
how to upload local files to wink?

(sorry for dumb question!) I successfully rooted my wink and now would like to install nashira's Blink, for this I need to copy Blink's directory to the hub - and I can't figure out how to do this :( I use Bitvise SSH client, and when I press "New SFTP window" button, it shows instantly "Opening new SFTP session." and "Closing SFTP session." in the log.

I would be grateful for any help
[Off-topic] Descention:
aprontest searches the database for attributes assigned to a node. The zwave nodes use the zwavedevicestate table to store the values capture by the zwave devices. If a particular device is capable of reporting the Wattage but doesn't have the attribute added to the zwavedevicestate table, it doesn't save that data and aprond effectively ignores it. Once you add a valid attribute to that table, aprond will save any updates from the zwave device to the correct row.

---------- Post added 21st January 2015 at 12:01 AM ---------- Previous post was 20th January 2015 at 11:57 PM ----------

Use SCP instead of SFTP. WinSCP works well for this but any SCP client should do.
[Off-topic] comp3v:
Descention, thanks a lot! it really helped!
[Off-topic] electronichamsters:
Has anyone been able to put devices in groups? Or how to add devices via "aprontest -a"?

Both commands seem to require specifying a radio type with the "-r [radio]". I have no idea what the valid radio names are. I tried "-r zigbee" and "-r ZIGBEE", but no good.

If someone could give me the exact syntax they used, either to add devices or to add devices to a group?
[Off-topic] smb_gaiden:
Cool product and great thread!

I've run into a jam and wondering if anyone here has advice which can help to overcome.

Background:

1. Rooted wink hub, behind VPN ssh is enabled for root w/ PW and no keys used at all.

2. Have UART access wired in

Problem 1:

How can I set up a static IP for this product on the wink itself? Unfamiliar with linux, but noticing using the curl command with the ssid and pass will request for DHCP assigned address. Would prefer to do the static IP on the wink, so I don't need to keep applying MAC based IP assignment as I go through various router upgrade cycles.

Problem 2:

On the dynamic host address, I am able to SSH in and see a very clean prompt environment. I guess STDERR is pointed only to UART.

On the UART I am seeing this cycle:

IpcServerRead: Detected disconnect

IpcServerAcceptLoop: accept() success!

IpcServerAcceptLoop: Ipc Server running in event-loop mode

-----Ipc Server Received message-----

seqNum: 0

msgType: C

Processing ZB_NETWORK_STATUS_CMD

-----Ipc Server Received message-----

seqNum: 1

msgType: C

Processing ZB_FIND_UNUSED_NETWORK_CMD

zbUtil_FindUnusedNetwork: network form success!

set state to: 0x0B04

security init TC: 0x70

Forming on ch 11, panId 0x05F8

Form error 0x70 aborting

Scan error 0x70

Network find complete (scan error).

Anyone have tips to get rid of these errors, so my UART console can be as clean as the SSH console?
[Off-topic] jimmcghee:
aprontest usage

Just type "aprontest" with no parameters and it will display its usage.

Examples:

show a list of devices

aprontest -l

Add a zigbee lightbulb:

aprontest -a -r zigbee (then turn the light on. It will blink a few times to show it's being added)

turn on/off

aprontest -u -m 1 -t 1 -v ON/OFF

Add a group

aprontest -s "Diningroom Light"

Add a device (m2) to a group (x1)

aprontest -a -x 1 -m 2

Turn group (x1) on/off (to last used brightness)

aprontest -u -x 1 -t 1 -v ON/OFF

Set group (x1) to full brightness

aprontest -u -x 1 -t 2 -v 255

Hope this helps. :D
[Off-topic] jimmcghee:
Adding a rooted hub to the Wink App

I've rooted my hub with:

http://www.dinnovative.com/?p=348

and upgraded (to .56, I think?) with post #220 from:

http://slickdeals.net/f/7446662-wink...0#post72622240

and everything is working GREAT! Except...

I rooted and upgraded without ever allowing it to connect to the internet (as per instructions) so I never added the hub to the android app.

I have now commented the entry in the /etc/hosts file that blocks access to hub-api.winkapp.com but the app can't find the hub when I try to add it.

It appears to be looking for the hub's accesspoint (WINKHUB...) and ip 192.168,0,1 and, of course, can't find them so it can't add it.

I see others talking about using their hub with the android/ios app after rooting it. How are they doing that?

--Help-- :confused::confused:
[Off-topic] wpskier:
I ran into the same issue where I couldn't get my hub connected to the app after rooting it (still haven't tried to tackle it again). But, If you want to get the hub to put up it's WINKHUB.... access point, just rename your /database/wpa_supplicant.conf file. From my experience, that should cause the hub to start broadcasting the SSID and the app should be able to find it. Hopefully that helps.
[Off-topic] jimmcghee:
It WORKS.

It worked!! Thanks! :D

BTW, there used to be a Thanks button. Where'd it go?

It took me several tries to get it to work. The first time, I didn't enter my network password in the Wink app because I thought it remembered it the same way it remembered my ssid. NOT.

It created a new /database/wpa_supplicant.conf file with 'key_mgmt=NONE' and no psk= line. The problem was, when it asked me to retry, I entered the password but the hub didn't change the wpa_supplicant.conf file so it didn't work no matter how many times I retried.

I finally noticed this and deleted the file and rebooted.

This time I entered my pw and it worked. Just mentioning this for future generations.

Another odd thing. I had used aprontest to add two lights and put them in a group. This worked fine with aprontest but the Wink app didn't like the bulbs so it created two new ones. The new ones didn't show up on 'aprontest -l'. I deleted them all and added them back with the Wink app and everything works fine now.

Both aprontest and the Wink app. The Wink app had no problem with the group but now I have a phantom group that doesn't show up on the Wink app but shows as group "2 | 275" in aprontest. Weird.

Anywho, thanks again for the help, Now to get it working with my Vera hub again.

Jim
[Off-topic] OuTTaRiCe:
Enable CRON for scheduled automation

The following steps will enable crond to allow scheduled automation of your devices directly from the wink hub.

1.) Set your timezone. The Wink HUB defaults to UTC, you may want to set this to your local timezone.

Edit /etc/profile and add the following to the file. This example sets Eastern timezone with auto adjust DST.

TZ='EST5EDT'
export TZ

2.) Create the startup script to startup crond on boot up.

This start script will mkdir the cron directory, copy a custom crontab file from the /database and start /usr/sbin/crond.

create file /etc/init.d/S62cron

#!/bin/sh

case "${1}" in
start)
echo -n "Starting crond..."
mkdir -p /var/spool/cron/crontabs
cp /database/crontab.root /var/spool/cron/crontabs/root
/usr/sbin/crond
;;

stop)
echo -n "Stopping crond..."
killall crond
;;

restart)
${0} stop
sleep 1
${0} start
;;

*)
echo "Usage: $0 [start|stop|restart]"
;;
esac

Make sure to set permission of the file.

chmod 755 /etc/init.d/S62cron

3.) Sample /database/crontab.root file.

This example will turn my light on 100% at 6pm, Dim the light at 11pm (as a nightlight), Turns off light at 5am.

00 18 * * * /usr/sbin/aprontest -m1 -t2 -u -v255;/usr/sbin/aprontest -m1 -t1 -u -vON
00 23 * * * /usr/sbin/aprontest -m1 -t2 -u -v1
00 05 * * * /usr/sbin/aprontest -m1 -t1 -u -vOFF

4.) Start the crond and you are good to go.

/etc/init.d/S62cron start
[Off-topic] comp3v:
Ecolink Z-Wave PIR Motion Detector (PIRZWAVE2-ECO)

Anyone tried to use Ecolink sensor with Wink hub? This sensor worked OK with my Staples Connect hub, but not with Wink. It is not listed as available product to add in Wink app, so I added it through aprontest - then it appeared as a sensor in the App, but it's not working correctly.
[Off-topic] Descention:
Not all devices or device attributes are supported yet. The wink hub's database doesn't recognize all attributes. There are also some unknowns in the aprond and the way it handles additions to the database. For instance, I've tried adding a 'Meter' attribute but it has yet to work. I've also had zero luck with my Aeon Labs mutlisensor.
[Off-topic] electronichamsters:
That's pretty cool. Have you tried making a script that uses aprontest to monitor the status of something? I'd like to have a script run every ~3 seconds that looks at the aprontest response on something like "aprontest -m4 -l", and then parse the output to see if it changed relative to the last time it was run. But I have no idea how to start something like that. I read someone else had done it though.

Ultimately, I'd like to use a script like this to change statuses on a OpenHAB installation, another home automation platform. But the first step I'm missing is the script to parse aprontest outputs.

Thanks for any ideas.
[Off-topic] doomsey:
So I have scripts to do most of this set up. A few tidbits:

* Z-wave is way more reliable than ZigBee when doing polling.

* In order to poll you have to have >=0.47 and use the new "-e" parameter to aprontest.

* You can use "cut" and "grep" to pull apart the aprontest output.

For example, I use the following script to read the on/off status of a ZigBee light. The first condition detects if the light is responding. If no response, it's probably off at the switch. If it responds, we read the value from the database and use that to update the switch in OpenHAB.

#! /bin/bash
PATH=$PATH:~/bin

if ! wink -e -m $1 | grep "Status 0" > /dev/null ; then
echo "OFF"
exit 8
fi

if wink -l -m $1 | cut -c 95-102 | grep " ON " > /dev/null ; then
echo "ON"
exit 0
fi

echo "OFF"
exit 1

Wink is a quick script that uses curl to access the wink using "exploit.php" generated by the SQL injection attack. The timeout addresses a frequent failure case where the Wink just never responds.

#! /bin/bash
timeout -k5s 10 curl -s "$URL_OF_WINK/exploit.php" -d cmd="aprontest $*"

Once you have the values you can use curl to update the state in openhab:

curl -s --header "Content-Type: text/plain" --request PUT --data "$DATA" "$URL_OF_OPENHAB/rest/items/$ITEM/state"

This should help you get started. I have a lot more but I'm kind of too lazy to package it all conveniently :)
[Off-topic] Descention:
No, the query is done in 'sqlite3 /database/apron.db'. If you're not familiar with SQL, you may not want to attempt this route.
[Off-topic] electronichamsters:
[MENTION=6361239]doomsey[/MENTION], that's really cool, and pretty much what I was looking for. Thanks a lot. I was able to get a script going for a tripper door sensor:

if aprontest -m1 -l | grep "48" > /dev/null; then
echo "Its closed"
exit 0
fi
echo "Its Opened"

I haven't figured out how to run the script every ~3 seconds. And how do you create a memory (variable?) to save the value so that it only write to OpenHAB when there's a change in value, so you minimize the number of calls to OpenHAB.

Thanks for any additional info. Don't know how XDA uses the thank meter, but I don't seem to have that option available.
[Off-topic] doomsey:
Well, the easy/stupid way is just to run your update procedure in a loop. You don't really need to minimize calls into OpenHAB, though I did actually do that until I realized you don't have to. You can use an HTML frame to fix up the stupid bug in the web interface that scrolls back to the top on the update.

while true ; do
UPDATE-SCRIPT
sleep 3
done

The right way to do it is to incorporate the polling into your item declaration in openhab, and calling your update script at the right interval using an exec item. There's some examples of how this works in the OpenHAB docs.

You can read the current state and compare it against the new state before writing thusly if you really want to do it:

#! /bin/bash
prev=`curl -s $OPENHAB_URL/rest/items/$1/state`
if [ "$prev" != "$2" ] ; then
curl -s --header "Content-Type: text/plain" --request PUT --data "$2" "$OPENHAB_URL/rest/items/$1/state"
fi

---------- Post added at 09:22 PM ---------- Previous post was at 09:06 PM ----------

By the way, if you're running all this on the wink you can start up your polling script when the Wink boots by editing /etc/init.d/S99local and putting an invocation of the polling script in.

#! /bin/bash
bash /root/wink-update &
[Off-topic] Descention:
I'd like to add on the aprontest -e usage. If your device is running on batteries, polling too often to wake the device may significantly decrease battery life.
[Off-topic] onesmartguy:
Has anyone seen any info on how to root the wink relay?
[Off-topic] doomsey:
This is possible and polling is certainly unnecessary in the case of a battery powered sensor, but actually the most likely outcome is the device being polled simply won't respond with minimal impact on the battery life. Note that the example for the tripper upthread clearly shows the correct use of the battery-powered Tripper without a -e poll.

source: I used to do this for a living ;)
[Off-topic] hoobajoob:
These instructions worked great for me. Thanks!:good:
[Off-topic] impressiver:
do not bootdelay without UART

Awesome, thanks for letting me know [MENTION=882811]hoobajoob[/MENTION]

One thing I forgot to mention in my last post was that any bootdelay, eg.:

fw_setenv bootdelay 1

prevents both my hubs from booting without an FTDI cable about 95% of the time, even a bootdelay of 1. Occasionally the luck of the electron gods is on my side and the hub boots without it, but so rarely that it bests my laziness (repeatedly pressing reset, hoping I won't have to fetch my laptop and connect the cable and tty). Once booted, I can disconnect and be on my merry way. But I wouldn't want to be far from an FTDI cable, for fear of all things that cause reboots.

Sounds like a good reason to learn how I might add some resistors to prevent the pins from floating. If anyone has suggestions, please share. I'm from the software world, still leveling up on hardware. Hardware is hard.
[Off-topic] wpskier:
I have a really annoying issue where my hubs (both rooted and non-rooted) will disconnect from my WiFi network and start flashing a yellow light. They never seem to reconnect, so I have to power-cycle them to get reconnected. Anyone else having this issue?

It's bad enough for me to consider stop using Wink because it becomes worthless when the hub is not connected to WiFi.
[Off-topic] Maynard100:
Nice
[Off-topic] OuTTaRiCe:
I would take a look at your wifi AP/router or the placement of your wink hub as the problem may be there.

It is recommended not to place the hub too close to your AP/router.

I haven't heard anyone complain about lost connections. Normally if it is an issue, you'll hear about it.

I have 3 of them, 1 on each floor and have not had any issues with lost connections.

I generally find the radios on this hub to be very good. The zwave is definitely better than my vera. I can control my second floor ZigBee bulb with my hub located in the basement.
[Off-topic] Descention:
On the note of placing too close to router, if my hub starts up while sitting beside my router, it won't connect. I moved it to another room and it works just fine. That threw me for a loop for a while.
[Off-topic] rainierez:
check status and level

I made a bash script that returns the status information in JSON for an "HA Dimmable Light"

#! /bin/bash
PATH=$PATH:~/bin

if aprontest -l -m $1 | awk '/Level/' | cut -c 100 | grep " " > /dev/null ;
then
LEVEL=$(aprontest -l -m $1 | awk '/Level/' | cut -c 101)
elif aprontest -l -m $1 | awk '/Level/' | cut -c 99 | grep " " > /dev/null ;
then
LEVEL=$(aprontest -l -m $1 | awk '/Level/' | cut -c 100-101)
else
LEVEL=$(aprontest -l -m $1 | awk '/Level/' | cut -c 99-101)
fi

if aprontest -l -m $1 | awk '/On_Off/' | cut -c 95-102 | grep " ON " > /dev/null ;
then
STATUS="ON"
else
STATUS="OFF"
fi

echo "{"
echo " \"Level\": \"$LEVEL\","
echo " \"Status\": \"$STATUS\""
echo "}"

you can run that locally (after making it exicutable chmod u+x devicestatus.sh ) and it outputs like this:

[root@flex-dvt ~]# ./devicestatus.sh 2
{
"Level": "255",
"Status": "OFF"
}
[Off-topic] rainierez:
Here is another Bash script that loops through multiple devices and reports Light status in JSON (but could easily be expanded to include other things). It may not be super fast and I bet there is faster ways to do all that but it works for me now.

#! /bin/bash
PATH=$PATH:~/bin

FOUNDSOME=0
for (( DEVICEID=1; DEVICEID<=$1; DEVICEID++ ))
do
if ! aprontest -l -m$DEVICEID | awk '/HA Dimmable Light/' | cut -c5-21 | grep 'HA Dimmable Light' > /dev/null ;
then
echo " },"
echo " \"$DEVICEID\":{"
echo " \"Error\":\"Not a HA Dimmable Light\""
else
if [ $DEVICEID -eq 1 ];
then
echo "{"
else
echo " },"
fi

if aprontest -l -m $DEVICEID | awk '/Level/' | cut -c 100 | grep " " > /dev/null ;
then
LEVEL=$(aprontest -l -m $DEVICEID | awk '/Level/' | cut -c 101)
elif aprontest -l -m $DEVICEID | awk '/Level/' | cut -c 99 | grep " " > /dev/null ;
then
LEVEL=$(aprontest -l -m $DEVICEID | awk '/Level/' | cut -c 100-101)
else
LEVEL=$(aprontest -l -m $DEVICEID | awk '/Level/' | cut -c 99-101)
fi

if aprontest -l -m $DEVICEID | awk '/On_Off/' | cut -c 95-102 | grep " ON " > /dev/null ;
then
STATUS="ON"
else
STATUS="OFF"
fi

echo " \"$DEVICEID\":{"
echo " \"Status\": \"$STATUS\","
echo " \"Level\": \"$LEVEL\""

fi
done

echo " }"
echo "}"

Result

[root@flex-dvt ~]# ./statusall.sh 10
{
"1":{
"Status": "OFF",
"Level": "255"
},
"2":{
"Status": "ON",
"Level": "3"
},
"3":{
"Status": "OFF",
"Level": "255"
},
"4":{
"Status": "OFF",
"Level": "156"
},
"5":{
"Status": "OFF",
"Level": "255"
},
"6":{
"Status": "OFF",
"Level": "255"
},
"7":{
"Status": "ON",
"Level": "255"
},
"8":{
"Error":"Not a HA Dimmable Light"
},
"9":{
"Error":"Not a HA Dimmable Light"
},
"10":{
"Error":"Not a HA Dimmable Light"
}
}
[Off-topic] rainierez:
Local Rest API

I was able to change the bash scripts I created and using the slim framework that is already on the wink hub i created a RESTful API that can be accessed locally. Granted there is no security and it only covers HA dimmable lights right now but it's a start. I put it all on github check it out. https://github.com/rainierez/Winkhub-Local-REST-api

Examples

To get the status of one device

$ curl -i -H "Accept: application/json" http://<IP of Wink Hub>/api.php/1

Returns

{"1":{"Status": "ON","Level": "255"}}

Turning the light off

$ curl -i -H "Accept: application/json" http://192.168.0.1/index.php -d '{"deviceid":"1","status":"0"}'

Returns

{"State":"Update device with master ID 1, setting value OFF for attribute 1"}
[Off-topic] hahack:
Suggestions for nouns?

Just had a look at this, it's pretty good work, thanks for sharing it!

If you don't mind a suggestion for improvement..? RESTful API's by convention use plural nouns for endpoints and act on them with the http verbs. So one might GET /devices/ for a list of all devices, and PUT /devices/21/ to update the value on a specific device. I find the following guide helpful..

/users/ when called with GET, lists users

/users/ when called with POST, creates user record

/users/123 when called with GET, shows user record

/users/123 when called with PUT, updates user record

/users/123 when called with DELETE, deletes user record

It doesn't really change the functionality you're exposing, but makes it more intuitive to understand. Putting all your devices under /devices/ might make it more intuitive to add authentication later, by giving you the easy option to have /users/ and /sessions/.

In any case, it's a great thing to have available as it makes it possible to hook the hub into other applications with very little effort. Kudos for putting the work in!
[Off-topic] rainierez:
Awesome notes. I really was learning as I went so conventions/best practices were not on my radar just yet. I'll look at making changes around this sort of thing.
[Off-topic] hahack:
Annoyingly, I ordered off Amazon and they sent me one which someone had already opened and updated. They're shipping me a replacement.
[Off-topic] themadlighter:
almost hacked?

So I messed around with the hacking during upgrade per instructions I found here and I got it upgraded while re-activating some of the original backdoors. For some reason I cannot get ssh access back now though. I can run almost any command like this:

curl "hxxp://192.168.0.1/set_dev_value.php" -d "nodeId=a&attrId=;<commandhere>"

But dropbear never seems to start up. Any pointers as to what I might try? Even commands like ls and echo work letting me modify files, etc.

Thanks!
[Off-topic] hahack:
So, I've been working on RESTful API's in the meantime as well, and from what I understand, you can ignore my suggestion about '/sessions/' as this would make the API stateful. The best way would be to use an API key;

GET 192.168.0.7/devices/17?apikey=jr8934jf9023jf9wjfiosejrf9032jfoiw4jf3290fj3290fjewf9032jf3902fj3902fm3490

Which could be stored in a config.php file? Though TLS would be needed to make this worthwhile. Does the hub software support it? (Noting again the issue I've had with the hub I bought...) I was also thinking last night about other nouns that would be appropriate... /devices, /groups (i.e. 'Living Room'), /rules (i.e. on a schedule or if-this-then-that?), /activities (i.e. 'Disco mode'). Though, I was wondering - would it be best to keep processing on the hub to a minimum? So, only use /devices/ and say.. /config/ - and expect users to run their own servers elsewhere with rules and activities, which call your API to get or set status of individual devices?
[Off-topic] bdjohns1:
Try creating a file called /database/ENABLE_SSH - I think the scripts now look to see that that file exists before trying to launch dropbear (at least via the init.d scripts).
[Off-topic] rainierez:
I made updates to the API to use plural nouns and then also add support for "On/Off Output" devices.

https://github.com/rainierez/Winkhub-Local-REST-api

Usage

Method |	Path | Parameters | Outputs

GET | /devices/ | <deviceid> | status and level

GET | /devices/all | <optional max range> | Loops from 1 to max range (defaults to 25 if nothing passed) and returns status and level for each device

POST | /devices/ | <deviceid>, <status> | returns confirmation of change

POST | /devices/ | <deviceid>, <level> | returns confirmation of change

POST | /devices/ | <deviceid>, <status>, <level> | returns confirmation of change. For status 1 = ON and 0 = OFF. For level 10 = dimmest and 255 = brightest

Examples

To get the status of one device:

$ curl -i -H "Accept: application/json" http://<IP of Wink Hub>/api.php/devices/1

Returns:

{"1":{"Status": "ON","Level": "255"}}
[Off-topic] hahack:
Hmmm.

So Amazon have now sent me two used (and updated) hubs instead of the new one I ordered.

Has anyone sniffed the wireless traffic when sending an 'update' command from the iPhone app? I'm guessing it posts a value to the Wink servers, which the hub then polls for the command? It would be nice if I could somehow force one of these devices into booting from the updater partition. (I don't have an iOS7+ or Android device, either)

I haven't a Home Depot nearby, so for now I just have two attractive desk ornaments.
[Off-topic] hahack:
USB?

So, I've taken a look at the board today, to get a better view than the teardown photos do.

Connector J8 is interesting - the footprint appears to exactly match that of Molex part 1051330001 - a vertical mounted micro-USB connector. This is also logical enough for an ARM processor. Most μUSB sockets wouldn't fit, but this one appears to. They're about a dollar each. Anyone tried to attach one, or found a reference to a USB client interface in the firmware?