Webcore logic


#1

I know this is something simple but I could use some help with understanding webcore logic and the actions it takes. Something simple I wanted to try was if it’s between 10 mins before sunset and sunrise everyday, turn on a lamp to 10%. This statement alone would appear to only turn the light on to 10% and never turn it off, so is it necessary to code turning the light off or does the hub interpret a simple statement like above to mean otherwise off?


(Jimmy) #2

every IF statement has an ELSE statement. adding the off action here would turn it off, too


(Robin) #3

You would need to add:

ELSE
turn off


(Robin) #4

LOL… great minds think alike… I need faster fingers


(Ron Talley) #5

Personally, I don’t like using Else statements, especially when there are only “conditions”, because it limits the possibilities.

Meaning if you turn on the light outside of these time periods it would turn back off.

I prefer “triggers” such as:

If time happens at 10 minutes before sunset
Then turn on

If time happens at 10 minutes after sunrise
Then turn off

This way, I have control of my light at all times. If I so chose to turn on/off outside of the specified time periods, it wouldn’t revert back the rule set in the “Else” strick condition.


(Robin) #6

That’s not how a ‘between time’ condition works… it fires two events, once at the start of the time window (becoming true) and once at the end (becoming false).

If the time boundary crosses midnight it fires there also, just confirming the ‘true’ state of the condition.

Unless the light being controlled is part of the condition / trigger set (which in this and most cases it isn’t… it’s only part of the actions), toggling the light will never trigger the piston.


(Ron Talley) #7

Tis is where my error was as I just tested it and you are 100% correct…as usual! :rofl:

Doesn’t force the light back off when leaving the light out of the argument. I am now wondering if this is true for everything “else” no pun intended.:grin:


#8

How would an else get them to turn off at 10 minutes to sunset and off at 10 minutes before sunrise? You would need to have two statements in your pistons, one for on and one for off. This is what I’m doing with my Living Room Light. Now, I’m using custom variables but you can just as easily use the presets in the Time device with the offsets for sunrise and sunset.


(Robin) #9

Assuning you made a typo and you mean:

turn on at 10 minutes to sunset and off at 10 minutes before sunrise

It would be:

IF
time is between 10 minutes to sunset and 10 minutes before sunrise
THEN
turn on
ELSE
turn off


(Hendre) #10

My non-math brain has a hard time understanding this principle.
My understanding of this statement is that webCoRE will start to turn on the light at 10 minutes to sunset and continue to send turn-on commands to the light until it stops doing that at 10 minutes before sunrise.
I’ve had bad experiences with webCore “overloading” the hub with statements like IF AT ANY TIME the alarm sensors becomes active, DO … The piston brought my system to a standstill for all practical purposes. Ever since then, I’m always concerned about pistons putting the hub under to much strain because they don’t “go to sleep” until the next trigger arrives. It feels to me as if I should trigger the statement when the time arrives (10 minutes to sunset), let the piston “go to sleep” and use a second command to execute 10 minutes before sunset.
Please, don’t get me wrong, I don’t question your advice. I’m just trying to understand why I should not be concerned to use statements which (in my small mind) “don’t go to sleep but stay awake all the time”.
I’m sure I don’t understand the concept, but would like to know where I go wrong.


#11

Okay, now I’m confused. Would this architecture turn the light off if it was turned on during the day? Also, what would it turn it back on if it was turned off manually at night? The trigger here is not clear to me because “is” isn’t a trigger action like “changes to” or “happens daily at”.


(Jimmy) #12

It would not bbe cause the light is not part of the condition, only time. The only times the condition would be evaluated are the start and need times and midnight. At those there times the true or else action would take place.


#13

When you first create a piston with “time is between”, the time end-point events will be scheduled, in @RobinWinbourne’s example, Sunset-10min and and Sunrise-10min. At Sunset-10min, the piston turns on (barring ST problems) the device — ONCE. If the time period spans midnight (as Robin mentioned), the piston, by default, will not try turn on the device again at midnight if it thinks it’s already in the correct state (this can be over-ridden in the piston’s optimization settings.) The piston sends “turn off” to the device ONCE, pass the Sunrise-10min event.

Remember, coRE/webCoRE is event-driven; those events are defined in your conditions for times, devices, etc. Hub “overloading” is probably caused by your devices sending too many events within a given time period that you’re monitoring in the conditions. This was the case for some of my energy monitoring devices … I had to increase the time reporting period for those events.


#14

“is” acts as the trigger if not mixed with … triggers. If your test conditions consists of only “conditions”, they’re the triggers … just make sure you see the lightning bolt to the left of the condition statement.


#15

If I may add another twist with this one, is nesting acceptable in webcore? While this light is dimmed I’d like to have a motion sensor crank it up to 100 while activated with maybe a 5 minute buffer before resuming prior state. I haven’t read through the entire command set available but would this run nested in the original if then or would it have to run separately and is there a “prior state” command?


#16

Straight from the Boss’s fingers :slight_smile: :

“… you can add as many statements (be them IF, FOR, WHILE, TIMER, ACTION, etc) in as many depth levels as you want. Open world. You can have IF after IF, IF inside IF, any combination you can think of.”


(Jimmy) #17

Nest all you want. I think this is the piston I have with the most layers