Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimeTrigger not taking timezones into account #3059

Closed
m4rcu5 opened this issue Aug 10, 2022 · 5 comments · Fixed by #3060
Closed

DateTimeTrigger not taking timezones into account #3059

m4rcu5 opened this issue Aug 10, 2022 · 5 comments · Fixed by #3060
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@m4rcu5
Copy link

m4rcu5 commented Aug 10, 2022

Hi,

It looks like the DateTimeTrigger implemented in #2923 is not taking into account the timezones which might be included in the item. The trigger treats all timestamps as local time.

Further discussion is available on the forum

Testing platform:

  • openHAB 3.3.0-1 via APT
  • Debian 11.3 for ARM
  • Kernel 5.4.199-odroidxu4 armv7l

Testing rule

rule "DateTimeTrigger timezones"
when
    Time is MyTestDateTime
then
    logInfo("DateTimeTrigger", "The test DateTime item caused a trigger!")
end

Setting a timestamp with UTC timezone

openhab> openhab:send MyTestDateTime 2022-08-10T11:29:00.000+0000
Command has been sent successfully.

Log output

2022-08-10 11:28:26.844 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'MyTestDateTime' received command 2022-08-10T11:29:00.000+0000
2022-08-10 11:28:26.855 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'MyTestDateTime' changed from NULL to 2022-08-10T11:29:00.000+0000
2022-08-10 11:29:00.939 [INFO ] [ab.core.model.script.DateTimeTrigger] - The test DateTime item caused a trigger!

Setting a timestamp with CEST timezone

openhab> openhab:send MyTestDateTime 2022-08-10T11:33:00.000+0200
Command has been sent successfully.

Log output

2022-08-10 11:32:31.064 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'MyTestDateTime' received command 2022-08-10T11:33:00.000+0200
2022-08-10 11:32:31.096 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'MyTestDateTime' changed from 2022-08-10T11:29:00.000+0000 to 2022-08-10T11:33:00.000+0200
2022-08-10 11:33:00.117 [INFO ] [ab.core.model.script.DateTimeTrigger] - The test DateTime item caused a trigger!
@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/datetimetrigger-and-timezones/138014/4

@jimtng
Copy link
Contributor

jimtng commented Aug 10, 2022

@m4rcu5
Copy link
Author

m4rcu5 commented Aug 10, 2022

Thanks @jimtng for resolving the issue.

I am afraid the jar does not seem to be compatible with the version of openHAB I am running (3.3.0-1). Triggering the following error:

==> /var/log/openhab/openhab.log <==
2022-08-10 14:01:18.389 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.core.automation-3.4.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.core.automation [315]
  Unresolved requirement: Import-Package: org.openhab.core; version="[3.4.0,4.0.0)"

@jimtng
Copy link
Contributor

jimtng commented Aug 10, 2022

I uploaded a 3.3 jar in the same release page above. The version number would be different but you should be able to spot it.

@m4rcu5
Copy link
Author

m4rcu5 commented Aug 10, 2022

👍 looks like that works as expected

openhab> openhab:send MyTestDateTime 2022-08-10T15:43:00.000+0200
Command has been sent successfully.

2022-08-10 15:42:50.563 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'MyTestDateTime' received command 2022-08-10T15:43:00.000+0200
2022-08-10 15:42:50.580 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'MyTestDateTime' changed from 2022-08-10T11:33:00.000+0200 to 2022-08-10T15:43:00.000+0200
2022-08-10 15:43:00.627 [INFO ] [ab.core.model.script.DateTimeTrigger] - The test DateTime item caused a trigger!


openhab> openhab:send MyTestDateTime 2022-08-10T15:44:00.000+0000
Command has been sent successfully.

2022-08-10 15:43:51.769 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'MyTestDateTime' received command 2022-08-10T15:44:00.000+0000
2022-08-10 15:43:51.806 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'MyTestDateTime' changed from 2022-08-10T15:43:00.000+0200 to 2022-08-10T15:44:00.000+0000
<< NOTHING >>


openhab> openhab:send MyTestDateTime 2022-08-10T13:45:00.000+0000
Command has been sent successfully.

2022-08-10 15:44:53.110 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'MyTestDateTime' received command 2022-08-10T13:45:00.000+0000
2022-08-10 15:44:53.137 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'MyTestDateTime' changed from 2022-08-10T15:44:00.000+0000 to 2022-08-10T13:45:00.000+0000
2022-08-10 15:45:00.161 [INFO ] [ab.core.model.script.DateTimeTrigger] - The test DateTime item caused a trigger!

@J-N-K J-N-K added the bug An unexpected problem or unintended behavior of the Core label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants