I have temperatures that arrive (from Home Assistant) and random times (whenever there is a change).
I have a continuous query that rolls these up into hourly temperatures, it looks like this (spacing mine for clarity):
CREATE CONTINUOUS QUERY Temp_Hourly ON HA
RESAMPLE EVERY 1h FOR 2d
BEGIN
SELECT mean(value) AS Temp INTO HA.autogen.HourlyTemps
FROM HA.autogen."°F"
GROUP BY *, time(1h) fill(previous)
END
This works fine, but is always an hour behind; the 10pm run for example fills to 9pm only.
If I ran it manually (between 10pm and 11pm as I just did) it works fine.
There is data between 2d ago and 10pm, plenty of it. Indeed for one series there was actually a data point at 21:58:29 present when it ran at 22:00, but it only created a data point for 21:00.
I tried the offset in the time() but it produced time stamps offfset, which is not what I wanted. This does work, I think, if I run it every 30 minutes, which is a viable workaround I guess but…
Should this store a time for 22:00 when run at 22:00?
Is it some kind of race condition, running at the hour, but thinking it’s not quite at the hour? I can’t find a way to run at (say) 22:05 but aggregate on whole hour boundaries. It is 100% reliable at producing data, just an hour behind.
If not, is there a more appropriate way to do this?
Using Influxdb 1.7.9 in a docker as part of Home Assistant running on Linux, setting the queries in the CLI not a UI.
PS. The reason for the 2d is just in case the sending system is down for a while; two days is probably 10 times too long, but at the moment I seem to have plenty of horsepower.