Page 1 of 1

nice way to work with home presence detection

Posted: Monday 11 December 2017 21:58
by Eugene
hi guys,

I am quite new to domoticz - so far i was using it for a year only for heating control and for couple of switches. All devices i have were triggered or configured only via default domoticz GUI config (like set temperature on time, switch on/off socket on time, etc).

recently got couple of PIR sensors and started playing with lua scripts to switch on/off lights based on detected motion.

Now I am thinking about making presence detection at home to shutdown lights and heating if no motion detected for 12 hours for example. I clearly see how i can make it with lua scripts however I can't imagine how lua scripts can co-exist with time based actions in domoticz GUI.

Do I understand right that all time based settings in GUI i should replace with settings applied from lua scripts? or is there a way where both (GUI and scripts) can co-exist without making the setup extremely complicated to manage?

thanks

Re: nice way to work with home presence detection

Posted: Tuesday 12 December 2017 11:27
by ronnyandre
They can coexist, however this will be messy and there will be multiple places you have to edit your events. I would definitely keep to the Events system (LUA/dzVents) rather than timers.

Re: nice way to work with home presence detection

Posted: Tuesday 12 December 2017 16:20
by Egregius
That's quite easy in pass2php.
I also do that:
If all the lastupdate timestamps of the pirs are more than 4 hours ago the house goes into sleep mode.
If they're all more than 12 hours ago the house goes into away mode.

In pass2php it's easy to see all the current statusses and their timestamp. Just loop thru a array and it's done:

Code: Select all

<?php
if(past('pirliving')>14395&&past('pirgarage')>14395&&past('pirinkom')>14395&&past('pirhall')>14395&&past('Weg')>14395&&$Weg==0){apcu_store('Weg',1);telegram('Slapen ingeschakeld na 4 uur geen beweging',false,2);}
if(past('pirliving')>43190&&past('pirgarage')>43190&&past('pirinkom')>43190&&past('pirhall')>43190&&past('Weg')>43190&&$Weg==1){apcu_store('Weg',2);telegram('Weg ingeschakeld na 12 uur geen beweging',false,2);}
My script also detects when the last 'home' status is set (Weg), that timestamp gets updated whenever I push one of the buttons of a minimote that I use to control my media. So, the house only goes into sleep mode if no movement is detected and I didn't do anything on my media for 4 hours.

Re: nice way to work with home presence detection

Posted: Tuesday 12 December 2017 18:53
by Eugene
Thanks, Gentlemen for your thoughts.

ronnyandre, thanks for confirming that approach i have in mind will be the less messy one (not to mix timers and scripts, go scripts only)

Egregius, i have similar logic in mind but with PIR sensors and hopefully i will deliver it with LUA scripts (i am not big fan of PHP :) )

Thanks
Eugene