Anybody home?

Post Reply
rrozema
Posts: 124
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi
Domoticz version: beta
Location: Delft
Contact:

Anybody home?

Post by rrozema » Monday 04 June 2018 15:02

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
}

pvm
Posts: 961
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: Stable
Location: NL
Contact:

Re: Anybody home?

Post by pvm » Monday 20 August 2018 17:25

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
Synology NAS, PI3, ZWave, Xiamo zigbee devices, BTLE plant sensor

poudenes
Posts: 592
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Anybody home?

Post by poudenes » Tuesday 21 August 2018 15:38

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
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

User avatar
EdwinK
Posts: 1379
Joined: Sunday 22 January 2017 22:46
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Anybody home?

Post by EdwinK » 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***
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | RFxcom | Dashticz V2

MiloshCZ
Posts: 26
Joined: Monday 23 January 2017 18:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Anybody home?

Post by MiloshCZ » Wednesday 22 August 2018 8:19

I am using EgiGeoZone for geofencing.

SweetPants
Posts: 2349
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V4.10196
Location: The Netherlands
Contact:

Re: Anybody home?

Post by SweetPants » Wednesday 22 August 2018 9:51

MiloshCZ wrote:
Wednesday 22 August 2018 8:19
I am using EgiGeoZone for geofencing.
Also not maintained anymore see: https://www.egigeozone.de/
Ubuntu 16.04.5 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (from source)

danielsan
Posts: 2
Joined: Friday 24 August 2018 10:13
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Anybody home?

Post by danielsan » Sunday 26 August 2018 10:56

For Android "Geofence for Domoticz". https://play.google.com/store/apps/deta ... ence&hl=it

User avatar
EdwinK
Posts: 1379
Joined: Sunday 22 January 2017 22:46
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Anybody home?

Post by EdwinK » Sunday 26 August 2018 19:54

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.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | RFxcom | Dashticz V2

rrozema
Posts: 124
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi
Domoticz version: beta
Location: Delft
Contact:

Re: Anybody home?

Post by rrozema » Thursday 13 September 2018 17:12

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest