Setting variable when contact sensor opens - not working


#1

1) Give a description of the problem
I have a dogfood reminder piston. Motion sensor in the kitchen triggers a voice alert to Sonos to feed the dog unless the dogfood cupboard has been opened. The problem is that it often fires to say feed the dog when the cupboard has already been opened. I have tried to figure out why the dogfood cupboard sensor is so unreliable. I replaced the battery in the contact sensor recently with a brand new one hoping that would fix it. But no luck. I created a piston to just set the variable when the contact is open and it is unreliable.

2) What is the expected behaviour?
It should set the variable when the cupboard door is opened.

3) What is happening/not happening?
It does not fire reliably when the cupboard door is opened.

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

5) Attach logs after turning logging level to Full

7/15/2019, 11:12:05 AM +148ms
+0ms ╔Received event [Home].test = 1563214325146 with a delay of 1ms
+126ms ║RunTime Analysis CS > 22ms > PS > 82ms > PE > 22ms > CE
+128ms ║Runtime (37579 bytes) successfully initialized in 82ms (v0.3.108.20180906) (126ms)
+129ms ║╔Execution stage started
+144ms ║║Condition #2 evaluated false (7ms)
+145ms ║║Condition group #1 evaluated false (state did not change) (10ms)
+150ms ║╚Execution stage complete. (20ms)
+151ms ╚Event processed successfully (151ms)
7/15/2019, 11:08:35 AM +171ms
+1ms ╔Received event [Home].test = 1563214115168 with a delay of 3ms
+150ms ║RunTime Analysis CS > 25ms > PS > 105ms > PE > 19ms > CE
+153ms ║Runtime (37581 bytes) successfully initialized in 105ms (v0.3.108.20180906) (149ms)
+154ms ║╔Execution stage started
+169ms ║║Condition #2 evaluated false (7ms)
+170ms ║║Condition group #1 evaluated false (state did not change) (10ms)
+175ms ║╚Execution stage complete. (22ms)
+176ms ╚Event processed successfully (176ms)


#2


From the MASTER. Just a suggestion…


#3

Thanks for the suggestion. My piston is setting the variable (string) using concat so I don’t think it is a typing issue. The variable is still set to Sunday even though the contact sensor was opened several times yesterday (Mon) and today (Tues).


#4

Instead of hitting Test, do you get it to set properly when the contact is opened?


#5

Set your variable Locally (in the piston) not Globally. Local Variables save instantly while Global variable only update after the piston has done its thing.


#6

@tw1st3d7550 is right about globals, but in this case, it is ok to store the data into a global variable.

I agree with @eibyer. For the log to be helpful to us, Contact Sensor 1 should actually be opened.
(the Test button does nothing in this piston)