This is a script that watches the apron database on your rooted winkhub, and updates openHAB when stuff changes. This way if you trigger a light outside of openHAB, such as through the Wink app or with a Lutron remote, your status in openHAB stays correct.
The initial version of this call would do n database calls, one for each device... which would tend to lock the sqlite database. Now it only makes 2 calls - one for -all- zwaves, one for -all- zigbees. I ported this script to PHP from Bash - I needed associate arrays to accomplish that.
- Keep device status updated when changed
- Cache status to avoid unnecassary PUTs to your openHAB box
- ...except you can force an update every x intervals to ensure everything stays in sync.
- If you call it with the commandline param 'now' it will do one forced update - you can have OpenHAB do this on boot.
In theory any zigbee/zwave device should work.. I've only personally tested it with GE Link bulbs and a schlage lock though.
cp openhab_monitor.ini.sample openhab_monitor.ini
- Adjust settings like intervals/timing
- Add your devices
If you have your wink hub set up with ssh keys and named winkhub
, you can just run the install script after you've configured it.
- Copy openhab_monitor.ini to
/etc
- Copy openhab_monitor.php to
/bin
- Copy S81openhab_monitor to
/etc/init.d
- Make sure all of those ^^ are executable (
chmod +x ...
)
If not, just copy the three files over manually.
/etc/init.d/S81openhab_monitor start
will start the monitor... next reboot it should start automatically.
To force a one-time update from your openHAB, do something like:
rule "Get current status updated on boot"
when System started
then
executeCommandLine('ssh winkhub "/usr/bin/php /bin/openhab_monitor.php now"');
end
- Author: JustinAiken
- Database polling idea: This comment by Reddit user izzy_monster.
- Init script idea: This comment posted by Reddit user wpskier.