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

Using 1970-01-01 in Date Item overwrites the Time-only flag of DateTime Triggers #4517

Open
simonh1005 opened this issue Dec 23, 2024 · 0 comments
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@simonh1005
Copy link

Expected Behavior

When creating a DateTime Trigger for a rule whith time-only set to false, the rule should not trigger, if the DateTime Items contains a date in the past.

Current Behavior

If the rule contains "1970-01-01 00:00:00", the rule will trigger every 1am in the morning.

Possible Solution

I think, the problem is related to this line of code: https://github.com/openhab/openhab-core/blob/12f2314a2d1cbd3157bead4b6de9159bea37275d/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/DateTimeTriggerHandler.java#L180C21-L180C35

It assumes that the date 1970-01-01 means that the rule is time-only. In the edge-case of a user actually sending this date, this is unexpected behavior.

Steps to Reproduce (for Bugs)

A minimal rule to reproduce this looks like the following:

configuration: {}
triggers:
  - id: "1"
    configuration:
      timeOnly: false
      itemName: Alarmclock_Next_Schedule
      offset: 60
    type: timer.DateTimeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript
      script: 'console.log("Debugging: Timestamp Rue has been triggered")'
    type: script.ScriptAction

Check your logs and you will see that the rule triggered at 1am in the morning.

Context

When trying to implement an alarmclock-rule that is triggered by a datetime trigger, I stumbled over a behavior, where the time-only flag is not working as expected when using a DateTime trigger. As I could not find a way to reset DateTime-Items to UNDEF, I use 1970-01-01 to express, that no date is selected.

Your Environment

  • Version used: 4.3
  • Environment name and version (e.g. Chrome 111, Java 17, Node.js 18.15, ...): Docker Image
  • Operating System and version (desktop or mobile, Windows 11, Raspbian Bullseye, ...): Debian
@simonh1005 simonh1005 added the bug An unexpected problem or unintended behavior of the Core label Dec 23, 2024
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

No branches or pull requests

1 participant