After restarting OpenHAB I get some error messages:
2018-01-04 21:46:14.007 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Strom an bei Schwimmbad Temperatur': The name 'Activate_Pool' cannot be resolved to an item or type; line 7, column 7, length 13
2018-01-04 21:46:15.670 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Strom an bei Schwimmbad Temperatur': The name 'Activate_Pool' cannot be resolved to an item or type; line 7, column 7, length 13
2018-01-04 21:46:15.682 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Strom an bei Schwimmbad Temperatur': The name 'Activate_Pool' cannot be resolved to an item or type; line 7, column 7, length 13
2018-01-04 21:46:28.018 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Strom an bei Schwimmbad Temperatur': The name 'ON' cannot be resolved to an item or type; line 7, column 30, length 2
But I get these only if I restart OpenHAB. When I open and save the rule file, OpenHAB loads it without problems.
Here is the rule:
import org.joda.time.LocalTime
rule "Strom an bei Schwimmbad Temperatur"
when
Item Temp_Pool received update
then
if (Activate_Pool.state == ON) {
val LocalTime morning = new LocalTime(10, 00) // 10:30 every day
val LocalTime evening = new LocalTime(17, 30) // 17:30 every day
if (now.toLocalTime().isAfter(morning) && now.toLocalTime().isBefore(evening)) {
// Temperatur mit Punkt statt Komma angeben
if (Temp_Pool.state < 25) {
if ( Devolo_Switch.state == OFF ) {
sendCommand(Devolo_Switch, ON)
logInfo("schwimmbad-temp.rules","Temperatur unter 25 Grad --> Devolo_Switch - ON")
}
} else {
if ( Devolo_Switch.state == ON ) {
sendCommand(Devolo_Switch, OFF)
logInfo("schwimmbad-temp.rules","Temperatur ueber 25 Grad --> Devolo_Switch - OFF")
}
}
} else {
if ( Devolo_Switch.state == ON ) {
sendCommand(Devolo_Switch, OFF)
logInfo("schwimmbad-temp.rules","Nicht in Zeit Bereich")
}
}
}
end
Item:
Switch Activate_Pool "Pool-Schaltung aktiv"
Iām using the stable version of OpenHAB 2.2.
Why is this happening?
More likely is this has always been doing this. It was in 2.2 that the error is now properly reported. Before, the error was not reported in a way that was human understandable.
And given that it is a timing issue, assuming my interpretation is correct, before you were lucky not to encounter the issue just from the luck of the timing. There is already an issue open to address the problem where rules load and run before items and persistence is done loading, which has been a problem since 2.0.
I see several error messages when restarting. They are all like
The name āblablaā cannot be resolved to an item or type;
The errors are different on each restart. Sometimes the are all about one rules file, or mutltiple different rule files.
But its not limited to items that are not yet properly loaded !
It also complains about global constants like ON
if(GwAlarmSoundActive.state ==ON){
gives
Rule āGwAlarmSoundRuleā: The name āONā cannot be resolved to an item or type;
It also affects constants that are defined just a few lines before the error line.
Even logDebug() is sometimes flagged as an error
The name ālogDebugā cannot be resolved to an item or type;
As said, the errors reported change on every reboot. Triggering the reload of files at runtime by touching them works OK.
I first noticed this behaviour after I flashed the RPi SD card with the latest openhabian containing oh2.2. I have never seen this when running OH 2.1.
Iām aware of the SD wear problem, but this is a relatively new 32GB Samsung Evo plus card. First used around Xmas the card has seen maybe 2 weeks worth of continous use in the RPi without any load on it and the card was never used for anthing but the RPi.
Because of the amazing speed of this SD card I am also pretty sure its an original Samsung and not a fake copy.
I doubt this is a SD wear problem, but just to be sure I will prepare a USB stick later today and try again.
Because the other part of the assigment has failed, i.e. the Item didnāt resolve. So the interpreter is still looking for an Item and ON doesnāt fit the bill.