Rule to convert timestamp in date string not fired

Hi,

i go mad with a rule which is not acting!

i try to convert a timestamp to a normal date string, when this timestamp is changed.

To check the conversation I want to trigger the rule with a switch:

rule "Konvertiere Ladedatum"
  when
	Item Ladelog changed from OFF to ON
  then
	var String date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new java.util.Date(((LastChargeDate.state as DecimalType) * 1000).longValue))
	LastChargeDateTime.postUpdate(date)
	logInfo("LastChargeDate:", LastChargeDateTime)
  end

I can see in the event-log that the value of “Ladelog” is changed:

2023-01-06 11:58:37.391 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Ladelog' received command ON
2023-01-06 11:58:37.392 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Ladelog' predicted to become ON
2023-01-06 11:58:37.396 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Ladelog' changed from OFF to ON

But the rule is not fired! To check this I added the loginfo.

Any ideas?

  • try adding logInfo at the start of your rule

also why not

val lastChargeMilli = (LastChargeDate.state as DecimalType).longValue
val date = java.time.Instant.ofEpochMilli(lastChargeMilli).atZone(ZoneId.systemDefault)
LastChargeDateTime.postUpdate(date)

i tried also… but why is the rule not fired ???
another idea or syntax?

Do you use .rules and .items files ?
Then it may be related to Rules not firing after item is edited · Issue #2097 · openhab/openhab-core · GitHub which is also discussed in OH3 (Possible) DSL Rules, received update not firing from different files

Hi Wolfgang, this seems to be the problem… so what to do? is there a workaround?

Did you try to restart the OH service ?

sure… no change…