We have moved at community.getvera.com

Author Topic: [_CODE_] DAD - Display of Astronomical Data V1.2  (Read 84151 times)

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
[_CODE_] DAD - Display of Astronomical Data V1.2
« on: January 25, 2011, 10:22:55 am »
EOL, unsupported.

http://bugs.micasaverde.com/view.php?id=1451

WARNING:
There is a bug in the firmware for Vera V2 (including 1.1.1338) which leads to wrong calculations due to rounding errors (the Lua implementation uses 'float' instead of 'double'). You are definitely affected by the bug, if the seconds for moonrise and/or moonset are different from '00'. Vera V1 users should be fine.



DAD displays the times for sunrise/sunset and moonrise/moonset, the current zodiac sign and the current moon phase on the GUI.

DAD provides the following times as UPnP variables (format: Unix timestamp and Human Understandable Format (HUF)) via UPnP service urn:upnp-ap15e-com:serviceId:DAD1:

  • astronomical/nautical/civil twilight begin/end
  • sunrise/sunset
  • moonrise/moonset
  • fraction of the moon illuminated at midnight/noon

DAD provides the following radiation data as UPnP variables (Germany only):

  • postcode and name of station
  • height of station AMSL
  • status of station
  • total equivalent dose rate
  • user defined threshold for total equivalent dose rate
  • flag for total equivalent dose rate above threshold

DAD provides the following earthquake data as UPnP variables:

  • region
  • date (UTC, local time, Unix timestamp)
  • link to map
  • magnitude
  • location (latitude, longitude, depth)
  • distance
  • table of raw earthquake data

DAD provides the following Luup events:

  • astronomical/nautical/civil twilight begin/end
  • sunrise/sunset
  • moonrise/moonset
  • possible impact of asteroid

  • total equivalent dose rate above/below user defined value
  • total equivalent dose rate above user defined threshold

  • distance from earthquake less than user-defined value
  • magnitude of earthquake greater than user-defined value

Dashboard layout for UI5:
Code: [Select]
                    [sunrise]        [sunset]

                    [moonrise]       [moonset]

[earthquake region] [magnitude]      [distance]

[total dose rate]   [station status] [zodiac sign]



Installation:
  • Upload the six files from the ZIP file to your box: 'MiOS Developers' -> 'Luup files' -> 'Upload files',
  • check 'Restart Luup after upload', click 'Go', wait for Lua to restart,
  • 'Create device' tab-> 'UpnpDevFilename': D_DAD_UI5.xml for UI5, D_DAD_UI4.xml for earlier UI versions -> click 'Create device',
  • restart the Lua engine several times to initialise the UPnP variables,
  • German users: go to http://odlinfo.bfs.de/laenderliste.php, select your state, set the UPnP variable DoseRateStationURL to the URL for your state, and set the UPnP variable DoseRateStationID to the 'Kennung' of the station nearest to your location,
  • restart the Lua engine several times to initialise the UPnP variables,
  • European users: set the UPnP variable EarthquakeProviderEU to 1 and restart the Lua engine.
  • Displaying icons for the moon phases: install/configure http://www.quivira-font.com/files/Quivira.ttf for your web client, set the UPnP variable DisplayMoonPhase to 1 and restart the the Lua engine. If the moon icon shows up as a rectangle, set DisplayMoonPhaseFont to Quivira (or to whatever font you are using for displaying moon phases) and restart the Lua engine. Please note that setting DisplayMoonPhaseFont to a non-empty string triggers bug http://bugs.micasaverde.com/view.php?id=1447.

