Page 1 of 1

Anybody home?

Posted: Monday 04 June 2018 15:02
by rrozema
Once you've got presence detection working (or almost, as both the mac/ip address and gps/ifttt methods are still not very reliable) you'll want to have domoticz make decisions based on whether someone is at home or not. If you live alone, this is easy: you just check the one presence switch. If however multiple people live in your house, you'll need some easy way to see if anyone is at home or everyone is away. What I did is add 2 more dummy On/Off switches, one called 'Iemand thuis' (someone at home) and another called 'Niemand thuis' (noone at home). This script sets the both buttons according to all people's away settings. If I change my presence detection method(s), I don't need to change anything else. If I add another presence button I simply add it in the list in the top of the script and I just as easily remove one or more from there without having to go through any other scripts to find other references. All decisions in other scripts look at the state of the 'Iemand thuis' or the 'Niemand thuis' switches.

Code: Select all

local PRESENCE_DEVICES = {
        'Presence Jane',
        'Presence Tarzan',
        'Presence Poemba',
        'Presence Timo'
    }

local IEMAND_THUIS = 'Iemand thuis'
local NIEMAND_THUIS = 'Niemand thuis'

return {
	on = {
		devices = PRESENCE_DEVICES
	},
	execute = function(domoticz, device)
		local iemand_thuis = domoticz.devices().filter( PRESENCE_DEVICES )
		    .reduce( 
		        function (acc, device) 
		            if device.state == 'On' then
		                acc = true
		            end
		            return acc
		        end, false)

		 local sw_home = domoticz.devices(IEMAND_THUIS)
		 local sw_away = domoticz.devices(NIEMAND_THUIS)
		 
		 if iemand_thuis == true then
		     if sw_home.state ~= 'On' then
		         sw_home.switchOn()
		     end
		     if sw_away.state ~= 'Off' then
		         sw_away.switchOff()
		     end
		 else
		     if sw_home.state ~= 'Off' then
		         sw_home.switchOff()
		     end
		     if sw_away.state ~= 'On' then
		         sw_away.switchOn()
		     end
		 end
	end
}

Re: Anybody home?

Posted: Monday 20 August 2018 17:25
by pvm
You've made a nice implementation in dzVents (configurable list of people).

Just another idea how I do this: I do this in Blockly with only one virtual switch 'Anybody home?' (on/off, true/false)
Rule 1: AND for every single person IS NOT present resulting in 'Anybody home' being FALSE
Rule 2: OR for every single person IS present resulting in 'Anybody home' being TRUE

Re: Anybody home?

Posted: Tuesday 21 August 2018 15:38
by poudenes
I did almost the same but went little bit further. I use locative app. When a phone is going within a range (gps) then it sends a https request to turn on a device. When the phone is going out the range another https request is sending to domoticz to turn off the device. My situation we have 2 phones (myself and my friend). All dzvents script relying on those dummy switches and work great for months. Locative is a free app.


Verzonden vanaf mijn iPhone met Tapatalk Pro

Re: Anybody home?

Posted: Tuesday 21 August 2018 17:01
by EdwinK
Too bad Locative is not in active development anymore, and the site has gone.
From the Google Play store:
*** Locative is not under active development anymore***

Re: Anybody home?

Posted: Wednesday 22 August 2018 8:19
by MiloshCZ
I am using EgiGeoZone for geofencing.

Re: Anybody home?

Posted: Wednesday 22 August 2018 9:51
by SweetPants
MiloshCZ wrote: Wednesday 22 August 2018 8:19 I am using EgiGeoZone for geofencing.
Also not maintained anymore see: https://www.egigeozone.de/

Re: Anybody home?

Posted: Sunday 26 August 2018 10:56
by danielsan
For Android "Geofence for Domoticz". https://play.google.com/store/apps/deta ... ence&hl=it

Re: Anybody home?

Posted: Sunday 26 August 2018 19:54
by EdwinK
I've been using this one before, but was not really impressed. It often said I was at home when I was on the other side of the country.

Re: Anybody home?

Posted: Thursday 13 September 2018 17:12
by rrozema
I have to agree that none of the methods to detect whether or not you're home seem to work very well. They all have their flaws. So much even that I think I can't reliably control any devices with it. The point of the script I posted here was however to be able to control any devices in Domoticz independent of the method used to detect the presence of the inhabitants. That part was succesfull.

I hope to sometime find/build a system that is able to detect in which room any inhabitant is. So far however I would be happy to find one method that is able to reliably detect that we're home.

Re: Anybody home?

Posted: Friday 06 August 2021 14:14
by jurgend
EdwinK wrote: Tuesday 21 August 2018 17:01 Too bad Locative is not in active development anymore, and the site has gone.
From the Google Play store:
*** Locative is not under active development anymore***
I use the Locative app on iOs, and as of today it still works

Anybody home?

Posted: Saturday 07 August 2021 8:42
by Treve
Locative is still supported in iOS. Last changes one week ago.
Image

Re: Anybody home?

Posted: Monday 09 August 2021 21:14
by Denny64
My experience. For presence detection i use a combination of Wi-Fi and Beacon Ble without any problem, but recently i've see Domoticz geofence function on Android App works like a charme . I'm testing it from several monts and i have not had a false positive (or negative). I'm very impressed for the stability because in the beginning this was not so.

Re: Anybody home?

Posted: Sunday 05 September 2021 16:34
by rrozema
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.