Logic issues with location mode piston



I’ve written a piston that sets the mode for my hub based off of the presence sensors installed on my iPhone as well as my wifes. We’ve got the webcore presence sensor as well as the default SmartThings presence sensor. Currently the script will run several times when my wife and I return home together (in the same car), I’m also getting some odd behavior when my wife is home and I come home. The script will sometimes run, sometimes not. Usually it will take a while after I’ve made it in the house before it will trigger.

What I’m hoping to do is set the mode based off of our presence, that should be pretty obvious by the code. I’m hoping that when both of us return home the script will only run once, I’m also hoping that if one of us returns home (the other already home) and the front door is locked, unlock the door, but do nothing with the lights. I’ve turned on logging and once I return home from work (my wife is home today) I will post the results of the log.


The multiple runs may be a timing issue given your ‘Only when’ will always be true. Since you cannot be in two modes, either ‘not home’ or ‘not night’ will always be true. I think you meant ‘and’?


I could see how the difference speaking in daily English vs how the logic would interpret could be different. Thank you for pointing that out. I’ve made the change. I’ll see if that helps.