Moon phases?

I see what you did and it's exactly what I needed - and I feel horrible to say it failed for me. just out of the box I got a text string of the URL in my dashboard icon.
I then d/l'd all your images and stored them local in the hubitat file folder /local/. still failed - when I kicked the debug of the page off I see there is no wrapper of an . Looking at your code, I see the additional attribute - but it's looks to me to be missing the IMG component.
I changed line 163 of your driver as follows:
from:
updateAttr("moonPhaseImg", "${iconPath}moon-phase-icon-${imgNum}.png")
to:
updateAttr("moonPhaseImg", "<img class='moonPhase' src='${iconPath}moon-phase-icon-${imgNum}.png'></img>")

Temporary change of course, just to test if maybe I was on the right track and the dashboard tile worked! I greatly appreciate your time and effort and thank you!
Of course I'll be running HPM and if you make mods, i'll be acutely aware. Thx for this -it's really useful!

Ah! You just want an image only tile.... Made the change for you.

Can someone tell me how to display that properly? I added the driver and created a virtual Device but what template do I use in the tile on the dashboard? I am sure this is simple but my first time with a custom driver.

Use the Attribute tile and select either the moonPhaseTile or moonPhaseImg attribute.

That was the first thing I tried but those do not show as attributes for the Moon Phase device. It just has the default attributes such as HSM Status. Is there something else I need to do to see the attributes?

Need to authorize the device to the dashboard app (Apps tab), and then select it as the source device when you add the tile.

Yes it is already. When I go to add a tile I can select the Moon Phase device in my dashboard and then I pick the attribute template but the dropdown doesn't have any moon phase attributes to select.

OK I got it to work. I deleted the tile then went and removed it from the dashboard in settings and redid all the steps and the attributes now work. Sorry for the trouble and Thanks for doing this.

No trouble at all, no telling why it didn’t work the first time, just glad it worked in the end.

Semper Fi

1 Like

I recently discovered the update at midnight doesn't seem to be working for me. I'm not even sure it ever did (he says sheepishly). I use this for a background image to a tile - I know that if I go into the Device and click the 'Get Phase' it updates and looks great - but I checked and unchecked and re-checked the 'Enable automatic update at midnight'. I've turned on my logs and will review tonite at midnight tosee what I can see - pls post up if you have thoughts.

Go to the bottom of the driver and look at the scheduled jobs, there should be one at 1 second past midnight if you have the automatic update turned on.

1 Like

I did actually check that - and it said 'No Scheduled jobs set'. After unchecking and rechecking the 'update and midnight' last night a job scheduled jas as you described. (mine said 'PDT'). I Checked the logs and it executed :slight_smile: must have been a glitch from when I toyed with it previously and I never cleared or flushed or something.
This AM the prev Run time was updated from '------' to '2021-07-03 12:00:01am PDT' and the LastQryDate under Current States also was updated.
All is well - pls file under 'IO error' (Inputting operator).

1 Like

I like that site! Now if I only knew how to write the code to use that for a weather app for my dashboards.. Im using (i think) weather tile now..

I've a new problem that just began. I get
error : Invalid date string use format yyyy-MM-dd HH:mm:ss

I updated to 8.143 last night and have spent all day fixing problems. THe last run was 16 days ago I think when I updated to 8.128 or something. Think this is related to the date problems being found elsewhere?

That change was made some time ago to make the calculation more accurate, but you can use all zeros for the time element if you like; i.e. 2021-07-28 00:00:00

ah. got it. I was pulling the next run time stamp which had the am/pm and Timezone concated. IO error. (inputting operator)

1 Like

Think I found a typo -
In the driver at line 152:

"Last Quater" is missing and r - "Last Quarter"
image
image

Got it, should have a fix out momentarily. Thanks!

Please excuse my ignorance but is midnight the best time to do the update for the phase? If tonight were officially the full moon, then at 00:01 this morning, the phase in the driver would have updated to Full Moon and and be correct when the moon appears tonight. However at 00:01 tonight, the phase would report as Waning even though the moon in the sky is still in fact Full.

I know this sounds petty and I don't know enough about the moon to know when would a moon officially change phases by definition? I am more asking for my curiosity about when moon phases change than about your driver. Plus, with 2 kids, I am rarely up past midnight to compare your driver to the actual moon anyway. :grinning:

I actually debated that fact with myself a couple of times, and almost went with sunset (still wondering if that might be a better time to be honest). Driver will calculate it based on the time ran or the date/time requested so it’s actually an easy change to make (can also run the getPhase() command from RM, etc. at any point).