Time of Sunrise/Sunset

I got “weahter.state” in my rule to send me that message. Here is the item:

String Weather

And here is the matching rule:

rule "Weather"
	when
		System started or
		Item CommonCondition_0 changed or
		Item Telegram_Test changed
	then
		Weather.postUpdate (transform("MAP","weather_de.map",CommonCondition_0.state.toString()))
end
1 Like

Thanks Andy! that helped me out :slight_smile: - this is my rule now - works fine

var text = "Hallo Philipp! Das Wetter: " + (transform("MAP","astro.map",Condition.state.toString())) + " Temperatur: " + Temp_MinMax_1_Today_WU.state + "°C Feuchtigkeit: " + Luftfeuchtigkeit.state + "% Windgeschwindigkeit: " + Wind_Speed.state + " km/h Sonnenaufgang: " + SunriseString.state + " Uhr Sonnenuntergang: " + SunsetString.state+ " Uhr"

and the last question :smiley: - how could i get 81% Humidity instead of 81,00% in the rule - thanks!

I dont know about that very much - I will have a look into it too, because I got “60.00%” and “90.0%”.

Maybe this is helping us: https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax

Edit: another link: https://en.wikipedia.org/wiki/Printf_format_string

Did you manage to have 81% Humidity?

I ran into another problem when I updated to the 2.2 release build:

[ERROR] [untime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Sunrise- and Sunset-Time for Messages': H != java.lang.String

rule "Sunrise- and Sunset-Time for Messages"
	when
    	System started or
    	Time cron "0 1 0 ? * * *" or
    	Item SunriseTime changed or
		Item SunsetTime changed
	then
    	SunriseString.postUpdate (SunriseTime.state.format("%1$tH:%1$tM"))
    	SunsetString.postUpdate (SunsetTime.state.format("%1$tH:%1$tM"))
end

You had that Error with “M” before… but I do not really know what is wrong there. So many things seem to have changed from 2.1 to 2.2…

Edit: It should be completely correct: https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#dt

have no probs here with 2.2.

Sunrise/Sunset Rule to String

// Umwandeln von DateTime auf String  ( 16:08 Uhr )
rule "Sunrise / Sunset für Pushover"
    when
    	System started or
    	Time cron "0 0 0 * * ?" or
    	Item SunriseTime changed or
		Item SunsetTime changed
    then
      SunriseString.postUpdate (SunriseTime.state.format("%1$tH:%1$tM"))
      SunsetString.postUpdate (SunsetTime.state.format("%1$tH:%1$tM"))
end

Good Morning Message Rule:


rule "Good Morning Message - Philipp"
    when
        Time cron "0 0 11 * * ?"       // Jeden Tag um 11 Uhr
    then    
        var text = "Hallo Philipp! Das Wetter: " + (transform("MAP","astro.map",Condition.state.toString())) + " Temperatur: " + Temp_MinMax_1_Today_WU.state + "°C Feuchtigkeit: " + Luftfeuchtigkeit.state + "% Windgeschwindigkeit: " + Wind_Speed.state + " km/h Sonnenaufgang: " + SunriseString.state + " Uhr Sonnenuntergang: " + SunsetString.state+ " Uhr - Schönen Tag!"
        pushover(text, "myPhone", 0, "", "", "classical")
end