OH3->OH4 just one hurdle left ... ephemTimeOfDay JS script fails

IC.
My influxDB system fails with a timeout during startup, and my RRD4j system is not able to persist strings?

Since Default_Day.sendCommand(“09:00:00”), why does both systems change state at 10:00?

2023-05-26 10:00:00.006 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from MORNING to DAY
2023-05-26 10:00:00.006 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from MORNING to DAY
2023-05-26 10:00:00.006 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from MORNING to DAY
2023-05-26 10:00:00.007 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from MORNING to DAY
2023-05-26 10:00:00.007 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from MORNING to DAY
2023-05-26 10:00:00.010 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from MORNING to DAY
2023-05-26 10:00:00.010 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from MORNING to DAY
2023-05-26 08:00:00.002 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from NIGHT to MORNING
2023-05-26 10:00:00.001 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from MORNING to DAY

And Default_Morning.sendCommand(“06:00:00”) at 07:00?

Is it related to Regional time setting? (Which don’t seem to follow DST automatically).

correct.

For maximum robustness I recommend:

  • MapDB configured to just do restoreOnStartup. It’s embedded so it will always be there and it will be very fast.

  • rrd4j for stuff you want to chart configured without restoreOnStartup

  • External databases only for those Items you want to do some serious analysis on using external tools

This gives the maximum robustness to meet all of those requirements.

You’ve got a timezone issue somewhere. There are multiple places where the timezone can be taken from:

  • operating system
  • JVM
  • openHAB regional settings

Most of the time, when there is a problem with timezones it can be fixed by setting it on the JVM side. There are tons of posts on the forum but I believe it just involves adding extra options to the java command that kicks off OH and there is a config file somewhere that does that. I don’t have an installed version of OH, just Docker and I can set the timezone through an environment variable with that sort of install. I can’t tell you where it is on an installed OH.

Well. I checked everything:
OS:

omr@shs2:~$ date -R
Fri, 02 Jun 2023 00:37:19 +0200
omr@shs2:~$ cat /etc/timezone
Europe/Oslo

JVM:

EXTRA_JAVA_OPTS="-Duser.timezone=Europe/Oslo"

openHAB:

Still all state changes are 2hrs behind.
I decided to take a more simple approach:

// Time Of Day
rule "06_00"
when
        Time cron "0 0 6 ? * * *" // 06:00 
then 
        TimeOfDay.sendCommand("MORNING")
        logInfo("TimeOfDay", "Transitioning from BED to MORNING")
end

rule "09_00"
when
        Time cron "0 0 9 ? * * *" // 09:00 
then 
        TimeOfDay.sendCommand("DAY")
        logInfo("TimeOfDay", "Transitioning from MORNING to DAY")
end

rule "18_00"
when
        Time cron "0 0 18 ? * * *" // 18:00 
then 
        TimeOfDay.sendCommand("EVENING")
        logInfo("TimeOfDay", "Transitioning from DAY to EVENING")
end

rule "23_00"
when
        Time cron "0 0 23 ? * * *" // 23:00 
then 
        TimeOfDay.sendCommand("NIGHT")
        logInfo("TimeOfDay", "Transitioning from EVENING to NIGHT")
end

rule "00_00"
when
        Time cron "0 0 0 ? * * *" // 00:00 
then 
        TimeOfDay.sendCommand("BED")
        logInfo("TimeOfDay", "Transitioning from NIGHT to BED")
        vDayOfWeek.sendCommand(now.getDayOfWeek.toString())
        logInfo("System", "DAY=" + now.getDayOfWeek)
end

Works fine:

yaml
omr@shs2:~$ grep -i transition /var/log/openhab/openhab.log | grep -i trans
2023-06-01 20:00:00.003 [INFO ] [omation.rules_tools.TimeStateMachine] - Transitioning Time State Machine from DAY to EVENING
2023-06-01 23:00:00.496 [INFO ] [.openhab.core.model.script.TimeOfDay] - Transitioning from EVENING to NIGHT
2023-06-02 00:00:00.495 [INFO ] [.openhab.core.model.script.TimeOfDay] - Transitioning from NIGHT to BED

But, I will always wonder why it didn’t work out with the template …

All I can think of is that the TZ on the DateTime Item states themselves was off, or maybe the times themselves.

I do recommend the simpler approach anyway in cases where you don’t have a different set of times based on the type of the day. It would be interesting to see what would happen if you used the Time is <Item> timeOnly trigger instead of cron. Would those still trigger two hours off?