Last update in python

i just play around with jython and i converted a dsl-rule to jython. what i realized was that the items are different assigned:

in jython: 2020-02-18T19:35:09.044+0100
in dsl-rule: 2020-02-18T19:40:10.579+01:00

because of that i had difficulites when i assigned an item in jython and wanted to use a dsl-rule with “isBefore…” then

hope this can help a bit

hi scott.
first of all: sorry i´m not a programmer and i hope i don´t write nonsense here. i will try to explain what i did, probably i did something wrong:

until now i had a rule and i needed to check when was the last update of an item. this i did with a global variable

var sAbzug_LastUpdate =

and in the rule:

    logError("test", "time now is " + now.toString)
    logError("test", "time last update was " + sAbzug_LastUpdate.toString)
    sAbzug_LastUpdate =

this produces following log:

2020-02-19 07:29:11.302 [ERROR] [.eclipse.smarthome.model.script.test] - time now is 2020-02-19T07:29:11.300+01:00
2020-02-19 07:29:11.309 [ERROR] [.eclipse.smarthome.model.script.test] - time last update was 2020-02-19T07:29:09.589+01:00

… you see the time-zone at the end is here:


now i want to switch this to jython and tried to assign the update-time to an item:

@when("Item iG_Abzug changed to OFF")
@when("System started")
def iAbzug_LastUpdate_Funktion(event):
    events.sendCommand(ir.getItem("iAbzug_LastUpdate"), str(DateTimeType()))"iAbzug_LastUpdate = %s" % ir.getItem("iAbzug_LastUpdate").state)

but now i see this in the log:

2020-02-19 07:39:43.777 [ome.event.ItemCommandEvent] - Item 'iAbzug_LastUpdate' received command 2020-02-19T07:39:43.763+0100

… you see the time-zone at the end is here:


and since that it is not possible to use a rule with a condition like


best, stefan

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.