rule "Takeoff Landing"
when
Item weather_wind_deg received update
then
if (weather_wind_deg.state as DecimalType > 200 && weather_wind_deg.state as DecimalType < 300)
{
postUpdate(weather_toland, "Landing")
}
else if (weather_wind_deg.state as DecimalType > 40 && weather_wind_deg.state as DecimalType < 120)
{
postUpdate(weather_toland, "Takeoff")
}
else
{
postUpdate(weather_toland, "Alternative")
}
end
As @rtvb mentioned, you need to compare the state, not the Item itself. Also, you need to cast the state to a DecimalType so the Rules knows that it is a number.
Error during the execution of rule 'Takeoff Landing': An error occured during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.BooleanExtensions.operator_and(boolean,boolean) on instance: null
Yes pretty sure.
Fixed by removing as decimal type. I guess i forgot to mention that i’m running OpenHab 2 so guess the behaviour is different
This is a copy from log. Lines go one after another.
In the items file i have
Number weather_wind_deg "Wind degree [%.0f °]" (g_Weather) {weather="locationId=forio, type=wind, property=degree"}
Here is the log
2016-06-22 21:30:36.301 [INFO ] [marthome.event.ItemStateChangedEvent] - weather_wind_deg changed from 297.00 to 299.00
2016-06-22 21:30:36.309 [ERROR] [.script.engine.ScriptExecutionThread] - Error during the execution of rule 'Takeoff Landing': An error occured during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.BooleanExtensions.operator_and(boolean,boolean) on instance: null
There is no need to split as rule is working. I guess that “as DecimalType” somehow doesn’t work. I will try to debug to best of my knowledge (which is little) and provide the results.
Thank you for helping out
I often see that type of error on math comparisons of item states when I first restart openHAB. In my case I think it’s because something hadn’t yet polled the items to get their initial states