Help designing my first piston- newbie


#1

1) Give a description of the problem
(No problem. have not been able to test piston under current conditions.
2) What is the expected behavior?
(Would like for kitchen lights to turn on, on a cloudy day only if motion has been triggered and Lux is under 45 between 7 am and 7 pm )

3) What is happening/not happening?
(Just would like someone to take a peek at the piston and see how it looks )

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)


#2

looks great. just move the if block starting at line 29 to outside of the if block starting at line 17. that way it will work great too. :slight_smile:

it should look like this when you are done:

if conditions
   turn on lights
end if
if condition
   turn off lights
end if

#3

Thank you! The light would go on when lux condition and motion was triggered, but for some reason it was not turning lights off after motion changed to inactive. Then I did what you suggested with bring out line 29 outside of the line 17 if block and the lights went off after no motion!!

This is awesome!


#4

Best advice I could give you moving forward is to avoid nesting your IF statements.

IF/THEN… <-- That’s okay.
IF/THEN/IF/THEN… <-- Not recommended


#5

sorry this is the screen shot I meant to upload.

those this look better?


#6

Looks good!


#7

total newbie at this as well, but you may want to add some kind of delay before the lights turn off. that way if you walk out for 10 seconds or stand still the lights don’t turn off.


#8

That sounds like a good idea! How would one add a 10 sec delay?

So :

Motion changes to inactive
Wait 10 sec
Then turn off lights


#9

Here’s a simple piston I use for my bathroom which uses a “wait”… works well.