Set Locations mode to Away based on presence sensors


#1

1) Give a description of the problem
Looking for help to design a piston that set the location mode to away when all of the presence sensors change to not present, I am using phones as presence sensors and it seem to be accurate when they go they leave as I have a piston which notifies me when any of the phones become not present.

2) What is the expected behaviour?
People leave the house with thier phones, they do become not present and then the Location mode should be changed from home to away

3) What is happening/not happening?
The phones become not present but away mode is never set

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full

+1ms â•”Received event [Dereks Phone].presence = not present with a delay of 55ms
+32ms â•‘RunTime Analysis CS > 16ms > PS > 5ms > PE > 11ms > CE
+34ms â•‘Runtime (38821 bytes) successfully initialized in 5ms (v0.3.110.20191009) (32ms)
+35ms â•‘â•”Execution stage started
+48ms â•‘â•‘Comparison (enum) not present changes_to (string) not present = true (0ms)
+49ms â•‘â•‘Condition #45 evaluated false (10ms)
+50ms â•‘â•‘Condition group #1 evaluated false (state did not change) (11ms)
+53ms â•‘â•‘Condition group #5 evaluated true (state did not change) (0ms)
+55ms â•‘â•‘Condition group #16 evaluated true (state did not change) (0ms)
+58ms â•‘â•‘Condition group #24 evaluated true (state did not change) (0ms)
+60ms â•‘â•‘Condition group #40 evaluated true (state did not change) (0ms)
+62ms â•‘â•šExecution stage complete. (27ms)
+63ms â•šEvent processed successfully (63ms)
14/06/2020, 12:48:34 +958ms
+1ms ╔Received event [Laura’s IPhone].presence = not present with a delay of 40ms
+34ms â•‘RunTime Analysis CS > 17ms > PS > 5ms > PE > 11ms > CE
+36ms â•‘Runtime (38819 bytes) successfully initialized in 5ms (v0.3.110.20191009) (35ms)
+37ms â•‘â•”Execution stage started
+50ms â•‘â•‘Condition #45 evaluated false (9ms)
+51ms â•‘â•‘Condition group #1 evaluated false (state did not change) (10ms)
+54ms â•‘â•‘Condition group #5 evaluated true (state did not change) (1ms)
+57ms â•‘â•‘Condition group #16 evaluated true (state did not change) (0ms)
+60ms â•‘â•‘Condition group #24 evaluated true (state did not change) (0ms)
+62ms â•‘â•‘Condition group #40 evaluated true (state did not change) (0ms)
+64ms â•‘â•šExecution stage complete. (27ms)
+65ms â•šEvent processed successfully (65ms)

Above Piston does however work if I remove one of the devices from the device variable group, for instance it can have my wifes Iphone or my Samsung just on its own and it works, it only seems not to work when there is more than 1 phone in the group.

I am also using the webcore presence app on the iphone and my Samsung.


#2

Also to note the IF statement is if ALL OF as I only want Away mode to be set if all of the presence sensors change to away!


#3

Just a quick look, you need to remove all of your empty IF statements at the bottom of your piston.


#4

Hi Pantheon,

I will give this a try, I started off with a more complex piston but it also was not working so went back to basics with above piston, the left over if statements are from the more com,plex piston, See below:

The first piston I posted does work when there is only 1 devcie within the PresenceSenors device variable group so assume it has soemthing to do with me trying to more than 1 device as a trigger, quiite new to this so just looking for some guidance on what is and what is not possible.


#5

Also note that your presence sensors may not change state all at the same time. And if your trigger is set to ALL instead of ANY, you’re piston will not fire unless all of the present sensors change at the same time.


#6

To note the code seems to work in the second piston as I always get the notifications when people leave or arrive but the location mode is never changed to away when all sensors become not present which is strange.


#7

I’m on my phone right now and I cannot dig into the bigger piston at this time. I will look at it in a little bit when I get to my computer.


#8

Also not sure if this is a bug or not but when I try to remove the extra if statement I do not get a delete option to do this, just clear clipboard, see screenshot

The big piston is having the same issue as the small piston as again when I go down to one device in the PresenceSensors group the location mode is changed, really not sure why!


#9

I am wondering if I should move away from triggers for this piston and chance to conditions?


#10

I got it working, Thanks for help Pantheon, I changed from triggers to conditions and it seems to work now.

Also I managed to remove the extra IF statement although these were not what was causing the issue.

You need to left click to highlight the full IF statement to want to remove and then right click to get the delete option, soemthing very simply but very new to this and could not see it straight away!


#11

For anyone else who may be interested I got the larger piston working which sends notifcations when home or away is set using this piston along with sending a notification witht the devices that go away\home, have shared it below!


#12

Glad you got things working. If I may make some comments…

  1. A condition is treated as a trigger if a trigger is not present. Please see this excellent comparison by @bangali : CONDITIONS AND TRIGGERS.
  2. Usually, it is desirable to have a single trigger for a piston with conditions below it to direct flow. Your big piston has 6 triggers (the orange lightning bolts in the left margin). Others may differ, but I prefer small, task specific pistons with a single trigger to make sure that the piston is doing exactly what I want. And it makes for easier debugging with the smaller pistons. So, for me, I would divide this piston into at least 2. One for arrival/present and one for departure/not present. Your situation and mileage may vary. :slight_smile:
  3. Note that in your big piston that your first two IF statements are not triggers and will not execute unless the piston is triggered by any of the 6 triggers. You may want things this way. But, depending on how you wrote the code, your mode may not change at all unless Presence Sensor 3 and Presence Sensor 1 both change at the same time. Just food for thought.

Webcore%20Green%20Check%20II


#13

Re-thinking this…your mode may change as you desire with the way your triggers are coded.