Eigentlich wollte ich die Anwesenheitserkennung meines Smart Mirrors über einen Bluetooth Ping regeln, was sich aber leider aufgrund von Problemen mit dem Bluetooth Stack bluez als nicht machbar herausgestellt hat. Ich habe hier darüber geschreiben.
Actually I wanted to control the presence detection of my Smart Mirror via a Bluetooth ping, but unfortunately this turned out to be impossiblasse due to problems with the Bluetooth stack bluez. I wrote about it here.
The nice thing about l2ping would have been the very simple implementation and you wouldn’t have had to rely on the smartphone as a partner device. Also devices like wearables could have been integrated.
Geofence
With apps like Geofency (iPhone) or EgiGeoZone (Android) you can draw a virtual fence around your home and trigger events when entering and leaving it.
I have set up my Geofency app so that when my smartphone enters the property, it calls up a URL with parameters on my Smart Mirror and sets a flag there that stands for my presence.
In order for the Smart Mirror to react not only to my presence but also to that of my girlfriend, the HDMI port is only off when both of us are not present.
The Smart Mirror runs a web server with a .php script that receives and processes the commands of our Geofence apps. The commands are divided into the affiliation of “Silvan” and “Sabine” as well as “Is present – 1” and “Is absent – 0”.
The two values are stored in two text files which are then accessed by a code snippet, which evaluates the content and switches off the HDMI port as soon as both values are set to “Is absent – 0”.
Geofency works with POST and EgiGeoZone with GET. Therefore I have to evaluate both variants.
In the code snippet there are also log and diagnostic functions commented out, which help you with the setup and show you e.g. the ID with which the iPhone reports.
Please note that the logfiles on Apache have the appropriate access rights and belong to the group www-data.
geofence.php
onoff.sh
The script “onoff.sh” is called either with the parameters “1” (on) and “0” (off) and controls the HDMI port.
#!/bin/bash if [ $1 == "0" ] then vcgencmd display_power 0 else vcgencmd display_power 1 fi