- Platform information:
- Hardware: armv7l GNU/Linux
- OS: Raspbian GNU/Linux 9 (stretch)
- Java Runtime Environment: zulu-embedded-8.25.0.76
- openHAB version: 2.5.1
- Issue of the topic: deltaSince is calculated improperly off by 1 (problem A)
- Issue of the topci: deltaSince uses improper < time instead of >= time query to influxdb (problem B)
I’m using influxdb persistence, and will have item of Number type named counterGamingHours which is incremented every hour I’m gaming
You can can observe current values in influxdb:
> select * from counterGamingHours order by time desc limit 3;
name: counterGamingHours
time value
---- -----
1583590429531000000 153
1583586753133000000 152
1583582573161000000 151
>
So the NEWEST one is from yesterday (March 7).
BUG: if you asked deltaSince(now.withTimeAtStartOfDay, “influxdb”) openhab queries influxdb (I observed it with debug logs on influxdb layer) with a query:
select value from "autogen"."counterGamingHours" where time < 1583622000s ORDER BY time DESC limit 1
which actually creates two problems:
Problem A: openhab deltaSince from the above example returns “1” - WTF? there is NO other data in the influxdb. It shall be 0.
Problem B: if I ask openhab for a really long period, example:
counterGamingHours.deltaSince(now.withTimeAtStartOfDay.withDayOfMonth(1),"influxdb")
I would get… NULL. Thats bug number two, which happens because in influxdb I have only values starting from March 2 (not earlier), AND BECAUSE openhab is using “<” query (quoted below) to find boundary, it returns nothing. Proper behaviours would be to use >= in this query.
Actual problematic query in case B is:
select value from "autogen"."counterGamingHours" where time < 1583017200s ORDER BY time DESC limit 1
I’m quite baffled that those bugs were not found/reported earlier, as literally every deltaSince returns wrong data today.
At least as it seems to happen on my system, so could you please shed some light or show some mistakes in my thinking?