Turn off light only when light wasnt on beforehand


#1

1) Give a description of the problem
So I have the hallway light set to turn on and off when the bedroom door opens and closes but I dont want it to turn off if the light was turned on manually beforehand

2) What is the expected behaviour?
It works sometimes.

3) What is happening/not happening?
The problem is if you close the door too fast it wont turn off the light.

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

is there a setting or something I need to change to make this work more reliably? I tried parallelism and async and override but none of those seem to make a difference


#2

The Search box here is your friend…


@bangali has a great thread over here for this exact purpose.

Just be aware in the first post, there are two pistons.

One is for a  dumb bulb / smart outlet... and
One is for a smart bulb /  dumb outlet.

Make sure you start with the appropriate one.


#3

Im sorry, but its almost as if you completely ignored the code i posted and what the problem was and directed me to a thread in which your last post tells people its not for troubleshooting.

I said the code works, just not reliably if the contact sensor state changes too fast. I just want to know if thats a limitation of webcore or theres a setting I can change to fix that.


#4

When you posted that question, you were:

pic

… so I do not regret my choice of words. I spent more time typing back to you than you spent on this forum.

That thread I linked to is by far the best one in this entire forum on that topic, and it covers all the questions, quirks and alternative points of views.

Do with that what you will.


For clarity, troubleshooting a piston posted by the OP is perfectly legit. We do this all the time

Creating two threads with the same question (as that other poster did)… maybe not so much.


#5

If you’re going to talk down to someone with something as menial as time spent, then it would probably be wise to remember that its possible to read this forum without making an account first.


#6

Fair enough. Let’s start fresh… I meant no disrespect, and was only trying to help.


A few things come to mind with your piston.

(1) ASYNC does absolutely nothing in your piston. Might as well be shifted back to a regular IFs & WITHs.

(2) I suspect the delays are due to you using a global variable. Using local variables are near instantaneously written to, and can be read back about 10ms later.

(3) Notice how line 32 & 46 both activate the trigger on line 50? Each door open or close essentially creates two triggers… and the piston runs top to bottom twice in a split moment. (generally, a bad practice)

(4) Parallelism is not the solution either

With all that said, I guess the million dollar question is… is it worth the time to recreate the wheel?


Speaking of time…

I am sorry you feel this way…

My time spent here is the exact opposite.


#7

I switched to a local variable and nothing changed. It seems that either the writing or reading of variables doesnt really work that well. Just running the second statement without checking if hall=true runs a lot more reliably than with it in.

The third statement on line 50 isnt really necessary. I threw it in there to reset the variable but it didnt change the reliability with or without it.

With that being said I switched from variables to checking the brightness level and changing it 5% to match conditions and its significantly faster than using a variable.


#8

Just for completeness, you should consider posting the updated piston to go with your solution.


#9

For others reading this thread, don’t be disillusioned by the above statement. Local variables work amazingly fast and reliable here in webCoRE… In the snippet below, it changes twice in 33ms. If we expand that number out, it may be able to handle 60 changes per second.

pic


Edit:

Added the word “Local” to the first paragraph, for clarity.