Remember that gets evaluated just one time only, when the rule file loads.
If you want something to update. do it in a rule
Remember that gets evaluated just one time only, when the rule file loads.
If you want something to update. do it in a rule
Hey rossko, thank you for that hint!
I got it working with the answer from @Udo_Hartmann. (did it via VPN - was so excited)
My rule is now:
rule "Good Morning Message"
when
Time cron "0 15 7 ? * MON,TUE,WED,THU,FRI *" or
Time cron "0 0 9 ? * SUN,SAT *"
then
logInfo("GoodMorningMessage","Sending the message now")
sendTelegram("BotAndy", "Guten Morgen Andreas!\n\nHeute ist "+WeekdayName.state+", der "+now.getDayOfMonth.intValue+"."+now.getMonthOfYear.intValue+"."+now.getYear.intValue+".\n\nDas Wetter: "+Weather.state+"\nMin/Max Temperatur: "+Temperature_MinMax_0.state+"°C\nFeuchtigkeit: "+Humidity_0.state+"%\nNiederschlagswahr.: "+Precip_Probability_0.state+"%\n\nSonnenaufgang: "+SunriseString.state+"\nSonnenuntergang: "+SunsetString.state+"\n\nSchönen Tag wünscht openHAB!")
end
Any ideas about the Intruder alarm?
Greetings
Andy
Thanks for jumping in @Udo_Hartmann.
I wanted to answer but test everything here at my home before, just to be sure with everything.
I hadn’t yet the time to do so.
Hey guys,
I just received the message and today is the sunset at “18:9”.
Is it possible to add the 0 to have “18:09”?
Should be with “if iSunsetMinute < 2 characters, then “0”+dtSunset.getMinuteOfHour” (at least I think so). I will search for something helping me here
Greetings
Andy
Try it in with:
SunriseString.postUpdate (SunriseTime.state.format("%1$tH:%1$M")
Hey Jürgen,
thank you for your input. I got it working with the following:
rule "Sunrise-/set-Time for Messages Test"
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
I added a “t” at the Minutes and a bracket at the end of the string. Now it shows:
“Sonnenaufgang: 08:18
Sonnenuntergang: 18:09”
Thank you!
Sorry for for those typos. Doing that on small Smartphone, while trying to the info via the ConnectBot app from the system at home is asking for such .
Glad you got that.
I’m still thinking about your Intrusion Alert rules. I do not understand where you (believe to ) have problems.
I do see a problem with an intruder switching a light on, which would result in NigthMode OFF and then IntrusionAlarm OFF.
No problem - just added that for anybody, who wants to have that message too.
What I did not try at the moment is to just put “SunriseTime.state.format(”%1$tH:%1$tM")" in the message, that way you would not need that extra rule I guess?
I think the Intrusion Alert has the following problems:
I would just place a timer in the rule to cancel the Sleep Mode, so that opening or closing an “important sensor (front door, balcony door + windows)” will result in an alarm even with lights turned on in the same second. But I am pretty unsure if that really works out.
Later on I want to connect my cameras too to have them only record when the bell rings and sleep or away mode are on. I already have a tablet at home that I will stick to the wall. Want to have a keypad on HABpanel to deactivate the away mode (~30 seconds when opening the front door, otherwise alarm).
It is like my first step to build a bigger security system (still need to find out how to connect my bell to openHAB, but that is another matter).
I will split this thread up - have here the time of sunrise/sunset for the message and marked as solve and in another thread the intruder alarm; makes more sense I guess for people searching for it.
Edit: Here is the new thread with the intruder alarm - Intruder alarm.
hi,
i tried Udo’s and DaAndy’s rule too:
rule "Sunrise/Sunset Time für Pushover"
when
System started or
Time cron "0 30 14 * * ?" or
Time cron "0/5 * * * * ?" or
Item SunriseTime changed or
Item SunsetTime changed
then
val dtSunrise = new DateTime(SunriseTime.state.toString)
val dtSunset = new DateTime(SunsetTime.state.toString)
val iSunriseHour = dtSunrise.getHourOfDay
val iSunsetHour = dtSunset.getHourOfDay
val iSunriseMinute = dtSunrise.getMinuteOfHour
val iSunsetMinute = dtSunset.getMinuteOfHour
SunriseString.postUpdate(iSunriseHour.toString+":"+iSunriseMinute.toString)
SunsetString.postUpdate(iSunsetHour.toString+":"+iSunsetMinute.toString)
logInfo(SunriseString.state.format("%1$tM:%1$tH"))
logInfo(SunsetString.state.format("%1$tM:%1$tH"))
end
i get this output in my sitemap and i have the “t” in front of M & H:
16:8 (should be 16:08)
and i get this in my log:
Error during the execution of rule Sunrise/Sunset Time für Pushover: M != java.lang.String
i also tried the @DaAndy’s short version of the rule @post11 with the same log output
rule "Sunrise/Sunset Time für Pushover"
when
System started or
Time cron "0 30 14 * * ?" or
Time cron "0/5 * * * * ?" 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
what am i missing ? thanks
Hey Philipp,
the rule is working for me without any problems; since this thread was solved.
I will have a look at it and post it here, when I am at home.
Greetings
Andy
Edit: Is that logInfo working in your first rule? I am using it with logInfo(“RuleName”,“State to show”)
Did you put your log also to that other rule??
Only thought so, because the time is even switched: logInfo(SunriseString.state.format("%1$tM:%1$tH"))
And I guess “M” is not defined then - but only my guess with little knowledge.
Edit 2: Maybe try the following as loginfo: logInfo(“Sun-Time”,"Sonnenaufgang: "+SunriseTime.state+"Sonnenuntergang: "+SunsetTime.state)
i deleted the LogInfo and now all is fine - thanks
how could i get the transform map (into german) working for the weather condition ? like this:
“Wetterverhältnisse [MAP(astro.map):%s]”
thanks
off-topic: would you use Telegram or Pushover for notifications ?
Hey Philipp,
sorry for my late reply - I was busy yesterday.
I will try to have a look at my setup this evening to tell you how to translate them.
Right now I am using Telegram, but I did not look at Pushover; guess I will look at it this weekend too, because I just installed it to use it for openHAB and I normally use Threema in daily life.
Here we go:
String CommonCondition_0 "[MAP(weather_de.map):%s]" {weather="locationId=home, type=condition, property=commonId"}
thunder=Gewitter
storm=Sturm
rain-and-snow=Regen und Schnee
rain-and-sleet=Regen und Schneeregen
snow-and-sleet=Schnee und Schneeregen
freezing-drizzle=Gefrierender Nieselregen
few-showers=Nieselregen
freezing-rain=Gefrierender Regen
rain=Regen
snow-flurries=Schneegestöber
light-snow=Leichter Schneeschauer
blowing-snow=Schneetreiben
snow=Starker Schneefall
sleet=Schneeregen
dust=Staub
fog=Neblig
wind=Stürmisch
cold=Kalt
cloudy=Bewölkt
mostly-cloudy-night=Überwiegend Bewölkt (Nacht)
mostly-cloudy-day=Überwiegend Bewölkt
partly-cloudy-night=teilweise Bewölkt (Nacht)
partly-cloudy-day=teilweise Bewölkt
clear-night=Klare Nacht
sunny=Sonnig
hot=Heiß
scattered-thunder=Vereinzelte Gewitter
scattered-showers=Vereinzelt Niederschlag
thundershowers=Gewitterregen
snow-showers=Schneefall
scattered-thundershowers=Vereinzelter Gewitterregen
unknown=Unbekannt
-=-
NULL=NULL
Hey Andy,
thanks for the map, but that was not my problem - sorry for the miss understanding
i get a pushover notification nearly the sames as you:
var text = "Hallo Philipp! Das Wetter: " + Condition.state + " 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"
but my condition.state isnt being translated - so i dont get the rain translated to "regen"
in my sitemap is all fine and german
thanks
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
Thanks Andy! that helped me out - 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 - 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