Hi and welcome to Webcore.
I’m creating this post to help out Newbies faster.
I will share some basic but most asked situations in this post.
please jump in and add your ideas but please let’s keep it simple so that the post serves new users.
I will be adding new situations as comes to my mind.
#1 - Lights on with motion and lights off if no motion X minutes.
#2 - Lights on with motion and lights off if no motion X minutes BUT with different CONDITIONS.
#3 - Nested IFs and two seperate IF blocks are NOT the SAME.
Lights on with motion and lights off if no motion X minutes.
Probably almost every smarthome user wants to do this as a first thing.
Here is one of the best ways of doing this:
Tips: We tend to use WAIT instead of STAYS INACTIVE but go with STAYS INACTIVE if you don’t want to get your partners annoyed.
Lights on with motion and lights off if no motion X minutes. BUT with different CONDITIONS
A CONDITION decides when trigger will continue to execute.
Let’s say you want your lights to turn ON only after X time (in this example sunset) but keep them off during the day.
_Tip : Do not use the same condition when turning lights OFF because, If your lights turn ON at 11.59pm and stays INACTIVE for 2 minutes, NOW, it’s past midnight. Your lights will remain ON until next sunset.
Nested IFs and two seperate IF blocks are NOT the SAME.
Line #17 is where your first IF block starts
Line #36 is where that IF block ends.
IF you add another IF - line #27 in this example - this piston won’t work as the one above (example #2)
“IF within IF” works if you have additional conditions.
In this example,
- motion sensor gets triggered,
- piston checks if time is between sunset and midnight
- IF both are TRUE, now moves on to next statement,
- IF switch X (could be home status etc) is OFF
then turns the lights ON.