Moon Phase piston


#1

Here is a piston that can calculate today’s moon phase daily. You must run it nightly and pass true for the updateToday argument.

It also doubles as a function you can call from another piston to get the moon phase for any day or search for a particular moon phase between a date range. It uses a callback-function-like pattern to call back the other piston. In this example, the callback portion is hard coded to call my other piston, but you could adapt it or make it more generic using piston IDs. OR just delete that entire section of you don’t need it.

It requires the following global variables:

string @MoonPhaseFirstQuarter = First Quarter
string @MoonPhaseFull = Full
string @MoonPhaseNew = New
string @MoonPhaseThirdQuarter = Third Quarter
string @MoonPhaseToday
string @MoonPhaseWaningCrescent = Waning Crescent
string @MoonPhaseWaningGibbous = Waning Gibbous
string @MoonPhaseWaxingCrescent = Waxing Crescent
string @MoonPhaseWaxingGibbous = Waxing Gibbous


Piston Return Value?
U.S. Holiday detection pistons
#2

To update today’s moon phase, the piston must be called with the argument {updateToday} set to true.

Here is an example of my “Midnight Updates” piston that runs this nightly.


#3

This is great and it’s exactly what I’ve been unsuccessfully trying to do for a long time. There’s one thing I can’t figure out. How would I use this to get the moon phase for the following day? I’d like to get a message the day prior to a full moon.


#4

Here is an updated version that sets today’s and tomorrow’s moon phase (i only tested it once :slight_smile:

You’ll need to add a new global variable:
string @MoonPhaseTomorrow

Then just write another piston that compares that to “Full” (or the other global variable @MoonPhaseFull).


#5

That’s perfect. Thank you!