When is the bad moon rising?

Upon request,I’m trying to show the days until next full moon in a sitemap (and yes, my daughter has been watching too much Teen Wolf :wink: )
On my first try, the rule i put together resulted in massive java errors and i finally needed to shutdown&restart, so i’d like to ask y’all for some advice. What I’ve got so far:

DateTime  Naechster_Vollmond  "Nächster Vollmond [%1$td.%1$tm.%1$tY %1$tH:%1$tM]"  <death_star>    (Astro)   {astro="planet=moon, type=phase, property=full"}
Number Tage_naechster_Vollmond "Tage bis Vollmond: [%s]" <death_star>    (Astro)


Text item=Naechster_Vollmond
Text item=Tage_naechster_Vollmond

da rule:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Math
import java.lang.String
import java.lang.Integer
import org.joda.time.*
import org.openhab.model.script.actions.Timer

rule "Biss zum naechsten mal"
    Item Naechster_Vollmond received update
    postUpdate(Tage_naechster_Vollmond,(Math::round((Naechster_Vollmond.calendar.millis - now.millis) / (86400000.0))))

Sadly, Designer is throwing errors:
Multiple markers at this line

  • Couldn’t resolve reference to JvmIdentifiableElement ‘/’.
  • Couldn’t resolve reference to JvmIdentifiableElement ‘-’.
  • Couldn’t resolve reference to JvmIdentifiableElement ‘millis’.
  • Couldn’t resolve reference to JvmIdentifiableElement ‘calendar’.
  • Couldn’t resolve reference to JvmIdentifiableElement ‘now’.

Does my way of calculation make sense at all? Or do I need a variable to first do the math on and then use that in postUpdate?
System info: Ubuntu 16.04 Server, OH 1.8.3, Oracle Java 1.8

Many thanks in advance,
Best Regards,

NOTE: With the latest OH 1.x Designer it has bascailly lost all knowledge of “now” so while Designer is complaining it likely really does work. At least the math looks right to me.

Thanks, I kind of guessed Designer has a flaw there. Sooo…I will give it a try and report back.

So I’ve uploaded the files.
Trigger Item gets refreshed:

2016-09-14 20:05:50.759 [INFO ] [runtime.busevents             ] - Naechster_Vollmond state updated to 2016-09-16T21:06:00

But the rule doesn’t get fired. I’ve added some loginfo to check that. I guess the update is comming from persistence, not the astro action. Could that be the cause? If so, would it help to issue:
openhab send Naechster_Vollmond 2016-09-16T21:06:00
fromOSGI console?

OK, so I did a restart (after refreshing the sitemap, clients did not update any more - known bug AFAIK)
The rule got executed, but unfortunatly no joy:

Sep 14 20:39:53 JARVIS openhab.sh[10857]: 2016-09-14 20:39:53.873 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Biss zum naechsten mal': The name '<XFeatureCallImplCustom>.calendar' cannot be resolved to an item or type.

Any idea?

Edit: after following change:

(Naechster_Vollmond.state as DateTimeType).calendar.timeInMillis

even Designer doesn’t complain any more. Promising…
Too late for another openhab restart now (takes 20+ minutes and I’ve no clue why: Startup and performance issues ) so I will call it a day and check tomorrow if the Item got populated. I’ll report back…

And we have a winner!
Via OSGI console, I just did a stop/restart of the astro binding and:

[runtime.busevents             ] - Naechster_Vollmond state updated to 2016-09-16T21:06:00
[hab.model.script.diverse.rules] - Berechne Tage bis Vollmond...
[runtime.busevents             ] - Tage_naechster_Vollmond state updated to 1

May you give the full item-/sitemap-list, please?
where do you got the icons from?

regards & thanks



