Simple Rules dealing with time not working, openhab3

  • Platform information:
    • Hardware: Raspberry Pi 4 8gb
    • OS: Openhabian
    • Java Runtime Environment: default
    • openHAB version: 3.0.2
  • Issue of the topic: When a rule is created that uses a built-in time function, or when it relies on it in some way, the rule does not work correctly or fails to fire at all.
    code:
triggers:
  - id: "1"
    configuration:
      itemName: AndroidPhone_Online
      state: ON
    type: core.ItemStateUpdateTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      startTime: 19:00
      endTime: 05:00
    type: core.TimeOfDayCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: StoveLight_StoveLight
      command: ON
    type: core.ItemCommandAction
  - inputs: {}
    id: "4"
    configuration:
      itemName: BedLamp_BedLamp
      command: ON
    type: core.ItemCommandAction

This will fire every-time the item changes to ON, regardless of time of day. I have 2 additional rules that start and stop an air filter everyday at a certain time, which have never worked. I will post code for one of them:

triggers:
  - id: "1"
    configuration:
      time: 08:00
    type: timer.TimeOfDayTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: AirFilter_AirFilter
      command: ON
    type: core.ItemCommandAction

Any help is greatly appreciated. I have not found anyone having a similar issue, but I using the most basic rule setup that I can, so i am not sure what is the issue. The rules work fine when run manually, they just don’t seem to pay attention to system time.

Thank you.

cron based rules seem to fail in the same way. perhaps something about the system clock? The clock seems to work fine on my pages.

Define “does not work correctly”. “Fails to fire” is clear enough but this points to two potentially unrelated problems.

Time periods that span midnight are always a challenge. You will likely need to add two conditions. One from 19:00-24:00 and another from 00:00-05:00. I suspect it’s not smart enough to understand how to handle a time period that spans midnight.

If this fixes that problem, file an issue on openhab-core because it should be possible to identify this use case when endTime is before the startTime and go down a different set of code to do the comparison.

How do you know it’s never worked? There is a whole bunch of stuff between a rule and a device. If you are just looking at the physical device to see if it’s on then you really have no idea where it’s failing. It could be that this rule isn’t firing. But it’s equally as likely that there is a problem with the Item, the network, the Thing, or something else.

Look in events.log at the entries around 08:00. Do you see AirFilter_AirFilter receiving an ON command? Are you certain the Item is named correctly? That’s an odd Item name.

The rule that triggers at a particular time of day does not fire at all. (when you manually trigger the rule, it works perfectly as intended. The other rule, that is conditional on a range of time, fires correctly, but does not pay any attention to the condition. Are there other places that it can fail between the rule and the device, when the rule works separate from the trigger?

I changed as suggested:

triggers:
  - id: "1"
    configuration:
      itemName: JustinsAndroidPhone_Online
      state: ON
      previousState: OFF
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      startTime: 19:00
      endTime: 23:00
    type: core.TimeOfDayCondition
  - id: "5"
    configuration:
      startTime: 00:00
      endTime: 05:00
    type: core.TimeOfDayCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: StoveLight_StoveLight
      command: ON
    type: core.ItemCommandAction
  - inputs: {}
    id: "4"
    configuration:
      itemName: BedLamp_BedLamp
      command: ON
    type: core.ItemCommandAction

This did not seem to make any difference.

I do not see an entry for the airfilter to start at 0800… {the item name was autogenerated when I created the link to the channel for a simple sonoff (tasmota and mqtt) switch}. However, I think I see the issue.
from my events.log:

2021-06-09 22:05:09.444 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Roomba595_RoombaBatteryLevel' changed from 100 to 2
2021-06-09 22:05:12.243 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PlexServer_Latency' changed from 0.0 ms to 1.0 ms
2021-06-09 22:05:12.245 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PlexServer_LastSeen' changed from 2021-06-09T22:04:12.230+0200 to 2021-06-09T22:05:12.235+0200

It seems that the system time is not correct. It is currently 13:05, and the last event in the log is from around 22:05.

So things are likely working fine, but at the completely wrong time of day.

I will work on this. Thank you.

Appears to work now. It was a matter of changing the time zone in openhabian-config after logging into the pi. then enabling NTP, though I doubt that was required. I thought I had the timezone correct, and it was correct for the UI, as my clocks all worked correctly. However, anything that used the system time, like rules apparently failed.

It is unclear whether or not the over-night condition played a role, I have it changed currently and it seems to work, it did not work (obviously) prior to changing the system time.

Thank you for your help. I am still learning where to look to figure things out. This was enlightening.