Now.gethourofday Incorrect time

Raspberry Pi 4, openHAB 2.4

Since the clocks went back last night in the UK my rules I have set using now.gethourofday are 60 minutes late. Is there anyway I can change this or is it a case of changing all my rules to be 60 out?

Also checked the pi current time and that is correct, even the times on the openHAB logs is correct. It’s only the rules that are out by 60 minutes.


Have you verified the time zone settings?

1 Like

Yes both in Pi Config and Paper UI. Both are correct

1 Like

In the OS too? Type date +%Z to check.

Much depends on what gethourofday is expected to return. The end of the second hour today was 0200, the end of the third hour was also 0200.

1 Like

So it will be anomaly just for the day the clocks change?

[11:12:54] openhabian@openhab : ~ $ date +%Z


[11:15:05] openhabian@openhab : ~ $ date

Mon 28 Oct 2019 11:15:24 AM GMT

[11:15:24] openhabian@openhab : ~ $

It’ll probably “come out in the wash” today, but we don’t really know what your ‘anomaly’ is or how you are using gethourofday. It might be improved with use of zonedDateTime.

GMT does not have daylight savings or “summer time” That could be your issue.

The time at the command line is correct, where does the ‘Now.gethourofday’ get its time from?

Below is the example of the rule, so the issue is its only operating currentHour >16.

rule "Turn Sidelight On_LUX"
        Item WeatherUV2 changed
        var CurrentHour = now.getHourOfDay

        if(CurrentHour <7 || CurrentHour >15){
        if (GroundLights.state == OFF && WeatherUV2.state < 120){
        sendBroadcastNotification("Side Lights ON")