Are you a Newbie, this is your post


#1

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.

#1
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:

52%20PM

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. :joy:

#2
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.

19%20PM

_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.

#3
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.

16%20PM

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.

such as,

10%20PM

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.

Motion Sensor Help
#2

This thread is a great idea…

If I may give one suggestion it would be to add import codes for the examples.
Some of the simplest commands can be tricky to find for new users.


#3

That is a great idea. I already deleted the above examples but I will keep this is mind for the future pistons.


#4

Thanks.
Can you please elaborate 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."


#5

If you use a timed shut-off for a light that is turned on because someone is in the room, it will turn off after the “wait” period regardless of someone still being in the room. Room lights shutting off and leaving you in the dark tend to upset some people, partner or otherwise.


#6

I was very hesitant to get into webcore due to its steep learning curve and me not being a developer.
I believe it’s the right time and right thread for me as a newbie to jump in and learn webcore!
Thanks OP !


#7

I’m not a coder either (except some less then a hobby level in the 90s LOL)
this is a great forum with tons of Pros and they are all very helpfull.


#8

Ok , I followed your instructions and created a piston but for some reason it’s a bit different… how do I fix it?


#9

very easy
your second IF block (line 20 ) is nested IF block you just need to seperate that.
move that after line 29


#10

Probably a silly question, how to move line 20 to line 29?


#11

Select the second IF block (lines 20-28), and use this method to drag it to the very bottom.


#12

Ok, was trying to use drag drop on phone but it did t work, will have to try on my laptop and check tmrw.
Will keep you posted


#13

My apologies… I do all of my coding on a large PC monitor…


#14

Yup… that worked!
Although, I first tried to delete the 2nd condition and redo it but it still became a nested IF, not sure why…


#15

It matters which “Add” you click on…

pic

  • The first highlighted area will create inside the THEN section.
  • The second highlight will create an independent block at the bottom

#16

Cool, thanks for explaining!

I spent a few hours this morning and created my first elaborated piston and it works really well and I feel elated :slight_smile:

Sometimes the push notification is received late or if I am testing it, all the notifications come at once…


#17

IF, it does stop working time to time, change your 5 seconds and 4 seconds to bigger numbers. Like 10-15 seconds.
Webcore is amazing yet not great with very short period of waits or calculations. (Due to network congesttions etc)


#18

Ya, I might change that depending on how it goes…


#19

Continuing my interest in creating more webcore pistons, I am trying to convert an automation into a piston.

Its a pretty straightforward automation where between sunset to sunrise when motion is detected in bedroom, 3 different lights turn on at the same time with different brightness, colour and hue but the catch is “the lights turn off at different times”

I am not sure how to create the ‘then’ statement for the 3 lights turn at the same but turn off at different times.

Here is the webcore I tried to create with 2 bulbs:


The first bulb turns off in 15 secs and the 2nd one after an additional 5 secs which means after 20 seconds. How do I get the 2nd one to independently turn off after 5 secs instead of creating another piston and calling it?
Any suggestions? The maybe I will be more creative and add some more actions :slight_smile:


#20

try this:

IF motion sensor stays INACTIVE 10 seconds
         then
         IF contact sensor IS closed (be aware this is a nested IF)
         and
         IF time is between X and Y
      With 
         RGB 1
         Do this do that
      With (Never cancel task)
         RGB 2
         Wait 15 seconds
         Do this do that