I have room sensors that are populating a postgress 16.6/timesacale database (on docker compose on Rasp Pi 5) (1 is occupied, 0 is not occupied)
The timezone of the postgress database is UTC:
I use the latest grafana 11.4 with default time options (UTC)
And the time options in a dashboard : Browser Time
I have a query that is collecting the occupation in 5 min buckets from day start time to start lunch time and form end lunch time to the end of day time:
select time_bucket('5 minutes',time) as period,avg(bezetting::real) as bezet
from kantoorbezettingklim
where sensornaam='${sensor1}' and
((time > '${datumstart}'::timestamptz and time <'${datumeind}'::timestamptz) and
((time::time between '${tijdstipbegindag}'::time- interval '1' hour and '${tijdstipbeginlunch}'::time - interval '1' hour) or
(time::time between '${tijdstipeindelunch}'::time - interval '1' hour and '${tijdstipeindedag}'::time- interval '1' hour) and
(trim(TO_CHAR(time,'day'))<>'saturday' and trim(TO_CHAR(time,'day'))<>'sunday')))
group by period
order by period
The day start time is 8:30u. I have to correct the time with ‘- interval ‘1’hour’, to get the correct start time in the query result (starting at 8:30u).( In dbeaver I get the same results without the ‘- interval ‘1’hour’ correction)
But after several refreshes suddenly the start time is 07:30. From then on after a browser refresh the start time is fluctuationing from 8:30u to 7:30u (not regulary).
This looks it has to do with timezones and the behaviour is inconsistent. Is this a setting ? Is there a solution ?
Help would be appreciated
Thanks Hugo