Hi everyone.
I am trying to do the same thing, but I am getting an error.
I have traced the error to this line: cal.setTime(MyItem.lastUpdate(āmysqlā))
This is my rule.rules file:
rule "Update timestamp"
when
Item LastSeenDevices received update
then
LastSeenDevices.members.forEach[i |
var Calendar cal = Calendar::getInstance()
cal.setTime(i.lastUpdate("mysql"))
// postUpdate("Label_" + i.name, new DateTimeType(cal))
// logInfo( "HB_LastSeen", "Updating Last seen value for" + i.name)
]
end
and the error I am getting is:
00:55:14.579 [ERROR] [.script.engine.ScriptExecutionThread] - Error during the execution of rule 'Update timestamp': Could not invoke method: java.util.Calendar.setTime(java.util.Date) on instance: java.util.GregorianCalendar[time=1457495714566,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Argentina/Cordoba",offset=-10800000,dstSavings=0,useDaylight=false,transitions=62,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2016,MONTH=2,WEEK_OF_YEAR=10,WEEK_OF_MONTH=2,DAY_OF_MONTH=9,DAY_OF_YEAR=69,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=2,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=55,SECOND=14,MILLISECOND=566,ZONE_OFFSET=-10800000,DST_OFFSET=0]
Could you please help me find the way to solve this.
Thanks, regards!
EDIT: Forgot to told you I am using OH2 and mysql persitence working fine:
±--------------------±------+
| Time | Value |
±--------------------±------+
| 2016-03-08 22:21:05 | OFF |
| 2016-03-08 22:32:03 | ON |
| 2016-03-08 22:33:03 | OFF |
| 2016-03-08 22:34:03 | ON |
| 2016-03-08 22:35:03 | OFF |
| 2016-03-08 22:36:03 | ON |