Page 1 of 1

Ignoring\Dealing with On On

Posted: Thursday 20 July 2017 12:22
by jimtrout87
Hello,

Can anyone help, i have some lights come one automatically when one of us gets home. Which works fine, the problem i have is that when i put my phone on charge at night it kicks back in location settings and then re-triggers my geogfence, therefore turning on lights. They do go off after a few mins, its just a bit annoying.

Because its multiple people i cant use add a variable for my phone as that would stop it working for others on occasion, I did wonder about lastupdate+1 or something but not sure if there is a syntax for this?

Code: Select all

if (otherdevices['Sunset'] == 'On' and otherdevices['Hallway Lights'] == 'Off' and (devicechanged['Jims Home'] == 'On' or devicechanged['Kaths Home'] == 'On')) then
	print("Coming Home, Setting Hallway lights to 85%")
--	commandArray['Porch Light']='On'
	commandArray['Hallway Lights']='Set Level 85'
	commandArray['Variable:Hallway_Lights'] = '2'
elseif (uservariables["Hallway_Lights"] == 2 and timedifference(otherdevices_lastupdate['Jims Home']) > 180 and timedifference(otherdevices_lastupdate['Kaths Home']) > 180  and otherdevices['Hallway Lights'] ~= 'Off') then
	commandArray['Variable:Hallway_Lights'] = '1'

end

return commandArray

Re: Ignoring\Dealing with On On

Posted: Monday 24 July 2017 22:59
by Ittiz
Hmm hard to see a good way to fix it with the code you posted. I would think it would need to be done in the code that figures out your home. If it was able to see that your last location is home for instance it ignores it if it says you're home again.

I had a similar problem with a door lock that occasionally would send extra notifications to the controller like and extra "door unlocked" right after it said the door was unlocked a few seconds earlier. How I got around this is when it got the door locked or unlocked message it would check out how long ago the device last changed and if it was less than 60 seconds before it would check the old status against the new one. If the two statuses were the same it would throw away the second status message. The reason why I only did this is it was less then 60 seconds is because some times the lock's status could change and the message never got back to the controller for some reason. So that would appear as two ons or two offs in a row, but usually minutes to hours apart. Different device I know but hopefully that gives you some ideas for you own code.

Re: Ignoring\Dealing with On On

Posted: Monday 24 July 2017 23:33
by pvm
I was thinking of a similar solution. Probably the geofence sets a virtual switch?
You can add an extra (hidden?) virtual switch which is controlled by your geofencing and use blockly to check current state of "Jim's Home" and when status has changed change the actual "Jim's home" switch, when extra virtual switch is identical to "Jim's home" then do nothing.

Re: Ignoring\Dealing with On On

Posted: Tuesday 25 July 2017 1:39
by sion
Don't know if it helps;
I use a " some one is home" switch. This is the switch that triggers the arriving home scene. And also the leaving home scene - so last one out.

So
if me= on and someonehome = off.
Set some one home on.

If wife = on and some one home = on.
Set someonehome = on.

If me= off and wife= off
Set someonehome = off.

This would help the double on, as someone home would already be on.

Re: Ignoring\Dealing with On On

Posted: Tuesday 25 July 2017 7:34
by markjgabb
this is very similar to mine
occupied event.PNG
occupied event.PNG (33.43 KiB) Viewed 1483 times

Re: Ignoring\Dealing with On On

Posted: Friday 28 July 2017 12:35
by jimtrout87
Thanks all for your assitance and pvm i think thats the solution, yes my curreny dummy is linked to geofence.

As for the other replies i do already have a someone home in place but i dont use it as i want the lights to come on at night when either us come home. The other person may already be home in bed or the back room so someone home is already on. I will make this smarter though and put a if someone home == off like you suggest though as that makes sense :)

Re: Ignoring\Dealing with On On

Posted: Thursday 03 August 2017 14:02
by jimtrout87
Quick Update on this. All working now using a seperate "Jims Home - Hidden" which is updated by "Jims Home"

One thing to note is that you cant seem to reference a hidden switch for Geofence. If its hidden you cannot select it and if you select it and then hide it it doesnt work. I kept it as "Jims Home" and changed the lua to look at the hidden switch.

Re: Ignoring\Dealing with On On

Posted: Monday 07 August 2017 9:52
by zicht
just another approach on this.

I have tasker installed on the phones, and on wifi connection home detected it sets a user var for the device (together with geofence) via http get in domoticz. As long as the var is set no change by scipts allowed the the master home/away switch.
That way your double safe as 2 conditions have to be met (--> had issues with GpS being turned off by battery saving on phone and geofences not being switched.)

Later i extended this a bit using also car bluetooth near to detect if in the car (using same vars) --> so we now know when the phone "on the road " avoiding messaging while driving but knowing they are actually on the way home :) so dinner can be cooked.