Not working conditions?


#1

Hi,

I have several pistons. But now I want to use core for motion controlled lights. Activating the light when there is motion is easy. I want to turn off the light when there is no motion for more than 3 minutes.
So I combined 2 conditions:

Each of Living Room Sensor and Living Room Sensor X motion is inactive
AND
Each of Living Room Sensor and Living Room Sensor X motion did not change in the last 10 minutes
There are also additional conditions:

AND
Living Room Switch switch is on (this is always on for now)
AND
Variable {@lroom} (as number) is equal to 1 (this is 1 when I check from global variables)
AND
Time is between 2:00 AM EET and 6:30 PM EET

But this does not trigger the lights off.
What may be wrong ?


#2

Use an else:

If motion x and y are active
then
Turn on light
Else
Wait 10 minutes
turn off light

Slot in your other conditions as desired

By default, task cancellation policy will cancel the wait if new motion occurs.


#3

but that’s not what I am trying to achieve. Because within that 10 minutes , there might be motion again and if so, I don’t. want to turn off the light.
I only want to turn off if there is no motion for 10 minutes.
how can I do that ?


#4

That is exactly what I described, the ‘else’ gets cancelled if new motion occurs during the 10 minute wait so there needs to be no motion for a full 10 minutes before the light turns off.

Just try it and you’ll see… use a shorter wait for testing.


#5

Ok, but this is already an if-Or clause.
Because, I select other actions if the time is in a different period.
So how can I make an “else” in an if-OrIf scenario ?
And this is just for turning off. For turning on, I have another If-OrIf piston.

my full scenario for turning off is:

IF
Each of Living Room Sensor and Living Room Sensor X motion is inactive
AND
Each of Living Room Sensor and Living Room Sensor X motion did not change in the last 10 minutes
AND
Living Room Switch switch is on (this is always on for now)
AND
Variable {@lroom} (as number) is equal to 1 (this is 1 when I check from global variables)
AND
Time is between 2:00 AM EET and 6:30 PM EET
THEN
turn off
OR IF
Each of Living Room Sensor and Living Room Sensor X motion is inactive
AND
Each of Living Room Sensor and Living Room Sensor X motion did not change in the last 20 minutes
AND
Living Room Switch switch is on (this is always on for now)
AND
Variable {@lroom} (as number) is equal to 1 (this is 1 when I check from global variables)
AND
Time is between 6:30 PM EET and 2:00 PM EET
THEN
turn off


#6

The ‘else’ is there below the ‘then’ section…

Use else instead of or if


#7

Actually, as you don’t seem to be wanting to turn the light on anymore, the following will work:

IF
Each of Living Room Sensor and Living Room Sensor X motion is inactive
AND
Variable {@lroom} (as number) is equal to 1 (this is 1 when I check from global variables)
THEN
With living room lights
Wait 10 minutes
Turn off (only whenTime is between 2:00 AM EET and 6:30 PM EET)
Wait 10 minutes
Turn off (only when Time is between 6:30 PM EET and 2:00 PM EET)

No need to check if the light is already on, that’s done for you in the background by command optimimization, an off command won’t fire on something that’s already off.

If you want the light to be turned on by motion as well:

IF
Each of Living Room Sensor and Living Room Sensor X motion is active
THEN
With living room lights
turn on
ELSE
IF
Variable {@lroom} (as number) is equal to 1 (this is 1 when I check from global variables)
THEN
With living room lights
Wait 10 minutes
Turn off (only whenTime is between 2:00 AM EET and 6:30 PM EET)
Wait 10 minutes
Turn off (only when Time is between 6:30 PM EET and 2:00 PM EET)


#8

If I use the “off” piston from your last post, and use another simple piston for turning on, then what will happen when there is motion before 10 minutes ?
I don’t want to turn off if there is motion before 10 minutes ends.
I just want to turn off if there is no motion for 10 minutes.


#9

Any reason you are using webcore instead of the smart lighting app in smartthings? It is set up for you already.


#10

I think you are missing what Robin is saying.
If you do as Robin has suggested it will work as you want it to.
You only need one piston as Robin is showing you.


#11

This works and is how my pistons are set up, i go slightly further where i have set off times for different times of the day.


#12

The best way to learn is to test on short time durations… but yes, the light will only receive an off command after motion has been inactive for 10 minutes, each motion event will reset the 10 minute countdown.


#13

@darroj
Smart lighting can not do that because I have several conditions for this.


#14

@bobbles
it may work as I want it to but I have several conditions and with just one if-else piston I can not add all of these.
I have 2 different scenarios to turn on and 2 different scenarios to turn off.


#15

whatever I do I can’t create a piston that does what I want to do.

I want to turn on lights when there is motion in any of the 2 motion sensors. but the “virtual switch” should be on as a second condition. as a third condition , global variable “lroom” should be set to 0.
then
if illuminance is between 15 an 1200 , lights should be turned on and set to level 50%
if illuminance is below 15 , lights should be turned on and set to level 100%
if illuminance is above 1200, lights should not be turned on
eventually, “lroom” should be set to 1.

to turn off the lights,
either
there should not be any motion for the last 10 minutes if time is between 2:00am and 6:30pm
or
there should not be any motion for the last 20 minutes if time is between 6:30pm and 2:00am

as second and third conditions to turn off,
virtual switch should be set to on
variable “lroom” should be set to 1

if these conditions are all true, lights should be turned off and “lroom” should be set to 0

so with ONE limited “if-then” piston I don’t see a way to do all of these.

please tell me how can I achieve it ?

I had thought that the combined “motion is inactive” and “motion did not change in the last 10 minutes” conditions would work. but it does not.


#16

Post a screenshot of your piston.
It will make it easier for people to advise you.


#17

for motion piston 1:


for no motion piston 2:


#18

Can’t really see the screenshot on my phone.
Will look when I’m on my PC.


#19

actually , screenshot is not really important. I described what I want to achieve in the previous post. I tried to use 2 pistons for it. but I am open to any other approach.


#20

webCoRE?