my Openhab Installation works (myopenhab also works) now and now I wanna start whit some rules (but I am very bad a this).
I want some rules but the first one should do:
If Temperatur Outside (I have an Item for that) is lower the 12 Degrees and Window is open longer than 15 Minutes then
push a Message “Windows Bath still open” on my iOS Device (via OpenhabApp)
But I have no Idea About the Syntax
p.s. if the myopenhab push is not so good I already can create a Telegram Bot.
I already found this but this doesn’t help me a lot.
sendBroadcastNotification("Hello world!")
i do a simple test script and this works.
rule "test"
when
Item FensterSchalfzimmer_FensterZustand changed to OPEN
then
if(Wetterinformation_Temperatur.state <= 10) {sendBroadcastNotification("Fenster Schlafzimer ist offen test")}
end
but I have no idea how what code I need for "windows longer open as 10 Minutes ".
var Timer FensterSchlafzimmer_Timer = null
rule "test"
when
Item FensterSchalfzimmer_FensterZustand changed
then
if (FensterSchalfzimmer_FensterZustand.state==CLOSED) {
if (FensterSchlafzimmer_Timer!=null) {
FensterSchlafzimmer_Timer.cancel
FensterSchlafzimmer_Timer=null
}
}
else if (FensterSchalfzimmer_FensterZustand.state==OPEN) {
if (FensterSchlafzimmer_Timer==null) {
FensterSchlafzimmer_Timer=createTimer(now.plusMinutes(10)) [|
if(Wetterinformation_Temperatur.state <= 10) {
sendBroadcastNotification("Fenster Schlafzimmer ist länger als 10 Minuten geöffnet")
}
]
}
}
end
First
Maybe you or someone else can help me with to more Ideas.
First can I add some how in the brodcast Message the Outside temperature like
(“Fenster Schlafzimmer ist länger als 10 Minuten geöffnet und and Outside Temperatur is Wetterinformation_Temperatur.state” Degrees)
Should I create a extra Rule for every room?
Second Question
the same Idea from the first rule but no timer rather.
rule "test2"
when
Item FensterSchalfzimmer_FensterZustand=OPEN
then
if (Time is Between 6:35 and 7:00 on Weekdays and temperature <=10degrees) {.
//How I set Time and Weekdays e.g. Monday till Friday and add the temperature
sendBroadcastNotification("Fenster Schlafzimmer zu machen")}
Depends on your specific requirements. I use one Rule and whenever any door (in my case) has been open for too long I send a single report with ALL the doors that have been open for too long. That way I can handle everything within on Rule as the message doesn’t depend on which sensor timer went off.
Check out the Design Pattern: Time Of Day. With a little work you can expand it to include a state for weekday verses weekend and then your rules would use:
Also see Design Pattern: Separation of Behaviors for ways to centralize your alerting so you can do some of these sorts of checks in a central location. For example, at night I use a different alerting mechanism than I do during the day. I send out alerts to specific phones sometimes and broadcast at others (e.g. broadcast when no one is home. But all this logic is in one place so I don’t need these kind of if statements everywhere I generate an alert.