Return light to previous state after


#1

1) Give a description of the problem
(Light doesn’t always return to initial state. Sometimes it does, sometimes it doesn’t.)

2) What is the expected behaviour?
(If light is on and there is motion light goes to 100%, flashes, then after 5 minutes returns to 50%. If light is off and there is motion light turns on, goes to 100%, flashes, stays on for 5 minutes then turns off.)

3) What is happening/not happening?
(Sometimes the light stays on after the sequence even if it was off before motion. Sometimes the light stays off after the sequence even if the light was on before motion. The ‘on’ in the ‘do’ sections was required to make sure the light was on after motion. Help! Thanks in advance.


#2

The never cancel task you inserted will force it to continue onwards, regardless of what changes.

IE: Most motion sensors could easily go from active to inactive and then back to active in under 5 minutes. (meaning your piston might be overlapping)

To properly diagnose this, I would recommend turning your Log Level to Full, and turn on Trace.
(more info here)


It is also worth asking yourself:
Do you want the light turning off even if the motion sensor still sees activity?


#3

WCmore,

Thanks for your thoughts. I should have noted the motion sensor has a built in delay between re-activation of ~5 minutes. After motion is detected the sensor shows ‘motion’ within ST for ~5 minutes.

Do you think overlap could still be an issue?

This is my first attemp at a code so if you have an idea on how to add a ‘cance taskl’ I would be interested.

I will try to get at the full log later.

Thanks!


#4

The general advice for a motion sensor is something like this:

If Sensor's motion changes to active
Then
     Turn on, do cool stuff, etc
END IF

IF Sensor's motion stays inactive for 5 minutes
Then
     Turn off etc
END IF

(Notice the two IFs are independent)

This gives you one quick event the moment you enter a room… but as long as there is at least one movement every 4.9 minutes, then the turn off timer will keep restarting. Once it is determined that the room has been empty for 5 minutes straight, then the final block kicks in.


Disclaimer:

Depending on the device, handler and the length of the pause, it is very common for (action > pause > action) to re-trigger the piston… (running thru the code, top to bottom)

Once you turn the log to Full, you will see what webCoRE sees.
(what trigger, how often etc)

… and to answer your next question, Yes. Most of us tweak our piston times once we become aware of the quirks of our particular device.


#5

In my log I found the following as the last entry when the light was stuck on:

Skipped execution of physical command [Front Porch Light].off([]) because it would make no change to the device. (3ms)

I’m trying to workaround this by using the following advice from another thread:
disable command optimizations.

I will test it out and reply.


#6

The potential solution in my previous post did not help. The log showed an off command being sent to the light but it would still be on.

I reworked the code as follows and it works.