Light will turn on but wont turn back off


#1

1) Give a description of the problem
when a routine fires, I want to turn on a light, wait 10 seconds, then turn that light off. I found similar instances in the community and I made sure that the task cancel for the IF is set to NEVER.

2) What is the expected behavior?
light turns on then off after delay

3) What is happening/not happening?
The light turns on when the routine fires, and the logs say that it is turning off - but the device never turns off.

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

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


#2

I haven’t experimented with Routines yet, but from the looks of your code, the Off command will never be sent. In webCoRE, when there is a long pause, the piston will wait the specified time, then start over from the top of the piston. Of course, the IF section will fail on the second run (since the Routine did not execute a 2nd time).

I wonder if you could remove the IF statement above, and tell your routine to simply run this piston:

temp2


#3

If I have just 3 commands with white bulb, it will never trigger - at least thats the error message that it gives. I tried another way of doing this with a variable something like this:

boolean need_off

if need_off is true
turn light off
need_off = false
endif
if routine fires
set need_off = true
turn on light
wait 10 seconds
endif

That did not work either. The original version shown in the original posting even claims that it is turning the light off (red arrow) - but does that mean its not really trying to do that? Any other ideas? Why is it so hard to get just a simple flow to work?


#4

Just for kicks, send it another off command.


#5

Thanks eibyer: I had tried that too and it didnt work either. :slight_smile:


#6

Does it work if you turn it on manually and issue an OFF command from a test piston? Also, try disabling command optimization if you haven’t’ done so already.


#7

Curious to see the solution to this. i have a similar issue on something I wrote to turn on a light when my front door state changed to open and then turn off again after 5 minutes. It works fine if I leave the door open for the whole 5 minutes, but if I close it before the lights go off it never executes the “turn off” command.

My work around ended up being to add the “wait 5 minutes” and “turn off” commands outside the if statement.


#8

Yours might be fixed simply by clicking on the WITH with the Wait in it and selecting the cog icon and changing the task cancellation policy to NEVER. Closing the door changes the condition and cancels the timer.


#9

Thanks I’ll give that a try.


#10

RESOLVED:
If you look at my original green listing - I had the do not cancel on the IF statement - but I did not have the do not cancel on the with statement - adding it both places fixed my issue and now the lights turn off when requested.