//Astro Items
Group        Astro    <blackhole>    (All)    
DateTime    Sonnenaufgang_Time    "Sonnenaufgang [%1$tH:%1$tM]"       <sun>        (Astro)        { astro="planet=sun,type=rise,property=start" }
DateTime    Sonnenuntergang_Time    "Sonnenuntergang [%1$tH:%1$tM]"        <sun>        (Astro)        { astro="planet=sun, type=set, property=end" }
DateTime    Mondaufgang_Time    "Mondaufgang [%1$tH:%1$tM]"         <death_star>    (Astro)        { astro="planet=moon, type=rise, property=start" }
DateTime    Monduntergang_Time    "Monduntergang [%1$tH:%1$tM]"       <death_star>    (Astro)        { astro="planet=moon, type=set, property=end" }
String        Mondphase            "Mondphase [MAP(moon.map):%s]"      <death_star>    (Astro)        { astro="planet=moon, type=phase, property=name" }
DateTime  Naechster_Vollmond  "Nächster Vollmond [%1$td.%1$tm.%1$tY %1$tH:%1$tM]"  <death_star>    (Astro)   {astro="planet=moon, type=phase, property=full"}
Number Tage_naechster_Vollmond "Tage bis Vollmond: [%s]" <death_star>    (Astro)
String        Sternzeichen            "Sternzeichen [MAP(zodiac.map):%s]" <symbol>        (Astro)        { astro="planet=sun,type=zodiac, property=sign" }
String        Jahreszeit            "Jahreszeit [MAP(season.map):%s]"   <sun>        (Astro)        { astro="planet=sun, type=season, property=name" }


        Group item=Astro label="Astrolab" icon="blackhole"  {
            Text item=Sonnenaufgang_Time            
            Text item=Sonnenuntergang_Time            
            Text item=Mondaufgang_Time            
            Text item=Monduntergang_Time            
            Text item=Mondphase    
            Text item=Naechster_Vollmond
            Text item=Tage_naechster_Vollmond
            Text item=Sternzeichen            
            Text item=Jahreszeit            

As for the icons- I gathered them on the Net putting them ancient hunter/collector genes to good use :slight_smile: If you search for “icons png 32x32 iconname” you should find most of them. Even though they are all freely available for personal use, I’ll refrain from posting them here as I don’t want the Site Admins receiving letters for Copyright infringement from some cheese lawyer chasing a quick buck.

Thanks man.

may i ask also for season.map, zodiac.map, moon.map?

Aries=♈ Widder
Taurus=♉ Stier
Gemini=♊ Zwilling
Cancer=♋ Krebs
Leo=♌ Löwe
Virgo=♍ Jungfrau
Libra=♎ Waage
Scorpio=♏ Skorpion
Sagittarius=♐ Schütze
Capricorn=♑ Steinbock
Aquarius=♒ Wassermann
Pisces=♓ Fisch


New=🌑 Neumond
Waxing_Crescent=🌑→🌓 zunehmender Halbmond
First_Quarter=🌓 erstes Viertel
Waxing_Gibbous=🌓→🌕 zunehmender Mond
Full=🌕 Vollmond
Waning_Gibbous=🌕→🌗 abnehmender Mond
Third_Quarter=🌗 letztes Viertel
Waning_Crescent=🌗→🌑 abnehmender Halbmond

Null=unbekannt ⁉

i found this … but the upper-/lower-case is not correct …

but, how you calc the next full moon?

I think the format of the map files depends on your OH version (OH1 or OH2).
For OH1, look here: https://github.com/openhab/openhab/wiki/Astro-binding
For OH2…sry, I’m out. No clue.
For full moon calculation just read Posts 1 to 5…

i think it is working right now.
the dates and times for sun-/moon-rise/-set are they for the act. day or for tomorrow?
if for today, is it possible to get this for tomorrow (or more future days)?

The times are calculated each midnight and are for the current day and the longitude/latidute you have in your config.
If you look at the Link to the Astro Binding, you can create Switches that get triggered with an offset in minutes from e.g. sunset. So maybe you can also create an additional DateTime Item for sunset with an offset of…ehm.hour has 60 mins…24 hours…1440 minutes to get tomorrow’s sunset, something like:

DateTime    Sonnenaufgang_Morgen_Time    "Sonnenaufgang Morgen [%1$tH:%1$tM]"       <sun>        (Astro)        { astro="planet=sun,type=rise,property=start",offset=1440}

Give it a try…worst case the Item doesn’t get updated, I guess.

it seemed not be working …

it show 7:03 for sun rise but it google tells 7:04 … for tomorrow.

may be it would be calculated correctly at midnight …

Well if it’s different(and later) than the value for today it should be OK. Basically the value that is now shown for tomorrow should match the “standard” sunset value you will see after recalc. I would watch this for couple days if the change pattern is right.

The offset parameter will be added to the result of calculation, so this item will show the sun rise of today (with date of tomorrow).

@udo, that seemed to be right.

this are the things i hate the most …

openhob.log: Could not find a mapping for ‘Aries’ in the file ‘astro_de.map’.

some post before i posted my map-file.

season is displayed well, sun’s zodiac is displayed well, phase is displayed well, but moon’s zodiac raises this error…
yesterday it worked without errors …

@Udo_Hartmann : thanks for clarification; it was worth a try i guess :grin:
@FyingEaglE : I would double-check that a) Item definition points to the right file b) that there is no odd typo in the file. Something like a space or other special char before or after “Aries”

i can’t find any typo or special chars …

So you are using one map file (astro_de.map) for all your astro items?
All other Items are “translated” OK?
Unfortunatly it’s not possible to set another Astro item to “Aries” via OSGI console(tried but they are read only) so I can’t think of another way how you could verify your entries.

yes, one file for all, yesterday it worked fine.
i found out, if i write Aries=Widder, then it worked. but if i write Aries=♈ Widder (as before) it wont work.