Datatype of return value of history.minimumSince()

  • Platform information: “openhab/openhab:3.4.2-alpine”

Given following code fragment in an ECMA script rule:

  var itemName = event.itemName
  var item = items.getItem(itemName)
  
  var dttmThen = time.ZonedDateTime.now().minusDays(1)
  
  var minSince = item.history.minimumSince(dttmThen)
  var maxSince = item.history.maximumSince(dttmThen)

  console.debug("Dump minSince")
  console.debug("typeof minSince: ", typeof minSince)
  console.debug("minSince: ", minSince)
  console.debug("minSince.state: ", minSince.state)
  console.debug("minSince.numericState: ", minSince.numericState)
  console.debug("minSince.rawState: ", minSince.rawState)
  console.debug("minSince.timestamp: ", minSince.timestamp)

I would not expect following output in the logs:

2023-03-29 00:40:30.672 [DEBUG] [cript.ui.calcMinMaxValuesInIntervall] - main:25 : Calculating min/max for  Temperature_Alarm
2023-03-29 00:40:30.698 [DEBUG] [cript.ui.calcMinMaxValuesInIntervall] - Dump minSince
2023-03-29 00:40:30.710 [DEBUG] [cript.ui.calcMinMaxValuesInIntervall] - typeof minSince:  number
2023-03-29 00:40:30.711 [DEBUG] [cript.ui.calcMinMaxValuesInIntervall] - minSince:  2.24
2023-03-29 00:40:30.711 [DEBUG] [cript.ui.calcMinMaxValuesInIntervall] - minSince.state:  undefined
2023-03-29 00:40:30.711 [DEBUG] [cript.ui.calcMinMaxValuesInIntervall] - minSince.numericState:  undefined
2023-03-29 00:40:30.711 [DEBUG] [cript.ui.calcMinMaxValuesInIntervall] - minSince.rawState:  undefined
2023-03-29 00:40:30.711 [DEBUG] [cript.ui.calcMinMaxValuesInIntervall] - minSince.timestamp:  undefined

but rather that minSince is a HistoricItem Object (instead of number) with those properties defined (there is plenty of data in the database for a day).
Default persistency is a mysql database.

There was an update to the js helper library recently that changed historicState to return the object instead of just a simple state. I forgot exactly when but guess that update was between 3.4 and 4.0 because it was a breaking change. You may be looking at the 4.0 references.

You can try upgrading to the 4.0 milestone now, rework the code to handle the simple state return value until you finally do upgrade, or, I believe, you can get the updated helper libraries to work with 3.4.