Yes! This method should work for any beacons not just Tiles. Works for my two Tile keyrings.
I was getting ready to write this up properly but hopefully it makes sense for now
I took this python script, and I run it on a CHIP computer: https://getchip.com/pages/chip
Pi3 is good too, anything with Python and Bluetooth really:
Uncomment this line, and change the log to somewhere HA can access.
#logOutFilename='/var/log/test_beacon.log'
Also make these changes:
FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
becomes
FORMAT = '%(asctime)s - %(message)s'
Saves messy logs.
Log entries are like this:
2017-01-20 16:20:53,748 - Tag f1:c8:e1:b4:7c:9f is back after 7 sec. (Max 48). RSSI -88.
2017-01-20 16:20:55,049 - Tag f1:c8:e1:b4:7c:9f is back after 1 sec. (Max 48). RSSI -92.
2017-01-20 16:20:57,429 - Tag d1:f2:6a:3c:6a:9a is back after 3 sec. (Max 48). RSSI -80.
2017-01-20 16:20:58,739 - Tag d1:f2:6a:3c:6a:9a is back after 1 sec. (Max 48). RSSI -84.
The RSSI can be used as a (very) approximate range finder, but I’m not using that here.
In my binary_sensors.yaml I have the following (via ssh):
- platform: command_line
command: if ssh chip@[CHIP IP] "timeout -s SIGINT 5s tail -f /var/log/test_beacon.log" | grep 'f1:c8:e1:b4:7c:9f' > /dev/null; then echo 1; else echo 0; fi
name: Bit_Rivers_Keys_tile
payload_on: 1
payload_off: 0
sensor_class: occupancy
And repeat for however many beacons you want to track.
Adjust the 5s part, aka 5 seconds, to however long you think you need to prevent false absences.
In a sensors.yaml, if you want to flesh out the payload:
- platform: template
sensors:
bit_rivers_keys_status:
value_template: '{% if is_state("binary_sensor.bit_rivers_Keys_tile", "on") %}Home{% else %}Away{% endif %}'
If you’re running HAdashboard
<li data-row="2" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="bit_rivers_keys_tile" data-view="Habinary" data-title="Bit_Rivers' Keys" data-iconon="check-square" data-icon-off="ban"></div>
</li>
Here’s some aliases I made for the chip to help me test it, and as the starting point of other sensors:
alias ble=‘cat test_beacon.log | grep Detected | sort -u’
alias blec=‘cat test_beacon.log | grep Detected | cut -c38-55’
alias devices=‘echo && echo -n "Number of Unique Devices Detected: " && blec | sort -u | uniq -u | wc -l && echo’
alias listen=‘echo; tail -f test_beacon.log’
Of course, as an easy ‘away’ test just put the tile in a metal box / wrap in tin-foil
Hope I haven’t forgotten anything,