Announcement

Collapse
No announcement yet.

Moon phases download

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Moon phases download

    Hi all...So my son, who is 7, got a nice telescope from Santa. He has so much interest in the moon, we are waiting for the clear sky promised tonight and the waxing crescent. However, I just realized that the moon phases are no longer downloading. I have an HStouch tablet he uses to look at and is so excited.

    The last download was sometime in October. It looks like the naval observatory site is undergoing reconstruction and I believe that's where weather XML gets the info.

    Is that a correct assumption? If so is there a way to get moon phase data from another source?
    however, I just realized that the moon phases are no longer downloading. The last download was sometime in October. It looks like the naval observatory site is undergoing reconstruction and I believe that's where weather XML gets the info.

    Is that a correct assumption? If so is there a way to get moon phase data from another source?

    Is there a replacement URL I can use? I am also thinking of using an alternate API that supplies thendata, but I would need to then make it accessible to WeatherXML. I am savvy enough, but need to know if there is a way to get weatherXML to look for it elsewhere.

    Ideas?

    #2
    Try this,
    Script goes in your scripts folder,
    Moons folder in \html\Images
    Create an event to run the script once a day. Populates a device called "Almanac Moon Phase" which you'll need to create: Location = Almanac, Device Name = Moon Phase. (Can be changed in the script if you want).
    I've been using this for years. Pay attention to the notes at the top of the script for other instructions.

    Click image for larger version  Name:	2019-12-30 13_32_08-HomeSeer Web Control.png Views:	0 Size:	19.5 KB ID:	1350559Click image for larger version  Name:	2019-12-30 13_32_08-HomeSeer Web Control.png Views:	0 Size:	19.5 KB ID:	1350560
    Attached Files
    Real courage is not securing your Wi-Fi network.

    Comment


      #3
      In weatherXML you can download images and even put them in rotation.

      You could create a custom page on HSTouch and have it display an HTML page until the data returns.

      One such URL is: https://www.moongiant.com/phase/today/Or you can run a browser on the tablet which goes directly to the page and displays over HSTouch. There is also a google app that is called Moon Phase Calendar.

      https://nightsky.jpl.nasa.gov/planner.cfm - this is a sight which might help him with his planning. There is also earthsky.org

      You can download a poster here that shows the moon phase for all of 2020. https://earthskystore.org/collection...lunar-calendar

      I am excited for him. There is nothing more infectious than the enthusiasm of a 7 yr old.

      Comment


        #4
        If you happen to be running on Linux you will need to change the backslash \ in the path to a "/" in the script.

        Comment


          #5
          Originally posted by AllHailJ View Post
          If you happen to be running on Linux you will need to change the backslash \ in the path to a "/" in the script.
          My script? Yeah, I've been doing a lot of that actually. This is one I used in HS2 for years and only use on a Windows machine with 3. I'll fix it now and re-up.

          done.
          Real courage is not securing your Wi-Fi network.

          Comment


            #6
            This is awesome! Thanks guys. Simple fix. I totally agree about my son son infecting me with renewed life. We have a 32 and 31 year old. Mom and I thought we were done after trying for a third child for a long time. We gave up and 20 years later Momma says, I think I am pregnant. So as he turns 8 tomorrow, I turn 55 in March. All three kids born on Holidays... First one July 4th, Second was Sept. 7 an it was labor day the year of his birth, and then finally Ethan on 12/31, on NYE.

            Comment


              #7
              Originally posted by Wadenut View Post

              My script? Yeah, I've been doing a lot of that actually. This is one I used in HS2 for years and only use on a Windows machine with 3. I'll fix it now and re-up.

              done.
              I also noticed that Homeseer should be HomeSeer and Images should be images for linux or you need to add symbolic links.

              NacMan - My children are grown as well but I remember the age fondly.

              Comment


                #8
                I took a different approach to this and had the script do less and the device do more.

                The updated script is below
                -----------------------------------------
                Sub Main(Parm as Object)

                ' Set Moon Icon (age_moon.txt)
                ' (c) 2000 by Eric L. Jilot, eric@jilot.net, http://www.jilot.net
                ' Permission to distribute intact, and to use, granted to anyone
                '
                Dim MoonDev As String = "Almanac Moon Phase" ' Optional device to contain the current moon phase string
                Dim intYear,intMonth,intDay,MoonNum As Integer
                Dim intJulian,YY,MM,K1,K2,K3 As Double

                intYear = year(now)
                intMonth = month(now)
                intDay = day(now)

                YY = intYear - Int((12 - intMonth) / 10)
                MM = intMonth + 9
                If MM >= 12 Then MM = MM - 12
                K1 = Int(365.25 * (YY + 4712))
                K2 = Int(30.6 * MM + 0.5)
                K3 = Int(Int((YY / 100) + 49) * 0.75) - 38

                ' JD for dates in Julian calendar
                intJulian = K1 + K2 + intDay + 59

                ' For Gregorian calendar
                If intJulian > 2299160 Then intJulian = intJulian - K3
                intJulian = (intJulian - 2451550.1) / 29.530588853
                intJulian = intJulian - Int(intJulian)
                If intJulian < 0 Then intJulian = intJulian + 1


                ' Populate Device
                MoonNum = Int(intJulian * 29.530588853)

                hs.SetDeviceValueByName(MoonDev,MoonNum)

                End Sub

                -------------------------------------------------------------------------------------------------

                I then modified the device to have 31 status text and status graphics. Partial shots are below

                Click image for larger version

Name:	Screenshot from 2019-12-31 11-45-45.png
Views:	214
Size:	184.9 KB
ID:	1350845

                Now the graphics

                Click image for larger version

