I have a rule for data reading, but to read a correct data from midnight, I must read one hour before :
val ZonedDateTime zdt = ZonedDateTime.now()
val actual_day = zdt.minusDays(1).withHour(23).withMinute(0).withSecond(0)
val number = Modbus_Data_Grid_sum_2634_Value_as_Number.historicState(actual_day).state as Number
postUpdate(number_item, number)
this value is
but if I will check in the graph, readed value is exactly in midnight
That line is flat. How do you know it’s one hour before midnight and not 6 hours before midnight or five hours later?
You are asking for the value at zdt.minusDays(1).withHour(23).withMinute(0).withSecond(0) which is exactly one hour before midnight on the previous day. So change the withHour to 0.
Then that means you have the tiemzone set wrong somewhere. Either OH’s location settings, the timezone setting on the Java that is running OH, the operating system timezone, or the timezone setting of your database is wrong.
Also be aware in Grafana the charts will always only use GMT for the time scale. That is a deliberate choice made by the developers of Grafana and they are not going to change it.
This is a linux / openhabian installation ?
Check the content of /etc/default/openhab for variable EXTRA_JAVA_OPTS
Does it contain a setting for -Duser.timezone ?