DateTimeTrigger didn't trigger

I’ve put my “time off” (“vakantie” in Dutch) from work in my Google Calendar, and have its beginning and ending converted into DateTime Items.

These DateTime Items then trigger a rule:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: startschoolvakantie
      timeOnly: false
    type: timer.DateTimeTrigger
  - id: "2"
    configuration:
      itemName: startschoolvakantie1
      timeOnly: false
    type: timer.DateTimeTrigger
  - id: "3"
    configuration:
      itemName: eindeschoolvakantie1
      timeOnly: false
    type: timer.DateTimeTrigger
  - id: "4"
    configuration:
      itemName: eindeschoolvakantie2
      timeOnly: false
    type: timer.DateTimeTrigger
  - id: "6"
    configuration:
      itemName: schoolvakantie_switch
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "5"
    configuration:
      type: application/javascript
      script: |-
        var itemnaam = event.itemName;
        var pythoninvenv = '/var/lib/openhab/bin/python/tado-manual-control/venv/bin/python';
        var pythonscript = '/var/lib/openhab/bin/python/tado-manual-control/tado-manual-control.py';
        var pythonwachttijdinseconden = 10;

        function callPython(command) {
          var pythonOutput = actions.Exec.executeCommandLine(time.Duration.ofSeconds(pythonwachttijdinseconden), command);
          console.log("python output = "+pythonOutput);
        }


        function startVakantieschemaTado() {
          var command = [pythoninvenv, pythonscript, 'set_schedule_type', '-s',  '0'];
          callPython(command);
        }


        function startWerkchemaTado() {
          var command = [pythoninvenv, pythonscript, 'set_schedule_type', '-s',  '2'];
          callPython(command);
        }


        if (event.itemName == "schoolvakantie_switch") {
          var nieuwestaat = event.newState;
          if (nieuwestaat == "ON") {
            startVakantieschemaTado();
          } else if (nieuwestaat == "OFF") {
            startWerkchemaTado();
          }
        } else if (itemnaam.startsWith("start")) {
          items["schoolvakantie_switch"].sendCommand("ON");
        } else if (itemnaam.startsWith("einde")) {
          items["schoolvakantie_switch"].sendCommand("OFF");
        }
    type: script.ScriptAction

So eindeschoolvakantie1 should have triggered this rule Monday morning. But it didn’t. This is an extract from events.log:

2026-02-22 23:59:46.609 [INFO ] [openhab.event.ItemStateChangedEvent  - 449       ] - Item 'Stopcontact_gasbrander_Power_Consumption' changed from 6 W to 5.9 W (source: org.openhab.core.thing$shelly:shellyplusplug:e4b32339c760:meter#currentWatts)
2026-02-23 00:00:00.031 [INFO ] [openhab.event.ItemStateChangedEvent  - 449       ] - Item 'Wasmachine_Power_Consumption' changed from 0.4 W to 0.3 W (source: org.openhab.core.thing$shelly:shellyplus1pm:d4d4da7df8a8:meter#currentWatts)
2026-02-23 00:00:00.181 [INFO ] [openhab.event.ItemStateChangedEvent  - 449       ] - Item 'startschoolvakantie1' changed from 2026-02-14T00:00:00.000+0100 to UNDEF (source: org.openhab.core.thing$icalendar:calendar:schoolvakantiekalender:current_start)
2026-02-23 00:00:00.182 [INFO ] [openhab.event.ItemStateChangedEvent  - 449       ] - Item 'eindeschoolvakantie1' changed from 2026-02-23T00:00:00.000+0100 to UNDEF (source: org.openhab.core.thing$icalendar:calendar:schoolvakantiekalender:current_end)

I thought that maybe the DateTime Item would be updated prior to the time it should trigger the rule. But that doesn’t seem the case. Unless I don’t understand 2026-02-23T00:00:00.000+0100 correctly, it should come before 2026-02-23 00:00:00.181, right?

Or is 181 ms not enough time to trust this to work? In that case, does someone have an idea on how to tackle this?

Thanks in advance!

No, but this is much easier to handle with

Yes, I get the DateTime Items via the iCalendar binding.

But I’m guessing you mean there’s some ‘trigger’ function directly via the binding?

That’s not how the “time is Item” trigger works. The rule should trigger based on the state of the Item but there is no separate event that you’ll see in events.log when that happens.

However, 181 milliseconds after when the rule was supposed to run the Item got set to UNDEF by the iCal binding. It seems reasonable that this change to UNDEF cancelled the rule trigger or it occurred before the rule could trigger. OH isn’t really a fault-tolerant nor a real-time system. There are lots of gray area when things happen really close together like that. the order of the processing of the events is not guaranteed. There is also no guarantee about how timely an event will be acted upon.

Some ideas:

Use a different Item which doesn’t get set to UNDEF quite so quickly. You can transfer the date time to this non-linked Item and that Item won’t get reset by the binding so it won’t go to UNDEF before the rule can trigger.

Use a different approach with your calendar entries. For example, create a short event that starts at the time you want the rule to run instead of ending at that time.

Use Ephemeris instead of iCal.

Not an event Channel (as far as I can tell) but you can configure the calendar entry command tags to command an Item from the calendar entry. iCalendar - Bindings | openHAB

Configure the calendar entry to send a command to a Switch or something when the event ends.

Yes, you can command for example a switch to ON at the beginning of that entry
I start hvac for our car that way.
You can also command something at the end of the entry …

I see. So that’s just a string in the calendar event? I’ll give it a go!

That sounds reasonable, indeed.

A string in the notes section of the calendar event.

1 Like

I ran a test this weekend, and this worked like a charm!

I had originally not understood what was meant in the binding docs. I understood “event” as some openHAB “event”, which confused me…

1 Like