Always on light bulb - even after I turn it off. Tried setting task cancellation policy with no effect [Resolved]


#1

1) Give a description of the problem
Turn off the light bulb and it comes right back on

2) What is the expected behavior?
The thing to stay off

3) What is happening/not happening?
Goes off then comes right back on. Piston is behaving like an event handler.

**4) Post a Green Snapshot of the piston

5) Attach any logs (From ST IDE and by turning logging level to Full)

d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:51 AM: info β•” Piston successfully stopped (167ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:51 AM: info β•š Stopping piston...
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: info β•” Event processed successfully (108ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: trace β•‘β•” Execution stage complete. (21ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Condition group #30 evaluated false (state changed) (11ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Cancelling condition #30's schedules...
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Condition #31 evaluated false (9ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Cancelling condition #31's schedules...
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Comparison (enum) on is (string) off = false (1ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: trace β•‘β•š Execution stage started
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: trace β•‘ Runtime (48703 bytes) successfully initialized in 19ms (v0.3.10a.20190223) (82ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘ RunTime Analysis CS > 18ms > PS > 19ms > PE > 45ms > CE
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: info β•š Received event [Notification Light].switch = on with a delay of 524ms
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: info β•” Event processed successfully (122ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: trace β•‘β•‘ Executed [Notification Light].on (10ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: trace β•‘β•” Execution stage complete. (39ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Executed physical command [Notification Light].on() (8ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Cancelling statement #32's schedules...
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Condition group #30 evaluated true (state changed) (11ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Condition #31 evaluated true (9ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:48 AM: debug β•‘β•‘ Comparison (enum) off is (string) off = true (1ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:38 AM: info β•” Piston successfully started (983ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:38 AM: debug β•‘ Comparison (enum) on is (string) off = false (3ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:38 AM: trace β•‘β•” Finished subscribing (257ms)
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:38 AM: info β•‘β•‘ Subscribing to Notification Light.switch...
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:38 AM: trace β•‘β•š Subscribing to devices...
d5ec8974-b59c-47db-80ce-6114c2f9748c  1:13:37 AM: info β•š Starting piston... (v0.3.10a.20190223)

For some reason the piston is acting like an event handler. Every time I turn off the light it goes off long enough for the piston to activate and turn it back on.

I found another topic that resembles this on and the resolution was to set the task cancellation policy to never. That did not work in this case.

Hints, tips, and suggestions would be apreciated at this point.


#2

A bit of confusion in he way you wrote this up. I see your piston is subscribed to the light and when it’s off you have a condition to turn it on.

What exactly are you trying to do?


#3

because piston is doing what you told it to do…
Delete or pause this piston and it won’t turn ON.


#4

Well, the idea was to test the state of the light bulb - is it on or not. If it isn’t then turn it on.

However, in the light of day I can see that doesn’t make sense - just turn the thing on. If it’s already on then it wont change states. Obviously a operator head space and timing error.

But now I’m curious - why does it keep flipping back to and executing that statement/piston? Trying to understand the why - not just the results.


#5

Every time the switch state changes, it will go into this piston to evaluate the if statement. If on, it does nothing and exits. If off, it turns it on. That is the logic you have implemented.


#6

New to this so bear with me.

If I understand this correctly then every time a state changes (lightBulb002) regardless of what piston it is in it will be evaluated.

That being the case my looking at a piston as a function or procedure that can be called is not correct. I need to look at it more like an event handler that checks the value every time an event triggers?


#7

That is basically it. Each piston subscribes to specific events as shown by the lightning bolt and monitors any change to the monitored value so it can evaluate the requested logic for true or false.