Need a little help with the sunset variable

variables

#1

1) Give a description of the problem
Piston doesnt show expected behavior and sometimes doesnt even activate lights on the given time.

2) What is the expected behavior?
Would love to see that livingroomlights go on 15 minutes before sunset and automatically turn off when its 00:00

3) What is happening/not happening?
cant get the lights to get activated 15 minutes before sunset. Also, some timer offset is running next to the piston in the dashboard, which is a little bit off with the sunset time.

**4) Post a Green Snapshot of the piston

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)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

I am not near a computer at the moment, but here is what jumps out at me:

In the pic above, line 26, 27 & 33 are not needed. That section can simply be:

With
    Bulbs
Do
    Turn on
End With

I would also be tempted to remove the (Only while) from line 31.

As far as testing goes, keep in mind all four conditions must be true for the piston to run.
(line 18, 20, 22 & 24) If any one of them are false, then the lights will not come on with your current wording.

To get it to turn off at midnight, you can make a new block (outside of any other commands) saying something like:

Every day at 23:59:00
With
    Bulbs
Do
    Turn Off
End With

#3

Hey there, thanks! Think I’ve got it now. You have any idea how I make it trigger 15 minutes before sunset? greetings


#4

Why use a variable. In the drop down where you picked the variable, pick ‘Presets’.
You can then pick Sunset and put in any offset you wish for pre sunset and post sunset.


#5

If you are a visual person, then this:

temp

Returns this code:

temp


#6

Think I’ve got it now. Trimmed a little bit. See how it goes next sunset. Here’s the current version.


#7

Lookin’ good, but to be honest, I still don’t like line 24 & 33.
There is never a need for an empty IF statement.
(it is just asking for problems)

I would grab the entire WITH statement (lines 26-32 above), and drag them up two lines right above the second IF. Then you can delete the empty IF without having to recode anything.


EDIT :
You might have to toggle “Allow moving of items” if you haven’t already

temp


#8

Reworked it now, it’s a bit of a hassle but I’m learning as I go.


#9

I admit, my first drag and drop was a bit awkward, but it really makes editing code ten times easier!

Now we just gotta wait until sunset, LOL


#10

mmmm, i think i have everything worked out. Though its just partially working, it already started logging.
The kitchen comes on automatically, just the other lines beneath that (livingroom) wont come on. Any idea’s what i could adjust to make this possible?

greetings


#11

Try setting both yours ‘WITHs’ to run asynchronously.
The first with will start to execute but will wait until midnight. This means it never gets to your second with.
Setting to async means both withs will run at the same time.


#12

I’d get rid of the WAIT commands all together - they’re a pain when using triggers.

Keep the top of your piston all the same, except delete “wait until midnight” and each instruction after that.

Create another “If time happens daily at midnight” condition, and in there put your “Turn off/Fade level/log to console” commands. It’ll be a lot less flaky and easier to modify later on.


#13

Ok I’ve done this now. I’ll let you know tomorrow if it worked out! Thanks for the (quick) response.

Greetings


#14

I’ll see tomorrow if I can test your option. Thanks again everybody for thinking along.


#15

Everything is working as it should! Thanks alot boys and gals, means so much to me!

greetings