Limitations:
  • DAD makes extensive use of Luup timers: all limitations of Luup timers apply to DAD.
  • DAD won't work for dates after 2038-01-19 (see http://forum.micasaverde.com/index.php?topic=5776.0).
  • Currently, events do not work for UPnP variables with floating point values (see http://bugs.micasaverde.com/view.php?id=1444).
  • The zodiac sign may be off by two days.
  • When the EarthquakeDistance event fires, the earthquake data set is consistent, when the EarthquakeMagnitude event fires, the earthquake data set is guaranteed to be inconsistent :( (see http://forum.micasaverde.com/index.php?topic=6213.0).
  • The update interval for radiation data is 24 hours.
  • The update interval for earthquake data is 5 minutes (DAD will miss earthquakes, which are less than 5 minutes apart).
  • Do not base your decisions on the radiation/earthquake data from DAD.

Download:
https://docs.google.com/open?id=0Bz4omZm4gYcsMGE3NzAyYzMtOWYxZC00NDQxLThjOWUtNTc3MzBiNzM5NDdj

Edit:
V0.02 adds support for civil, nautical, and astronomical twilight (see DAD_Advanced.jpg)
V0.03 adds support for moonrise and moonset (via U.S. Naval Observatory - Astronomical Applications Department)
V0.04 cosmetic changes
V0.05 bugfix for more than one moonrise/moonset per day (thanks to JOD), new variable DAD_USNO_URL
V0.06 bugfix for moorise/moonset for locations west of Greenwich (thanks to JOD)
V0.07 last ;) bugfix for moonrise/moonset, adds fraction of the moon illuminated for midnight and noon
V0.08 adds load-balancing for all users within a specific timezone
V0.1   adds Luup events for astronomical/nautical/civil twilight, sunrise/sunset, moonrise/moonset, and possible impacts of asteroids
V0.11 adds equivalent dose rate for about 1800 locations in Germany (see http://odlinfo.bfs.de/)
V0.11a fix for new ODL number format ...
V0.12 adds data for earthquakes (see http://earthquake.usgs.gov/earthquakes/catalogs/eqs1hour-M0.txt)
V0.13 BETA adds Luup events for radiation and earthquakes
V0.14 bugfix for DST issue (thanks to futzle for finding and fixing the bug)
V1.0   bugfix for DST issue for days on which the clocks shift (thanks to futzle for the suggestion), local time for latest earthquake
V1.0a bugfix for local time for latest earthquake ...
V1.0b bugfix for moon illumination for the West, 'workaround' for Y2K38 bug (thanks to oTi@ for finding and fixing the bugs)
V1.0c bugfix for pattern matcher for timestamp of last earthquake
V1.0d adds support for earthquake data from http://www.seismicportal.eu/
V1.0e adds more robustness against error conditions and makes sure that the earthquake data set for the distance event is consistent (the earthquake data set for the magnitude event is inconsistent, this is a limitation of MiOS, see http://forum.micasaverde.com/index.php?topic=6213.0)
V1.0f adds support for zodiac signs
V1.0g adds support for moon icons that correspond to the moon phase
V1.0h bugfix for moon phases for the South (thanks to futzle)
V1.0i Unicode workaround for browser quirks (Chrome, IE, Safari) (thanks to oTi@ for the suggestion and for beta-testing)
V1.0j fix for new ODL site structure; change microSv/h to nSv/h (workaround for MiOS bug #1444);
        remove variables Message and EarthquakeRawData from lu_sdata (as requested by TimAlls);
        change the thresholds for moon illumination from 1/49/51/99 to 3/47/53/97 (as suggested by futzle)
V1.1  adds support for UI5: new variables Sunrise_HHMMSS, Sunset_HHMMSS, Moonrise_HHMMSS, Moonset_HHMMSS, MoonIcon, ZodiacSign
V1.2  bugfix for sunset events earlier than sunrise events (thanks to dchoe and CMRancho for finding the bug)
« Last Edit: May 08, 2012, 12:52:46 pm by Ap15e »

Offline mcardenas

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +0/-0
Re: DAD V0.01 - Display of Astronomical Data
« Reply #1 on: January 25, 2011, 11:13:29 am »
Hey Ap,

You always came with cool and useful plugins. Thanks!

Offline saf101

  • Sr. Newbie
  • *
  • Posts: 40
  • Karma: +0/-0
Re: DAD V0.01 - Display of Astronomical Data
« Reply #2 on: January 25, 2011, 02:26:33 pm »
AP

Thank you pretty cool

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: DAD V0.03 - Display of Astronomical Data
« Reply #3 on: January 26, 2011, 11:28:51 am »
V0.03 adds support for moonrise and moonset.

Offline JOD

  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: DAD V0.04 - Display of Astronomical Data
« Reply #4 on: January 27, 2011, 02:49:06 pm »
Ap15e,

I added this yesterday. I get sunrise / set but not moonrise / set. Is that related to this link?
http://forum.micasaverde.com/index.php?topic=5482.0

JOD.

I'm sorry, my responses are limited. You must ask the right questions.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: DAD V0.04 - Display of Astronomical Data
« Reply #5 on: January 27, 2011, 03:03:26 pm »
There are days without moonrise and without moonset ...

Please check the data at:
http://aa.usno.navy.mil/data/docs/RS_OneYear.php

Offline JOD

  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: DAD V0.04 - Display of Astronomical Data
« Reply #6 on: January 27, 2011, 03:16:15 pm »
Both days, yesterday and today has data.

Jan 26  0026 1137

Jan 27  0130 1223

JOD.
I'm sorry, my responses are limited. You must ask the right questions.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: DAD V0.04 - Display of Astronomical Data
« Reply #7 on: January 27, 2011, 03:34:57 pm »
Thanks for checking.

Please add luup.log(url) to I_DAD.xml just after the statement local url = ... and please send me the url.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: DAD V0.04 - Display of Astronomical Data
« Reply #8 on: January 28, 2011, 06:02:46 am »
There are days with more than one moorise/moonset, e. g.:

http://aa.usno.navy.mil/cgi-bin/aa_rstablew.pl?FFX=2&xxy=2011&type=1&place=&xx0=-1&xx1=117&xx2=38&yy0=1&yy1=81&yy2=8&zz0=-1&zz1=11&ZZZ=END

DAD V0.04 assumes that there is one line per day. This may explain JOD's problem.
Will be fixed with DAD V0.05.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: DAD V0.04 - Display of Astronomical Data
« Reply #9 on: January 28, 2011, 06:37:31 am »
Please upgrade to DAD V0.05 (contains a bugfix for moonrise/moonset).

@JOD
Please send me the value of the DAD_USNO_URL variable from the 'Advanced' tab, if your problem persists.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: DAD V0.06 - Display of Astronomical Data
« Reply #10 on: January 28, 2011, 12:49:29 pm »
Please upgrade to V0.06 (contains a bugfix for moorise/moonset for locations west of Greenwich (thanks to JOD)).

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: DAD V0.07 - Display of Astronomical Data
« Reply #11 on: January 28, 2011, 07:12:34 pm »
Please upgrade to V0.07 (contains the last ;) bugfix for moonrise/moonset and adds 'fraction of the moon illuminated' for midnight and noon.

Save energy, no need to switch on the outdoor lights if the moon is lit and the sky is clear:

Code: [Select]
local moon_delay         = 1800  -- activate moon_delay seconds after moonrise/up to moon_delay seconds before moonset
local illu_threshold     =   80  -- activate if illumination >= illu_threshold

local moon_rise          = luup.variable_get( 'urn:upnp-ap15e-com:serviceId:DAD1'          , 'Moonrise'                , 16847 )
local moon_set           = luup.variable_get( 'urn:upnp-ap15e-com:serviceId:DAD1'          , 'Moonset'                 , 16847 )
local moon_illu          = luup.variable_get( 'urn:upnp-ap15e-com:serviceId:DAD1'          , 'MoonIlluminationMidnight', 16847 )
local weather_condition  = luup.variable_get( 'urn:upnp-micasaverde-com:serviceId:Weather1', 'Condition'               , 16824 )

local moon_rise = tonumber( moon_rise )
local moon_set  = tonumber( moon_set  )
local moon_illu = tonumber( moon_illu ) or 0

local current_time       = os.time()

return  luup.is_night()
       and
         (  not ( ( moon_illu >= illu_threshold ) and ( weather_condition == 'Clear' ) )
           or
            (  ( ( moon_rise == nil ) and ( moon_set == nil ) ) -- no moonrise and no moonset today; we do not know where the moon is ...
              or
               ( ( moon_rise == nil ) and ( moon_set ~= nil ) and ( current_time > moon_set - moon_delay ) )
              or
               ( ( moon_rise ~= nil ) and ( moon_set == nil ) and ( current_time < moon_rise + moon_delay ) )
              or
               ( ( moon_rise ~= nil ) and ( moon_set ~= nil ) and ( current_time < moon_rise + moon_delay ) and ( current_time > moon_set - moon_delay ) )
            )
         )

Requirements:

MCV,

what about adjusting the moon image in the banner to the illumination, if DAD is installed?
« Last Edit: April 08, 2011, 01:51:45 pm by Ap15e »

Offline JOD

  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: DAD V0.08 - Display of Astronomical Data
« Reply #12 on: January 29, 2011, 12:41:19 pm »
Ap15e,

V0.07 worked. Thank you.

JOD.
I'm sorry, my responses are limited. You must ask the right questions.

Offline CMRancho

  • Hero Member
  • *****
  • Posts: 1008
  • Karma: +1/-0
Re: DAD V0.08 - Display of Astronomical Data
« Reply #13 on: January 30, 2011, 08:17:14 pm »
@Ap15e: I installed this according to your directions, and much to my surprise, it works! Maybe these Luup thingamabobs of yours aren't as crazy as I thought.

Thanks for sharing your work with me!
Vera123beta; Schlage, Kwikset, TZEMT400; Linksys cams, Smarteye cams, HSM100; Aeon, Everspring, Cooper, Leviton, Intermatic, FortrezZ, Global Caché, USB-UIRT, Somfy, etc.

Offline anthonyris

  • Sr. Member
  • ****
  • Posts: 250
  • Karma: +6/-1
Re: DAD V0.08 - Display of Astronomical Data
« Reply #14 on: February 03, 2011, 12:09:24 pm »
@Ap15e: another happy customer... v0.08 worked perfectly.

You should have the icon change to be the current zodiac sign... hehe ;-)

.//A.
Vera3x2, Leviton, GE dimmers, relays and lamp modules, Sonos, Nests...