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 )
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:
Items:
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)
Sitemap:
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"
when
Item Naechster_Vollmond received update
then
postUpdate(Tage_naechster_Vollmond,(Math::round((Naechster_Vollmond.calendar.millis - now.millis) / (86400000.0))))
end
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
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.
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
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 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.
Cheers,
-OLI
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:
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.
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 @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”
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.