How would I create a piston to turn a light on at 10pm only if any one or all of 3 motion sensors were active during 1pm to 8pm
Turn light on only if motion sensor active
I’m assuming you want to turn the light on at 10pm, if there has been any activity on the 3 sensors between 1&8.
set a variable (1 of 3) when a sensor is activated between 1&3
At 10pm, check all variables & if set turn the light on. Also reset the 3 variables ready for the next day.
There are many examples of this throughout this forum and MANY ways to do this. I have not tested this, but one way would be…
Define a variable
Motion_Active : Boolean
IF any of motion_sensor1, motion_ sensor2, motion_ sensor3 changes to active
Then
IF Time is between 1PM and 8PM
Then Set Motion_Active = True
END IF
END IF
Every day at 10PM
Do
IF Motion_Active is true
Then
Do
Turn On Light
Set Motion_Active = False
END IF
END EVERY
Thanks Guys
Pantheon, not sure how to add "then set motion_Active = true
Ive gone to Global Variables and add the two statements
boolean @Motion_Active=True
boolean @Motion_Active=False
not sure what to do now
In your code, click on “add a new statement”, “Add an action”, “Add a task”, “Set variable”
No. You should not need a global variable unless you are going to use that variable outside of this piston. If you are, then define a local variable first, get this piston working, then you can change it to global if needed.
Another tip which can catch you out if you’re new to webcore,
Don’t give the variable an initial value, if you do, every time the piston runs it will take this value. If you need an initial value, you can click on the variable, in the variables section and assign it a value.
now i cant figure one how you added
Every day at 10
Do
If motion Active is true
I can add happenes every day at
but I dont think that the same
This is what I have so far
When I try to add Set Motion_Active = False
I get an error “invalid variable”
Very good. You are getting there. But you need to make some changes.
- Define your variable Motion_Active in the define section at the top of the piston. Go to the top right of your piston and click on Options and check the Show variables.
- Under your Time is between 1PM and 8PM, take the set variable statement out from under the IF and have it as a statement by itself.
- Remove both blank IF statements below it.
Ok
I see what i was doing wrong. I didnt define the variable at the start of the piston
Also I had the set variables in the wrong place
Thanks for your help Pantheon
I have to be away from my computer now. If you can post your edited version, I will review it later.
I changed the times temporarily and it seems to be working
Thanks for all your help.
Now I know a little about variables I have a momentary switch on my garage door opener and a contact sensor. (Want it to close at sunset and if open anytime after that for 15 min. The piston does not work on occasion. Maybe I would be better off using the contact sensor in a variable