Hi there!
Would you like to help a NOOB?
I have persistence set up and working.
I just like to find out an items last update using JSR223 Jython on openHAB2 2.2
Nothing fancy. Just like to retrieve the date.
Can the following script easily be modified:
scriptExtension.importPreset("RuleSimple")
scriptExtension.importPreset("RuleSupport")
class MyRule(SimpleRule):
def __init__(self):
self.triggers = [
Trigger("MyTrigger", "core.ItemStateUpdateTrigger",
Configuration({ "itemName": "TestString1"}))
]
def execute(self, module, input):
item = ir.getItem("A580IP")
# Here... what to do to get the items last update time?????
automationManager.addRule(MyRule())
Just the way that I do in the following Xtend script which works great:
rule "Test"
when
Time cron "0/15 * * * * ?"
then
var String Timestamp = Bathroom_Door.lastUpdate.toDateTime.toString("yyyy-MM-dd HH:mm:ss")
if (!Bathroom_Door.updatedSince(now.minusSeconds(90))) {
logInfo("Bathroom_Door", "Bathroom door was opened : " + Timestamp)
}
end
I appreciate your kind help!!! Cheers!
Edit: I hope it doesn’t matter what kind of persistence service I’ve setup. But in case it does, I’ve set up InfluxDB (v 1.0) Persistence.