I’m on vacation now, and in pimatic i have a vacation switch so when we are not home the lights won’t turn on when its getting dark.
I can use ping to check all our phones at home, but the problem is that every one here has a iphone, so pinging is only possible when some1 is using their phone.
I thought something like this:
if no phone was available between 07:00 and sunset then switch to vacation mode. But i have no idea how i could check if no phone was available between a certain time.
Solved, thanks to @georg90:
Install pimatic-ping.
add all your phones to the config:
{
"id": "my-phone",
"name": "my smartphone",
"class": "PingPresence",
"host": "192.168.1.4",
"interval": 10000
}
Create a variable called $home
Add this rule to change $home to false if everybody is gone:
IF my-phone is absent for 15 minutes and $home is "true" THEN set $home to "false"
To set $home to true if someone is home:
IF [your-phone is present] and $home is not "true" THEN set $home to "true"
Now you can use $home in other rules to do something when someone is home or not. like:
IF $home = "true" and its 18:00 THEN turn lights on
If your using an iphone you have to wake it because the wifi of the iphone goes to sleep when its inactive.
First install hping: sudo apt-get install hping3
Then add this rule to wake the iphones every 5 minutes:
IF every 5 minutes THEN execute "sudo hping3 -2 -c 3 -p 5353 192.168.1.4 >/dev/null 2>&1 || true"
Change the ip to your phone’s ip address. Make sure you have added you phone to the ip address reservation list on your router.