I am really desperate now. I have a rule for a motion sensor which collapses the motion state and the last update time on one line. It seems that the rule is not being executed which I conclude out of a debug statement I put into the rules “body”. I have other rules which are similar being all executed.
Below is the excerpt from the items and rules file.
/*
* Set lastupdate
*/
val org.eclipse.xtext.xbase.lib.Functions$Function1 lastUpdate = [
org.openhab.core.library.items.DateTimeItem item |
postUpdate(item, now.toString());
]
rule "Motion GF Entrance Update"
when
Item Motion_GF_Entrance received update
then
logDebug("Motion_GF_Entrance Update", "in rule")
lastUpdate.apply(Motion_GF_Entrance_Lastupdate)
postUpdate(Motion_GF_Entrance_Formatted, Motion_GF_Entrance.state)
end
From the log I see the update event for the item Motion_GF_Entrance but nothing more. No error in the log, no output and no update to Motion_GF_Entrance_Formatted.
2015-10-06 20:43:56 - LightLevel_GF_Entrance state updated to 0.0
2015-10-06 20:43:56 - LightLevel_GF_Entrance_Lastupdate state updated to 2015-10-06T20:43:56
2015-10-06 20:43:57 - LightLevel_GF_Entrance_Formatted state updated to 0.0 Lux - (0.0/24.0) @Tue:20:43
>> 2015-10-06 20:43:58 - Motion_GF_Entrance state updated to 1
2015-10-06 20:45:00 - Tom_MacbookPro received command ON
2015-10-06 20:45:00 - Tom_Nexus received command ON
2015-10-06 20:47:47 - Date state updated to 2015-10-06T20:47:4
I absolutely have no glue how to go forward from here.
So any help is highly, highly appreciated.
However, you only copied from your events.log. Your logDebug statement and any errors will appear in openhab.log.
Do you have openHAB running in DEBUG mode or have you updated logback.xml to log out the DEBUG statements? If not the log statement will not show up in your logs at all.
I’d try switching it to logInfo instead of logDebug for now (you can remove or change back to logDebug later) and watch openhab.log in addition to events.log. Then add a log statement to your lambda before and after the postUpdate to see if it is completing execution of that. I’ve found sometimes when a lambda fails for some reason it can do so silently and the rule just stops.
I looked as well into openhab.log the output wasn’t there and debug log level was switched since the log file was swamped with debug statements. There are also no errors I could see in the openhab.log. To me it looks like the rule is not being executed.
Weird. I usually have the problem where a rule triggers too much when I use “received update”. Did you check that there were no errors when the rules file is loaded? Maybe there is a syntax error somewhere that prevented the rule from even loading and you missed it with all the stuff that gets printed in the debug log.
You can force it to reload the file by updating the timestamp on the file (e.g. on Linux the “touch” command).
No errors during load. I have a bunch of other rules before and after that particular rule. The other rules work as expected. Really strange. I extracted parts of the debug log where the item seems to accessed. I have not looked into the sources so far to understand what is going on but anyway may be somebody on the forum can spot something here.
import org.openhab.core.library.types.*
rule "Motion GF Entrance Update"
when
Item Motion_GF_Entrance received update
then
logDebug("Motion_GF_Entrance Update", "in rule")
Motion_GF_Entrance_Lastupdate.postUpdate(new DateTimeType())
Motion_GF_Entrance_Formatted.postUpdate(Motion_GF_Entrance.state.toString)
end
I changed my logDebug to logInfo to have the chance to see something. After openhab restart I saw the string initiation exception.
Obviously the problem was the last statement in the rule which you correctly suggested to change to