Trying to get light to turn on when door opens and go back to original level on close


#1

1) Give a description of the problem
I am trying to get my light to turn on 100% when the door opens which works but i want it to either shut off if it was off or go to the level it was before the door opened.

2) What is the expected behavior?
if the light was at 1% when the door was shut I expect it to go to 1% when the door shuts again.

3) What is happening/not happening?
door opens and the light goes to 100% which is good. door closes and it stays at 100%. i want it to go back to original value before door opened or off if it was off.

**4)


#2

Here is a piston I use wiht a couple examples:

Basically you want to capture the level and switch to a local store before turning it on/setting level (if empty) and then restore it after all is done

Now I am sure this piston could be optimized, but it works :slight_smile:


#3

here is the working one, combined with yours and what i got from RobinWinBourne on ST i was able to get this working.


#4

Only suggestion is use a Value and Name for the localStore so that in the future you can combine a bunch of these into a single piston


#5

I will remember that. Not sure if i will have anymore exactly like this though. this is the only area that has no light in it.


#6

I have a similar, but different problem…I have a light outside that is on at 10% in the evening. I would like the light to go to 100% when the door opens, but (this is where things get difficult) I want the light to stay on at 100% for 15 minutes regardless of any state changes to the door contact. So, if I open the door and close it behind me I would like the light to go to 100% and stay at that level, then, after 15 minutes return to the original level (usually either 0% or 10%).

The problem I run into with the piston is that it triggers with each state change of the door sensor. So, I can successfully store the original light level in a local variable when the door opens, and, if I leave it open with a wait command, I can reset to the original level after 15 minutes. However, if I close the door, the piston runs again during the wait period and the logic changes so the ‘wait’ is negated and the light stays on at 100%.


#7

I am also attempting a use case that is very similar to the original post. When a contact sensor (Garage Door) opens I would like to store the current state of a multi-color bulb and then wait a period of time. If the door remains open I would like to change the bulb to red - indicating the door has been left open.

If the contact remains open until the bulb is changed to red and then closed all the settings (state, color, level) return to the pre-event conditions. However, if I close the contact BEFORE the bulb is changed to red (i.e. garage door closed before open door indicator turns on red) then the bulb state is changing to ON - all other attributes remain at the pre-event settings.

Any ideas on this use case as well as previous would be appreciated.


#8

@dduisenb On your first ‘with’ statement, you need to change the Task Cancellation Policy (TCP) from ‘Cancel Tasks on Condition State Change’ to ‘Never’.

Click on the ‘with,’ then the gear icon at the bottom of the pop-up. You’ll see the option there.


#9

@bthrock Thank you! I was not aware of that setting. I have made the change on two pistons and did some preliminary testing. This appears to have corrected my problem.

Thanks again!