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