what exactly does everyone expect the notification to do once we do find a way to catch it? ( personally id love to have it send an http bind to OpenHab so rules can be built. Forget using WInk Hub as anything but a wifi enabled radio relay. there is a terrific post where someone combines openhab with wink hub.
So bad news and GREAT news...
Bad news... from what I'm reading, while sqlite does indeed have triggers... all the triggers can do is update the database, not actually do anything outside the database such as running a script.
GREAT news... I have a working proof of concept that you can easily write a monitoring script that runs outside the database.
rootwink.com.monitor.sh
Code: Select all
#!/bin/bash
tail -fn0 /tmp/messages | \
while read line ; do
echo "$line" | grep -q "0x7ce5240000065ded:1; Cluster 0x0006; Attribute ID: 0x0000; State 0"
if [ $? = 0 ]
then
echo "Hey... the light turned off!"
fi
echo "$line" | grep -q "0x7ce5240000065ded:1; Cluster 0x0006; Attribute ID: 0x0000; State 1"
if [ $? = 0 ]
then
echo "Hey... the light turned on!"
fi
done
And it works!!!
Script output when I turn the bulb on, off, and back on either via the iPhone app and/or the command line:
Code: Select all
Hey... the light turned on!
Hey... the light turned off!
Hey... the light turned on!
Command I'm running to turn the light on/off manually
Code: Select all
[root@flex-dvt ~]# aprontest -u -r zigbee -m 1 -t 1 -v ON
Update device with master ID 1, setting value ON for attribute 1
[root@flex-dvt ~]# aprontest -u -r zigbee -m 1 -t 1 -v OFF
Update device with master ID 1, setting value OFF for attribute 1
And with a case statement...
[root@flex-dvt database]# cat /tmp/rootwink.com.monitor.sh
Code: Select all
#!/bin/bash
tail -fn0 /tmp/messages | grep aprond | \
while read line
do
crop=`echo $line | grep aprond | sed 's/^.*): //g'`
#echo $crop
case $crop in
"NetAddr: 0x9924; Source: 0x7ce5240000065ded:1; Cluster 0x0006; Attribute ID: 0x0000; State 1")
echo "0x7ce5240000065ded:1 was turned ON!"
;;
"NetAddr: 0x9924; Source: 0x7ce5240000065ded:1; Cluster 0x0008; Attribute ID: 0x0000; State 255")
echo "0x7ce5240000065ded:1 was set to full brightness"
;;
"NetAddr: 0x9924; Source: 0x7ce5240000065ded:1; Cluster 0x0006; Attribute ID: 0x0000; State 1")
echo "0x7ce5240000065ded:1 was turned ON!"
;;
"NetAddr: 0x9924; Source: 0x7ce5240000065ded:1; Cluster 0x0006; Attribute ID: 0x0000; State 0")
echo "0x7ce5240000065ded:1 was turned OFF!"
;;
"GOT ZB_ASYNC_MSG_SENT_SUCCESS_MSG from 0x7ce5240000065ded:1 with status 0")
echo "0x7ce5240000065ded:1 Confirmed receipt of my request"
;;
"Sending ZCL ON/OFF to 0x7ce5240000065ded:01")
echo "0x7ce5240000065ded:1 was told to toggle on/off"
;;
*)
echo "CROP=\"$crop\"" | grep 7ce52400
;;
esac
done
Results in...
Code: Select all
0x7ce5240000065ded:1 was set to full brightness
0x7ce5240000065ded:1 was told to toggle on/off
0x7ce5240000065ded:1 Confirmed receipt of my request
0x7ce5240000065ded:1 was turned OFF!
CROP="NetAddr: 0x9924; Source: 0x7ce5240000065ded:1; Cluster 0x0008; Attribute ID: 0x0000; State 0"
0x7ce5240000065ded:1 was set to full brightness
0x7ce5240000065ded:1 was told to toggle on/off
0x7ce5240000065ded:1 Confirmed receipt of my request
CROP="NetAddr: 0x9924; Source: 0x7ce5240000065ded:1; Cluster 0x0008; Attribute ID: 0x0000; State 0"
0x7ce5240000065ded:1 was turned ON!
Though do not trust my conversion of what the status lines mean... I'll verify them later.
the /tmp/messages file appears to some times take a bit to update... I wonder if it doesn't update the file until the commands have made it through the cloud api or not... TBD