Hi All
I am trying to manipulate some Date and Time Items to be able to hide Frames in a sitemap using the “visibility” options.
I have the recorded the time an item last updated as a string using the following rule:
rule "Partition 1 Alarm Timestamp"
when
Item Partition1_AlarmMemory changed to ON or
Item Testing_Switch received command ON
then
postUpdate(Partition1_Last_Alarm, new DateTimeType())
logInfo("", "Partition 1 Alarm Timestamp " + Partition1_Last_Alarm.state )
end
Partion1_Last_Alarm is a STRING item defined in PaperUI.
I also have the current time defined by the following rule:
rule SetDay
when
System started or
Item Testing_Switch received command ON or
Time is midnight
then
Today.postUpdate(new DateTimeType())
end
Which I display using the sitemap as follows (so no formatting):
Default item=Today label="Today [%s]"
Default item=Partition1_Last_Alarm label="Today [%s]"
And I get the following outputs:
Today 2020-10-16T11:30:22.961+02:00
Partition1_Last_Alarm 2020-10-16T11:09:03.010+02:00
From what I have read these are ISO8601 format? And I would like to convert them to be Number Values (Epoch) so that I can compare and make decisions in the visibility statements. (E.g. visibility=[Partition1_Last_Alarm > Today]
So I have used the following to try and convert to EPOCH based on DateTime Conversion #9
rule SetDay
when
System started or
Item Testing_Switch received command ON or
Time is midnight
then
Today.postUpdate(new DateTimeType())
//Removed.millis as end of next as seconds OK
val Number Today_Epoch_Val = new DateTime(Today)
Today_Epoch.postUpdate(new DateTimeType())
end
I however get the following error in the logs and no matter what I have tried I still get the error:
14:52:32.417 [INFO ] [smarthome.event.ItemStateChangedEvent] - Today changed from 2020-10-16T11:30:22.961+0200 to 2020-10-16T14:52:32.417+0200
14:52:32.417 [ERROR] [untime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'SetDay': No instant converter found for type: org.eclipse.smarthome.core.library.items.StringItem
14:52:32.417 [INFO ] [org.quartz.core.QuartzScheduler ] - Scheduler openHAB-job-scheduler_$_NON_CLUSTERED started.
Today_Epoch is an item defined in PaperUI as a Number with no dimension applied at this stage.
I expect that if I can get Today to work the same would apply for the Partition1_Last_Alarm item as well.
Any hints or guidance would be greatly appreciated.
Mark