Door Open Light change


#1

1) Give a description of the problem
When my front door is open, I want to change a light by the door red. This is a hue light. Then when the door closes and locks I would like to turn the light back to the previous color. If the light was off before the door opened, I want it to turn off as well.

2) What is the expected behaviour?
(PUT YOUR INFO HERE)

3) What is happening/not happening?
I can get the light to turn red when the door opens but it won’t turn back to previous color or won’t turn off if the light was off before it turned red

**4) Post a Green Snapshot of the piston!

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

You might want to post a green snapshot of your piston so we can see what you’re doing.


#3

Hope this works


#4

When it comes to Capture and Restore, here are my thoughts
(all 8 links are saying the same thing, in different words)

I apologize… I did not feel like making a ninth today… :blush:

One of these days I may combine all of them into one thread…


Side Note:
If you must share a red snapshot, for your safety, please at lease cut out or obscure the import code.


#5

About recording colors and restoring them:
In my experience it was delaying way too much…
@Wcmore and I wrote a piston for my bathroom.
AT on the wall had options to turn lights in different colors.AND back to original smooth white.
I have about 10 Hue bulbs and sometimes going back to original colors would take up to 20-30 seconds.

Maybe mine was due to signal issues etc…


#6

This is what I have so far. The light will not go back to same color as before. I have tried with a without color temp. Any thoughts?


#7

If line 48 is deleted, and line 42 is adjusted to say:
–IF Sensor CHANGES TO locked
then it should work as expected.
(You want a lightning bolt next to both IFs)

If you are watching your logs, you will see that your current piston does nothing when the door locks


Edit
There is a chance that a door lock also triggers from line 27…
(if so, it would indirectly execute the second part of this code)


#8

Also, you are capturing the state of Bulb 4, but restoring to Bulb 2


#9

So I tried with and without line 48. Didn’t restore to correct color. And bulb 2 and 4 are same color just different bulb. Bulb 4 is actually three bulbs set as a zone in hue app so I thought that might be messing things up. The light does restore to a color when the doors locks with the piston I posted just not the correct color. I will edit line 42 and see what happens but that shouldn’t affect color right?

Thanks for everyone’s help


#10

So this is what I have now. How do I get the lightening bolt


#11

Your last piston looks solid…

I am not sure why there is no lightning bolt on line 40, but it is written as a trigger, so it should fire properly.

The only thing that might be missing is returning the switch status to what it was earlier…