i need help for creating a rule for automatical ventilation.
I will use the Weather_Rain_Volume_today and the Weather_Snow_Volume_today from the openweahterbinding.
I have a chain motor and a shelly 2.5 in use, i will open the window once a day with a rule, but the value i get from the Weather_Rain_Volume_today and Weather_Snow_Volume_today is a unit of measurement, so it is with mm and m, how can i create a rule if the value of both is zero than open the window for some minutes?
And also the same in the other way, if the value is higher than zero close the windof if it is open?
this was my first try:
rule "Dachfenster bei regen schnee usw schließen"
when
Item Dachfenster changed
then
if ((Weather_Rain_Volume_today.state > 0 || Weather_Snow_Volume_today.state > 0)) {
Dachfenster.sendCommand(DOWN)
logInfo("FILE", "Dachfenster wird geschlossen da es Regnet oder Schneit")
}
else {
logInfo("File","Dachfenster Regel Problem")
}
end
Here’s a thermostat rule (with hysteresis) example that may help. I added the timer on the fly so there may be a syntax error but you can check with VSCode. For the timer you can use now.plusMinuets(10) or hours if you needed.
var Timer mytimer = null
rule " temp"
when
Item MySetpoint changed or
Item MyTemp changed
then
var Number cur_temp = MyTemp.state as Number
var Number setpoint = MySetpoint.state as Number
val Number hysteresis = 0.5
mytimer?.cancel // Cancel any running timer
if (cur_temp < (setpoint - hysteresis)) {
if (MyItem.state != ON) {MyItem.sendCommand(ON)}
myTimer = createTimer(now.plusSeconds(60), [ |
//do whatever
])
}
else if(cur_temp > setpoint + hysteresis) {
if (MyItem.state != OFF) {MyItem.sendCommand(OFF)}
}
end
I hope it helps or at least gives you something to work with.
rule "Dachfenster bei regen schnee usw schließen"
when
Item Dachfenster changed
then
if((Weather_Rain_Volume_today.state as QuantityType<Number>).intValue >= 0 ) if( Weather_Rain_Volume_today.state >= 0 | "mm" ) ||
if((Weather_Snow_Volume_today.state as QuantityType<Number>).intValue >= 0 ) if( Weather_Snow_Volume_today.state >= 0 | "m" )
{
Dachfenster.sendCommand(DOWN)
logInfo("FILE", "Dachfenster wird geschlossen da es Regnet oder Schneit")
}
else {
logInfo("File","Dachfenster Regel Problem")
}
end
but now i get these error on the logs:
[WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'dachfenster.rules' has errors, therefore ignoring it: [5,128]: no viable alternative at input '||'