Name:	Screenshot from 2019-12-31 11-46-15.png
Views:	168
Size:	127.7 KB
ID:	1350846

                I downloaded the graphics so the moon looked more real. I added to HS Touch on my local weather page and wrote an event to run the script every morning at 03:00.

                For the indeterminate case I did a jpg of most of the moons so I would know there was a problem.

                Thanks to all who contributed as I learned some things and I now have the moon phase in my project. Way Cool!!!!!!

                Comment


                  #9
                  I did something similar, as I had the graphics in a folder from weatherXML. weatherXML stopped updating the moon phase when weather underground changed. So I just modified the script to use the device that weatherXML had created, because it had all the value/status pairs, like the above. The script just puts the value into the device, no need to copy and delete the sunset.gif icon. I did leave in the moonstring code, because for some reason that wouldn't change with the change of value/status. It is working well.
                  Thanks to Wadenut for the script to modify.
                  Here are my modifications as well:

                  Sub Main(Parm as Object)

                  ' Set Moon Icon (age_moon.txt)
                  ' (c) 2000 by Eric L. Jilot, eric@jilot.net, http://www.jilot.net
                  ' Permission to distribute intact, and to use, granted to anyone

                  ' Converted to VB.net 06/2009 Wadenut

                  Dim MoonDev As Integer = 54 <------my weatherXML device

                  Dim strPath,strCurrent,MoonStr As String
                  Dim intYear,intMonth,intDay,MoonNum As Integer
                  Dim intJulian,YY,MM,K1,K2,K3 As Double

                  strPath = hs.GetAppPath
                  intYear = year(now)
                  intMonth = month(now)
                  intDay = day(now)

                  YY = intYear - Int((12 - intMonth) / 10)
                  MM = intMonth + 9
                  If MM >= 12 Then MM = MM - 12
                  K1 = Int(365.25 * (YY + 4712))
                  K2 = Int(30.6 * MM + 0.5)
                  K3 = Int(Int((YY / 100) + 49) * 0.75) - 38

                  ' JD for dates in Julian calendar
                  intJulian = K1 + K2 + intDay + 59

                  ' For Gregorian calendar
                  If intJulian > 2299160 Then intJulian = intJulian - K3
                  intJulian = (intJulian - 2451550.1) / 29.530588853
                  intJulian = intJulian - Int(intJulian)
                  If intJulian < 0 Then intJulian = intJulian + 1

                  ' build a filename
                  strCurrent = strPath + "/html/images/weatherXML/moon/moon" & Int(intJulian * 29.530588853) & ".gif" <--------my path to the graphics folder

                  ' verify file exists
                  If Not System.IO.File.Exists(strCurrent) Then
                  hs.WriteLog("Web", "Moon file " + strCurrent + " missing!")
                  Exit Sub
                  End If

                  ' Populate Device

                  MoonNum = Int(intJulian * 29.530588853)

                  If MoonDev <> 99 Then <-----------------always true since my device is number 54
                  Select Case MoonNum
                  Case 0
                  MoonStr = "New Moon"
                  Case 1
                  MoonStr = "Waxing Crescent"
                  Case 2
                  MoonStr = "Waxing Crescent"
                  Case 3
                  MoonStr = "Waxing Crescent"
                  Case 4
                  MoonStr = "Waxing Crescent"
                  Case 5
                  MoonStr = "Waxing Crescent"
                  Case 6
                  MoonStr = "Waxing Crescent"
                  Case 7
                  MoonStr = "First Quarter"
                  Case 8
                  MoonStr = "Waxing Gibbous"
                  Case 9
                  MoonStr = "Waxing Gibbous"
                  Case 10
                  MoonStr = "Waxing Gibbous"
                  Case 11
                  MoonStr = "Waxing Gibbous"
                  Case 12
                  MoonStr = "Waxing Gibbous"
                  Case 13
                  MoonStr = "Waxing Gibbous"
                  Case 14
                  MoonStr = "Full"
                  Case 15
                  MoonStr = "Waning Gibbous"
                  Case 16
                  MoonStr = "Waning Gibbous"
                  Case 17
                  MoonStr = "Waning Gibbous"
                  Case 18
                  MoonStr = "Waning Gibbous"
                  Case 19
                  MoonStr = "Waning Gibbous"
                  Case 20
                  MoonStr = "Waning Gibbous"
                  Case 21
                  MoonStr = "Third Quarter"
                  Case 22
                  MoonStr = "Waning Crescent"
                  Case 23
                  MoonStr = "Waning Crescent"
                  Case 24
                  MoonStr = "Waning Crescent"
                  Case 25
                  MoonStr = "Waning Crescent"
                  Case 26
                  MoonStr = "Waning Crescent"
                  Case 27
                  MoonStr = "Waning Crescent"
                  Case 28
                  MoonStr = "Waning Crescent"
                  Case 29
                  MoonStr = "New Moon"
                  Case Else
                  MoonStr = "indeterminate."
                  End Select
                  End If

                  hs.WriteLog("Web", "Moon Phase: " + MoonStr ) <----------just for testing

                  hs.setDeviceValueByRef(MoonDev,MoonNum,true)
                  hs.SetDeviceString(54,MoonStr,true)

                  End Sub

                  Bruce

                  Comment


                    #10
                    After running this I found a problem with the script. The script actually gives todays moon irrespective of the hour.

                    I checked online and for Colorado today (meaning tonight) it should be a 1/4 moon. Instead I got waxing crescent. To fix this I changed the following line to my corrected line

                    --> Original line --- intDay = day(now)
                    --> Corrected line --- intDay = Math.Round((day(now) + hour(now)/24),0)

                    essentially this makes the day run from noon to noon. If you execute the event twice a day it should keep you correct.

                    Comment

                    Working...
                    X