Set 100% then restore state


#1

Trying to have the lights on between sunset and 22hrs at 10% then off after that.

If motion detected at any time when its dark set the light to 100% then return to original state

I think its running twice on motion which cause it to capture 100% on.


#2

The first thing to try is setting TCP to never.
The way you have it at the moment, when motion sensor goes inactive the task will cancel at the 5 minute wait.
Also get rid of your Turn On. Just use the set level.


#3

oh ok so the task would only run whilst the if condition was met.

Have made the changes will test tonight thanks.


#4

If you look at TCP the default is to ‘Cancel on Condition change’ (I think).
This means when the motion sensors condition goes inactive the task will cancel.
If you set it to ‘Never’ then the tasks will never cancel and will mature. If motion is detected before the 5 minute wait matures then the tasks will start again from the top.


#5

So the wait issue is fixed but now it will run twice and capture the state from the first run not the original state?


#6

I’ve never used anything like this but I would think if there is motion then it will store the state as you wish.
Then set the level to 100%.
Wait 5 mins and then restore the original state if no more motion is detected.
If motion is detected again in the 5 minute window the piston will re-evaluate and save the level and switch state again, which is on and 100%.
This is all an assumption as I have never done anything like this.
You may have to amend this to take this into account. Give it a try for both scenarios and see what happens.


#7

Just tested this and if there is no motion, the attributes are restored OK to the light.
If there is motion before the timer expires it saves the new attributes.


#8

If you don’t want subsequent motions to overwrite your stored values, you need to break out the conditions separately. I haven’t put this through the paces, but logically it should do what you’re attempting to do:


#9

This will do the job for you. Tested it and it works fine for me.


#10

@anon12447784 did you try the piston I posted? Does it do what you want?