# Gauge for Length of Day (showing Solstices & Equinoxes)

#22

Hi Alwas, thanks for the questions.

First off, my current piston states can be seen in the ‘hover text’ as shown 2 posts back… but they can be modified to fit you, of course…

It is important to note that the first two gauges are extremely accurate (within 30 seconds since webCoRE rounds dayLength to the nearest minute). On the other hand the 3rd gauge (the one you mention) is entirely based on the day of the year. (and solstices and equinoxes can vary a day or two each year) This means the 3rd gauge is the one easiest to share with others, but it also means it is the least accurate. (it could be 24 hours off in either direction)

If you want the data without the gauge, then I suggest creating a piston from the data found in the very first post here. It is a lot of math required, but it only needs to be done once, and it remains accurate for years and years.

Let me know your thoughts, and we can go from there

#23

I’m all about accuracy, so i don’t want to be days off, but i like third one because the summer solstice gauge is in the middle, mimicking the sun at it’s highest point in the year…

#24

Well, the summer solstice is close to the middle in the 3rd gauge since the winter solstice happens 10 days before the year is up…

So, I have to ask. Will you be using the gauge or simply text in the piston states?
(the code is substantially easier if you drop the gauge entirely)

#25

I’d probably drop the gauge, and try to work out some funky helpful text. And use least resources as possible…

#26

OK. I will be glad to help with the math, but I have a homework assignment for you first:

You need to find the longest and shortest days for your location (down to the seconds for accuracy). I put in my city at www.timeanddate.com/sun/ and then examined the “Daylength” in late June and then in late December to find the extremes.

For added accuracy, I recommend comparing a few years. I will need to know the longest DayLength in June, and the shortest DayLength in December. (I will base my math on the numbers you give me)

#27

@Alwas I sent your math in a PM to keep your personal information private

#28

Happy Summer Solstice everyone!

Here is how my 3 gauges changed in the past 24 hours:

Nice transition of colors as the first two gauges will now spend the next 6 months moving towards the left. (the 3rd gauge is continuing on moving to the right)

In the first gauge, Blue represents the coldest 3 months, Yellow is the hottest 3 months, and Green/Brown is the middle 3 months.

In the 2nd & 3rd gauge, Blue/White represents Winter, Green is Spring, Yellow/Orange is Summer, and Brown is Fall… (still tweaking my colors a bit)

#29

Wow awesome, exactly what i was looking for, and your piston state version for me was seamless, looks really good. It’s like you read my mind! And what an auspicious day to get it, Summer Solstice. I was once at Stonehenge at dawn on a Summer Solstice, which was an awesome experience. And as much as i look at your math in the piston i’m dumbfounded, i’m also dumbfounded with how the Druids were able to work out the Longest day of the year to the second, 3000 years before the “second” existed. Anyway…

#30

Stonehenge is definitely on my bucket-list…

In my last house, I placed decorative stones in various places around my backyard. The shadow from my flagpole acted like a solar calendar as it moved around throughout the year. It amazed me at just how precise it was…

I was originally inspired from Indiana Jones - Raiders of the Lost Ark, LOL

(Although I never put a crystal on the flagpole…)

Great 4 minute video here if you want to refresh your memory…

#31

If my math looks confusing, perhaps seeing a different example will help it to make sense:

#32

Hey thanks, I’ll look into that…

#33

Have you noticed that the amount of sunlight visible X minutes before sunset seems quite different at various times throughout the year? For example, Sunset-20 seems much darker in the summer than in the winter.

I have come up with a math formula to automatically compensate for this. It ends up being a very simple formula, but does require the data stored in the @@dayLengthPercent variable above for it to work.

In the following example, at the summer solstice, the piston would trigger 60 minutes before sunset, and gradually shift over the next 6 months. By the time the winter solstice arrives, the piston would be firing 20 minutes before sunset. It would then spend the next 6 months slowly moving back in the other direction.
(the step-by-step guide below is so you can use numbers that work for you)

• First, you have to decide how many minutes before sunset you want your piston to trigger at the two solstices. (I am using 60 for the longestDayOffset, and 20 for the shortestDayOffset)
• Next, we subtract one from the other to find the difference. (60 - 20 = 40)
• Finally, we take 100 divided by the difference to find our multiplier. (100 / 40 = 2.5)

The formula for webCoRE would be:
`round(-((@@dayLengthPercent / multiplier) + shortestDayOffset),0)`

Or, using our example above, you can define a variable in the top section like this:
`define integer sunsetOffset = round(-((@@dayLengthPercent / 2.5) + 20),0)`
(Don’t forget to replace 2.5 and 20 with YOUR numbers)

and make the first line of code something like this:
`Time happens daily at {sunsetOffset} minutes past {\$sunset}`

This piston idea works great for things like closing blinds, turning on evening lights, or anything else revolving around the time of sunset… I have been using this code for a couple months, and it works like a champ! (every couple of days, the offset shifts another minute)

SIDE NOTE:
This formula was designed to work with any two integers (whole numbers)…
The only restriction is the longestDayOffset (Summer) has to be greater than the shortestDayOffset (Winter).

#34

Hi, WC. I enjoyed reading your post and piston for a gauge for length of day. Nice work.

As a newbie at webCoRE (starting today), how do I actually see the gauge?

#35

Hey thanks. I appreciate that. It sure was a lot of fun to build.

From the Dashboard, you can click on:
Settings > Categories > Add Category
Then give it a name, and make sure the second column says “Tiles” of some kind. Click Apply, and you are done.

Then any piston you want to display a tile and/or gauge, you just have to add the line of code, and remember to save that piston to that “Tile” Category you created.

#36

This is great! I’ve been bugged for years by the difference in darkness at 20 min before sunset between Summer and Winter solstice. Unfortunately, the basic tools I’ve been using (UpStart for UPB switches and SmartThings for Z-Wave switches) both provide a fixed positive or negative offset from Sunset and Sunrise all year long. Now I can begin moving Z-Wave control for lights on at sunset to a Piston. Thanks for thinking of this.

#37

Well, we are quickly approaching the last day of summer…
It seems appropriate to show the current data on my gauges:

Reminder:

• The first two gauges are moving towards the left (0) and are based on sunlight
• The last gauge is moving towards the right (365) and is based on day of the year

#38

Two days left of summer! My background changed to “brown” as an early alert.

The other two gauges will change background as it gets even closer.
(since the first two gauges are more precise)

#39

Last full day of summer is here:

(I am still tweaking my colors a bit. It’s not so easy because certain elements only appear once a year, LOL)

#40

Beautiful transition for the Equinox.

The ‘point 2’ after the 50 is because webCoRE rounds to the nearest minute for sunrise & sunset. Once webCoRE returns the actual seconds, my gauge will become even more accurate and display 50.0 at the equinoxes.

#41

Just an update for those curious…

You won’t hear this mentioned anywhere else, but today begins the darkest 3 months of the entire year…
(for those of us in the northern hemisphere)

We are currently halfway thru fall, but surprisingly, the day length has already dropped to only 15% above the absolute minimum.

I have to admit, I never realized the rate of daylight increase/decrease changed so much throughout the year until I let webCoRE monitor this for awhile…