after upgrading to #1518 I see this error in my logs:
2019-02-09 11:41:18.040 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Dishwasher Consumption State Machine': The name 'now' cannot be resolved to an item or type; line 48, column 74, length 3
2019-02-09 11:38:59.677 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'household-devices.rules', using it anyway:
The method averageSince(Item, Object, String) from the type PersistenceExtensions refers to the missing type Object
The method averageSince(Item, Object, String) from the type PersistenceExtensions refers to the missing type Object
The method averageSince(Item, Object, String) from the type PersistenceExtensions refers to the missing type Object
here the rule:
// Dishwasher State Machine
rule "Dishwasher Consumption State Machine"
when
Item Fibaro_Dishwasher_MeteredWallPlug_SensorPower changed or
System started
then
if(Fibaro_Dishwasher_MeteredWallPlug_SensorPower.state == NULL) {
return;
}
else if (Fibaro_Dishwasher_MeteredWallPlug_SensorPower.state < 0.1) {
Dishwasher_OpState.postUpdate("offline")
}
else if ((Fibaro_Dishwasher_MeteredWallPlug_SensorPower.averageSince(now.minusMinutes(2), "rrd4j") as Number) <= 1) {
if (Dishwasher_OpState.state == "running" && dishwasherTrigger) {
dishwasherTrigger = false
var dish_message = "The dishwasher is reporting the program is now finished"
sendMail("ariela@nesys.it", "Electrolux Dishwasher - FINISHED", dish_message)
Dishwasher_OpState.postUpdate("standby")
}
else {
Dishwasher_OpState.postUpdate("standby")
}
}
else if ((Fibaro_Dishwasher_MeteredWallPlug_SensorPower.state > 1) && (Fibaro_Dishwasher_MeteredWallPlug_SensorPower.state < 3) && (Dishwasher_OpState.state == "standby")) {
Dishwasher_OpState.postUpdate("programmed")
dishwasherTrigger = true
}
else if (Fibaro_Dishwasher_MeteredWallPlug_SensorPower.state > 3) {
Dishwasher_OpState.postUpdate("running")
}
end
Occasionally, I saw similar errors; often I was able to resolve them by a couple of OH2 restarts.
I may be wrong, but I have the impression that for me these were triggered by rules loading before OH2 had finished initializing.
As the process of restarting a few times was rather unsatisfactory, I implemented this: Cleaning up the startup process / renaming rules (windows possible) and never seen this issue again. There are other ways to do this too that you can find searching the forum.
Hope this helps
Another issue like the previous one (maybe same root cause?)
Error:
2019-02-09 11:38:52.917 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'presence.rules', using it anyway:
The method createTimer(Object, Procedure0) from the type ScriptExecution refers to the missing type Object
The method lastUpdate(Item) from the type PersistenceExtensions refers to the missing type Object
The method lastUpdate(Item) from the type PersistenceExtensions refers to the missing type Object
The method lastUpdate(Item) from the type PersistenceExtensions refers to the missing type Object
presence.rules:
// Global variables
var Timer cameHomeTimer = null
// Presence (Away) IFTTT out
rule "Set Away"
when
Member of gPIFTTT changed to OFF
then
val setAway = gPIFTTT.members.filter[ a | a.state == OFF && a.name == triggeringItem.name].map[ name.replace("_Presence_IFTTT", "") ]
switch setAway {
case setAway.get(0) == "Andrea": Andrea_Presence.sendCommand(OFF)
case setAway.get(0) == "Cate": Cate_Presence.sendCommand(OFF)
}
end
// Presence (Home) Unifi in
rule "Welcome home my dear"
when
Member of gPhones changed to ON
then
if(cameHomeTimer !== null) {
return; // do nothing if there is already a Timer
}
logInfo("test", "Rule triggered by " + triggeringItem.name + " at " + now.toString)
cameHomeTimer = createTimer(now.plusSeconds(5), [ |
val cameHome = gPhones.members.filter[ p | p.state == ON && (p.name == triggeringItem.name || (p.lastUpdate !== null && p.lastUpdate.isAfter(now.minusSeconds(6)))) ].map[ name.replace("_Phone_Home_Unifi_online", "") ]
gPhones.members.forEach[ p | logInfo("test", "Values for " + p.name + "\n" + "State = " + p.state.toString + "\n" + "LastUpdate = " + p.lastUpdate.toString)]
var message = "Benvenuti a casa, "
switch(cameHome.size) {
case 0: {
logError("came home", "Unexpected number of phones: " + cameHome.size)
return;
}
case cameHome.size == 1 && cameHome.get(0) == "Andrea": message = "Benvenuto a casa, Andrea"
case cameHome.size == 1 && cameHome.get(0) == "Cate": message = "Benvenuta a casa, Caterina"
case cameHome.size == 1 && cameHome.get(0) == "Sofia": message = "Benvenuta a casa, Sofia"
case cameHome.size == 1 && cameHome.get(0) == "Edo": message = "Benvenuto a casa, Edoardo"
default: {
message = message + cameHome.members.reduce[ String list, String name | list + ", " + name ]
val ind = message.lastIndexOf(",")
message = new StringBuilder(str).replace(ind, ind+1," e").toString();
}
}
logInfo("check message", "message is: " + message)
Echo_Living_Room_TTS_Volume.sendCommand('90')
//Echo_Living_Room_TTS.sendCommand('<speak><break time="2s"/>' + message + '</speak>')
Echo_Living_Room_TTS.sendCommand(message)
cameHomeTimer = null
])
end
Unfortunately I’ve already implemented the first solution in the link you mentioned … and after upgrading to #1518 I’ve had no issues at all with those rules
The method lastUpdate(Item) from the type PersistenceExtensions refers to the missing type Object
The method historicState(Item, Object, String) from the type PersistenceExtensions refers to the missing type Object
The method createTimer(Object, Procedure0) from the type ScriptExecution refers to the missing type Object
Rule 'xxx': The name 'now' cannot be resolved to an item or type; line 261, column 25, length 3
I did an
apt-get install openhab2=2.5.0~S1512-1 openhab2-addons=2.5.0~S1512-1
to revert to the specified build and everything seemed to be ok again afterwards.