Google Assistant has a feature 'Presence detection', plus another feature called Routines, which we can combine to let Domoticz know when everybody has left home and when the first person arrives again. This is the first presence method that I have found to work reliably enough for me to actually use it for more than a few weeks.
How it works:
Google uses the occupants phone's locations to see when a phone leaves the area the house is in. Whenever a phone leaves the area, it reports so to Google Assistant, then when the last phone left the area, Google Assistant runs a routine called "Away". In my case I have the "Away" routine switch a dummy switch called "Iemand thuis" Off in Domoticz via Controlicz. Later, whenever the first phone returns in the home area, this phone reports so to Google Assistant, which in turn runs the 'Home" routine", which I have set up to switch the dummy switch "Iemand thuis" On again.
Next I have setup a dzvents script to respond to the changes of the "Iemand thuis" switch. Below are the things I'd like to happen. For the moment I only have the heating switched automatically, but this is the list of things I plan on doing:
When switched Off (everybody left):
[*] if the heating is not set to Economy, set it to Economy.
[*] if there are any lights left on inside the house (i.e. not the outside lights), switch them off.
[*] if there are any windows left open, close them.
[*] if the vacuum cleaner didn't yet do it's round today, start the vacuum cleaner.
[*] If the alarm is not armed, ARM it.
When switched On (someone enters):
[*] if the heating is not set to Normal, set it to Normal.
You may notice that I plAn on arming the alarm automatically, but I don't plan disarming it automatically. This is for security reasons: In the event my home automation does get hacked somehow, I don't want the hacker to be able to easily disarm my alarm. This is also why I don't have any electronic locks: It sounds great -to me too- to be able to just unlock the door by walking to it, but I think the locks only purpose is to make it hard to get into my home, so I'm not going to make it easier for a burglar to get in by adding more possible attack vectors.
What you need:
-
Controlicz. If you've got any Google Home device, you really should have this anyway, because it's awesome to be able to use your voice to control your house: you'll never want to pick up your phone anymore to control anything. A requirement for Controlicz is to have a valid certificate for your Domoticz setup, instructions can be found in the forum.
- the Google Home app in every household member's phone.
- define your home in the Google Home app,
- in the Home app specify the home address so Google can find the area your home is at.
- in the Home app go to 'presence detection' and enable the 'Allow this home to use phone locations' toggle. At the same time in your own phone also enable the phone to send its location.
- every person in your household needs to be in your Google Assistant Family. If you're using google assitant devices to control your home and/or have one or more chromecast devices, you've likely already set all your family members up, so that shouldn't be a problem. If you haven't yet, you can do so using the Google Home app: add all your family members to the list of "People in this house"
- every person's phone must report in when leaving or entering the home, so in each phone, you need to go in the home app, go to 'Presence detection' and in the list of phones, find this phone and enable it. The list showns all phones for the occupants, plus whether or not they have location access enabled or not. Every member should have it on, or they may end up sitting in the dark and cold, with the alarm armed when everyone else leaves from home...
- In Domoticz set up this dummy switch 'Iemand thuis' (which translates as 'Anybody home'). It's a simple on-off switch, nothing fancy.
- Make sure the 'Iemand thuis' switch is in a room in Domoticz, or it won't be seen by Controlicz. You don't have to assign it to a room in the Home app.
- Now write a script in Domoticz to do whatever you want done when the 'Iemand thuis' switch turns On or Off. You can use your favorite scripting method like blocky, phyton or LUA, but I prefer dzvents over any of them.