changedSince() (or possibly just retrieving Switch states from persistence) not working any more in OH3 (influxDB)

Several weeks ago I took the plunge and updated my OH2.5 installation to OH3, and apart from some issues with migrating CalDAV to iCalendar, most of that seems to have gone well. However, I notice there are two problems with OH3 in regard to its handling of persistence data (the data is definitely being stored in influxDB as it should be, because I still get good quality graphs out of that with Grafana).

The first minor annoyance is that all the persisted Switches no longer graph in the BasicUI view. I have the following in my sitemap, and the first and last graphs still work as they used to, while the middle two give me flat lines with no data:

	Frame label="Graphs" {
		Chart item=gTemperatures period=D refresh=60000
		Chart item=gPresence period=D refresh=60000
		Chart item=gClimate period=D refresh=60000
		Chart item=elecDemand period=D refresh=60000
	}

The first and last graphs are groups of Number items, but the middle two are groups of Switch items. They used to graph perfectly well (just ranging from 0 to 1 and back again), but they no longer do so.

However, the really important bit is that the persistence queries in my rules which control the watering system no longer work: changedSince(xxx) queries now always return false, regardless of whether that value has changed in the applicable period. I have updated the date/time syntax for OH3 rules, and that all looks to be working perfectly on the persistence queries for Number items, but once again my problem is with persistence queries on the Switch items. As in the cases above, my Grafana graphs show that the data is being stored correctly - those graphs still look exactly the same as they used to - so it is OH3 that is failing to correctly retrieve/use the persisted data.

Here is the start of the rule where the problem is critical:

rule "morning watering"
when
	Item TimeOfDay changed from "Night" to "Twilight"
then
	val averageHumidity = Outside_Humidity.averageSince(now.minusDays(1)) as Number
	val averageTemperature = Outside_Temperature.averageSince(now.minusDays(1)) as Number
	val thisTimeYesterdayRainfall = Rainfall.historicState(now.minusDays(1)).state as Number
	val endOfYesterdayRainfall = Rainfall.historicState(now.with(LocalTime.of(0,0,0,0)).minusMinutes(1)).state as Number
	val nowRainfall = Rainfall.state as Number
	val wateredVeggiesLawnYesterday = waterVeggiesLawn.changedSince(now.minusHours(25))
	val wateredVeggiesLawnPast2Days = waterVeggiesLawn.changedSince(now.minusHours(49))
	val wateredGardenBedsYesterday = waterGardenBeds.changedSince(now.minusHours(25))
	val wateredGardenBedsPast2Days = waterGardenBeds.changedSince(now.minusHours(49))
	val wateredGardenBedsPast3Days = waterGardenBeds.changedSince(now.minusHours(73))

All of the persistence queries of Number items appear to work perfectly - the calculations which use the first five values have no problems at all (using historicState and averageSince queries). However, the changedSince queries (which are referring to the persistence of Switch item states) always return false, despite the fact that they definitely have changed within the applicable times.

I thought I went through all the breaking changes in the OH3 notes, but I don’t remember seeing this, and I’m really struggling to figure out how to either fix or work around it. It seems ridiculous to create and persist an extra set of variables as numbers to mirror the states just because it isn’t retrieving Switch state data properly any more. Suggestions welcome!

Looks relevant

1 Like

Thank you! I searched for the problem I thought I was having, but that’s the bug I wanted to find. Glad it’s not something I’ve messed up! Will follow those threads and see where they lead.

And that’s solved it - updated to 3.1.0.M2, and it’s behaving as expected both for the graphs and for the changedSince() query.

Is there an expectation when this update will be propagated to the latest docker container?

Daniel

Hi,

is this update ever going to be released to the docker container? Should I do my own dockerfile. This is kind of an essential behavior.
Could someone please push this to openhab:latest as 3.0.3?

Daniel