Good morning, although somewhat earlier as planned.
I am working on some Date/Time based rules to trigger automation around the house. One of which being a sunrise routine in the bedroom.
This is where I noticed that the DateTimeTigger
seems to be ignoring the timezone, and treats the time as local.
For example, using the Android app to set the AlarmClock
item, which it does in UTC time. After which my rule set a second item a bit earlier.
2022-08-09 23:28:10.261 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'AlarmClock' received command 2022-08-10T06:30:00.000+0000
2022-08-09 23:28:10.272 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'AlarmClock' changed from 2022-08-10T05:00:00.000+0000 to 2022-08-10T06:30:00.000+0000
2022-08-09 23:28:10.312 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Bedroom_VirtualSunrise' received command 2022-08-10T05:55:00.000+0000
2022-08-09 23:28:10.318 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Bedroom_VirtualSunrise' changed from 2022-08-10T04:25:00.000+0000 to 2022-08-10T05:55:00.000+0000
That time is set by the following rule:
rule 'Set Virtual Sunrise time' do
changed AlarmClock
run do |event|
if event.item.state?
Bedroom_VirtualSunrise << event.item - 35.minutes
else
Bedroom_VirtualSunrise.update(NULL)
end
end
end
To create the virtual sunrise, I’m using the following rule, mostly a copy paste, straight from the documentation:
rule 'Virtual Sunrise' do
description 'Create a virtual sunrise before the alarm clock sounds'
trigger 'timer.DateTimeTrigger', itemName: Bedroom_VirtualSunrise.name
run do
BlindsBedroomWindow_Vane.ensure.command(50)
end
end
However this morning, I had a early rise and shine
2022-08-10 05:55:00.389 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'BlindsBedroomWindow_Vane' received command 50
2022-08-10 05:55:00.391 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'BlindsBedroomWindow_Vane' predicted to become 50
2022-08-10 05:55:00.404 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'BlindsBedroomWindow_Vane' changed from 0 to 50
Note: Timestamps in the logs are local time - Europe/Amsterdam, UTC +2 CEST
I have a different rule to run a Time Of Day routine, which is linked to the astro
binding, which seems to set the time in local time, and this one works fine.
The item:
openhab> openhab:status ToD_Day
2022-08-10T06:21:00.000+0200
The rule:
ToD = %w[ Day Afternoon Evening ]
ToD.each do |t|
rule "Set Time of Day to #{t}" do
trigger 'timer.DateTimeTrigger', itemName: 'ToD_' + t
run { items['TimeOfDay'].command(t) }
end
end
The logs:
2022-08-10 06:21:00.729 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TimeOfDay' received command Day
2022-08-10 06:21:00.732 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TimeOfDay' changed from Evening to Day
As both the sunrise and the timeofday items clearly include a timezone/offset, I would expect that any triggers would compensate for this.
I’m not sure if this is a JRuby issue, a upstream issue at the DateTimeTrigger
implementation, or a issue that sites between my keyboard and chair