Weather Offset Depending on Clouds


#21

Your only trigger is line 22 (next to the lightning bolt)


so that should be the only things activating the piston.

When a motion changes to active, it will check the variable and time conditions.


#22

@WCmore So really, I should change the IF to a while and capture the date/time first ?

What about my last IF, how would that work. I just want it to fire if/when dark_outside changes to true?

Nothing else?


#23

Wait, you want it to constantly fire to check the global variable?!?


#24

For my outside lights…especially this time of year. I would be happy for the piston to fire one the global variable has changed from false to true to turn on.

My inside, I can control that with a while loop (I presume)

Even today, it is very overcast, so on the weekend, I would have a piston to keep inside lights on and possibly check every half hour to see if things have gotten brighter, or not.

Have patience with me as I am still learning and understanding how it all works.


#25

Hang on, running a test now for you


#26

What if I changed from an IF = to IF changes

that should trigger the piston, no? The question is, will the global variable keep checking to change ?


#27

My test was successful. If you make a lightning bolt next to the lines:
IF @dark_inside is true
IF @dark_outside is true
then they will act like a trigger, and the piston would run when the variables change.

Just edit those lines, and click the ‘cog’ and Subscription method: Always subscribe


#28

OK, I have made that change…how does this look ?


#29

Ooopps, sorry, I should have clarified. The first two globals should be switched back the way they were.

temp

This is because you cannot have two triggers happening simultaneously.
That top block will only run when the motion changes to active.

The other two globals lower in the code look perfect now!


#30

I need to re-think the presence sensor light, so I took that out for now.

Thank you again for your help

and everyone’s help for the ideas and hints


#31

ok, just keep in mind lines 1-64 will likely NEVER RUN the way it is currently worded.
(We can only have one trigger per block if you expect it to work)


#32

So really

I should split up all three lights into 3 separate pistons to keep things simpler

Inside
Colour
Outside


#33

That part is up to you really…

The part I am trying to emphasize is each block of code normally has ONE trigger, and occasionally one or more condition(s).

Think of it this way… What do you want to actually trigger a block of code? A precise time of day? Upon motion detects? Upon variable changes?

Each block should pick ONE trigger, and only one trigger. You can always add conditions inside that block to further narrow it down…


#34

I understand what you are trying to say

I am just trying to wrap my head around how to execute it properly

I really only care about turning on my lights when it gets dark. differently on weekday vs weekends

The only other thought was the presence sensor, which as you mentioned should go first

while between 12 and 3pm
if motion = true and dark_inside = true
turn on lights

or something like that
as its own piston

then have my if after 3pm piston fire when dark_inside=yes


#35

would something like this work


#36

Yes, if you make the global variable line Subscribed always…
(and make sure no lightning bolt next to the time)


#37

Like this…


#38

That looks good, but I would change the global lines to say:
IF {@dark_inside} CHANGES TO true
(remember we want a precise trigger)

It might also be worth considering adding another block to turn off the lights if the global changes to false


#39

Thank you for your help!

I have different pistons for turning off lights, depending.

Thank you again

Will see how this fires up tomorrow!


#40

Question

Changing the trigger to changes to true

Would that not fail, if it changes to true before 3pm

So it will execute and exit before 3pm

But since it already changed to true , it won’t trigger again for the rest of the day

Wouldn’t it be better to keep it as true , so from 3pm onward it checks ?