Hi,
i’m goint to tune my roller shutters rules (at the moment there is only a simple “up in the dawn” and “down in the dusk” by astro binding.
Now i’d like to add some shading by the weather-binding (https://www.openhab.org/addons/bindings/weather1/) with openweathermap.org
my Items work more or less: on one hand i get the ERROR “Can’t retreive weather data” on the other hand i see Item-changes:
.
… so i think in principle the weather-binding works.
question is how to integrate this Item in a roller shutter rule. i’m so bad in programming
First i’ve searched similarities to my astro-rules - but they work with channels; here i’ve items.
And then i need to create a “greater than” oder “less than” - condition (… but ITEM need “changed” or “received update”).
my last and poorly try was this rule:
rule "Rolladen Wohnzimmer runter wenn es warm ist"
when
ITEM Temperatur_AIT.state changed < "10.00"
then
Rolladen_Wohnzimmer_BlindsControl.sendCommand(50)
end
unfortunaly it’s still not working
The latest Coding looks like this:
rule "Test Rolladen bei Temperatur
when
Item Temperature_AIT changed
then
if (Temperature_AIT.state as Number < 15) Rolladen_Wohnzimmer_BlindsControl.sendCommand(50)
end
and i get this error:
2019-09-11 23:36:32.999 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘Rolladen_Wohnzimmer_Sonne.rules’ has errors, therefore ignoring it: [8,43]: no viable alternative at input ‘15’
You got to bracket that if ( (Temperature_AIT.state as Number) < 15)
It’s really worth looking through other forum posts on similar topics, there are lots of example of rules like this, which would allow to see how things should be put together.
Hi,
seems that the brackets brought the solution - and please belive me, that i’ve searched trough this forum posts - it’s difficult to find a key word (if you don’t know where the problem is).
Yes, I agree. There is value in looking at only vaguely related posts along “compare temperature rule” or even “compare Number” and suchlike, just to see how rules coding is applied. For openHAB you’re just not going to get it all from a manual.
i’ve tried to adjust the rule in the java.- direction with “{” / “}”:
rule "Rolladen Wohnzimmer runter wenn es warm ist"
when
Item Wetterdaten_Aussentemperatur_Openweathermap changed
then
if ( (Wetterdaten_Aussentemperatur_Openweathermap.state as Number ) < "25")
{Rolladen_Wohnzimmer_BlindsControl.sendCommand(50)}
end
rule "Rolladen Wohnzimmer runter wenn es warm ist"
when
Item Wetterdaten_Aussentemperatur_Openweathermap changed
then
logInfo("Wetterdaten_Aussentemperatur_Openweathermap", "Value = " + Wetterdaten_Aussentemperatur_Openweathermap.state.toString)
if ((Wetterdaten_Aussentemperatur_Openweathermap.state as Number) < 25) {
Rolladen_Wohnzimmer_BlindsControl.sendCommand(50)
}
end
There are two approaches to this.
Convert the Number:Temperature to a plain number or compare with a temperature:
Solution 1:
rule "Rolladen Wohnzimmer runter wenn es warm ist"
when
Item Wetterdaten_Aussentemperatur_Openweathermap changed
then
logInfo("Wetterdaten_Aussentemperatur_Openweathermap", "Value = " + Wetterdaten_Aussentemperatur_Openweathermap.state.toString)
if ((Wetterdaten_Aussentemperatur_Openweathermap.as QuantityType<Number>).doubleValue < 25) {
Rolladen_Wohnzimmer_BlindsControl.sendCommand(50)
}
end
Solution 2:
rule "Rolladen Wohnzimmer runter wenn es warm ist"
when
Item Wetterdaten_Aussentemperatur_Openweathermap changed
then
logInfo("Wetterdaten_Aussentemperatur_Openweathermap", "Value = " + Wetterdaten_Aussentemperatur_Openweathermap.state.toString)
if (Wetterdaten_Aussentemperatur_Openweathermap.state < 25 | "°C") {
Rolladen_Wohnzimmer_BlindsControl.sendCommand(50)
}
end