Persistence sumSince() doesn't output a valid numer, only zero

  • Platform information:
    • Hardware: virtual Machine on ESX Server
    • OS: Suse Linux Enterprise Server 15
    • Java Runtime Environment: zulu8.33.0.1-jdk8.0.192
    • openHAB version: 2.4.0
  • Issue of the topic: Persistence sumSince() doesn’t output a valid numer, only zero
  • my configurations:
    • Items configuration related to the issue

items/door.items

Contact Door_Status "Door Status[%s]" <door> (GP_Persist_Restore, GP_Persist_Change, GP_Persist_Hour) { channel="mqtt:topic:door_status"}
Number:Dimensionless Door_Counter_monthly "Door Counter this month [%d]" <door> (GP_Persist_Restore)
  • Sitemap configuration related to the issue

nothing special here

  • Rules code related to the issue

rules/door.rules

rule "monthly door counter"
    when
        Item Door_Status changed to CLOSED or
        Time cron "0 0 0 1 1/1 ? *" or // first of month, 0:00 o'clock
        Item Debug_Trigger_Counter_Update changed to ON
    then
        Door_Counter_monthly.postUpdate(Door_Status.sumSince(now.minusDays(31), "influxdb"))

        if(Debug_Trigger_Counter_Update.state == ON) {Debug_Trigger_Counter_Update.postUpdate(OFF)}

end
  • Services configuration related to the issue

persistence/influxdb.persist

Strategies {
	everyMinute : "0 * * * * ?"
	everyHour : "0 0 * * * ?"
	everyDay  : "0 0 0 * * ?"
	default = everyChange
}

Items {
	GP_Persist_Minute* : strategy = everyMinute
	GP_Persist_Hour* : strategy = everyHour
	GP_Persist_Day* : strategy = everyDay
	GP_Persist_Change* : strategy = everyChange
}

persistence/mapdb.persist

Strategies {
	default = everyChange
}

Items {
	GP_Persist_Restore* : strategy = everyChange, restoreOnStartup
}
  • If logs where generated please post these here using code fences:
    events.log
14:43:36.161 [ome.event.ItemCommandEvent] - Item 'Debug_Trigger_Counter_Update' received command ON
14:43:36.162 [vent.ItemStateChangedEvent] - Debug_Trigger_Counter_Update changed from NULL to ON
14:43:36.329 [vent.ItemStateChangedEvent] - Door_Counter_monthly changed from NULL to 0.0
14:43:36.338 [vent.ItemStateChangedEvent] - Debug_Trigger_Counter_Update changed from ON to OFF

I want to count the number of door opening events for this month (31 days in this example). Persistence itself works, I see data in Grafana (connected to same influxdb instance):
image

But sumSince() always outputs me a zero, why?
Is there aproblem in using two persistence services? That’s why I put sumSince([...], "influxdb") there, but that doesn’t change anything.

Just for record:

  • I never used calculation on persistence data, so there might be a more general configuration issue there
  • I first wanted to use sumSince(now.withTimeAtStartOfDay.minusDays(now.getDayOfMonth()))) but to keep out complexity I made the example easier.

Thanks in advance :slight_smile:

I think you will find this relevant (you can’t sum strings)

Note also you probably want your count as a plain Number type, not Dimendionless which is really for ratios or percentages.

Hmm, are you sure? You can see in Grafana that it doesn’t save strings but numbers (0 = CLOSED, 1 = OPEN), so one should be able to sum that.

No, that already got answered:

I don’t want to save/exchange plain numbers, OpenHAB has a Units Of Measurements concept, and I want to use that - so I have to pick the correct UOM type.

Well, summing your contact Item doesn’t work, it’s up to you if you want to do anything about that.

Here is the second result from searching influxdb + sumsince (previous link was the first)