For example, with the Colorific bulb you need BlueZ setup so we can use the hcitool to do the scan. I opted to just do a scan for devices in range so you don't have to mess with pairing. It seems to work even if you are not discoverable. The second part will be to add WiFi scanning in case your Bluetooth is off or vice versa (WiFi is off but Bluetooth is on). Unlike the DomotiGA version which is called from a device setting this will run in a loop and use cURL to put to the HTTP rest API in openHAB.
First we need to create a few items to track the status of each person and an overall one in case we want to write a rule based on if anyone is home. Here is my items config.
all.items
//Proxmitiy
String occupiedState "Someone home" (gNetwork)
String device_WillPhone "William Phone" (gNetwork)
String device_JennPhone "Jenn Phone" (gNetwork)
Since I am using a group for all proximity items the sitemap is really simple. This also reduces the number of lines used on the sitemap main page.
default.sitemap
Frame label="Home?" {
Group item=gNetwork
}
Finally, the shell script that makes the magic happen. This version is just the Bluetooth scanning but it is setup to add WiFi as well. I wrote it so that you can easily add more devices by adding another entry to the array. It will check each device in the array without having to change the main loop. Follow the repo on github to get the updated version when I add WiFi support like the DomotiGA version. https://github.com/FriedCircuits/Home_Automation/blob/master/openHAB/Proximity/device_scan.sh
I hope this helps you easily get proximity working. Comment below if you found it helpful and/or your variation. It's nice to see people base their setup on something you created. It's open source at its best - the community working together.
Thnx for sharing, will try this in the near future :)
ReplyDeleteThnx for sharing, will try this in the near future :)
ReplyDeleteI am so glad I found your blog. It is clear, concise, and very helpful. Thanks for putting this together.
ReplyDelete