Rules - time switch for a lightbulp

The door contact opening and closing:


tail -f /var/log/openhab/openhab.log /var/log/openhab/events.log

2021-03-18 15:21:02.669 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EingangsturKontaktBitronVideo90201021A_ContactPortal1' changed from CLOSED to OPEN

2021-03-18 15:21:05.770 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EingangsturKontaktBitronVideo90201021A_ContactPortal1' changed from OPEN to CLOSED

Probably not. In the interest in time I’ll just state what rossko57 is trying to hint at.

Your Rule will trigger every time your Item updates to OPEN. Those logs you are looking at only show changes, not updates (which is why I directed you to the Developer Sidebar).

Note, only one instance of this rule can run at a time. So if your contact updates to OPEN in that 15 seconds where it’s asleep, it’s going to wait and then run the rule again. Maybe using a rule that doesn’t trigger so often. Perhaps only triggering the rule when the Item changes to OPEN might work better.

That’s what rossko57 is trying to say.

But you still have a problem. If you open the door, close it, open it again, and close it again all within 15 seconds (not an unreasonable) what will happen is your light will turn on for 15 seconds, turn off for moment then turn on again for 15 seconds.

That is almost certainly undesirable and it is why the sleep is a dead end for something like this.

I got it - finally!

triggers:
  - id: "1"
    configuration:
      itemName: EingangsturKontaktBitronVideo90201021A_ContactPortal1
      state: OPEN
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: |
        FlurDeckeLEDVANCECLA60RGBWZ3_Color.sendCommand(ON)
        createTimer(now.plusMinutes(3), [ | 
        FlurDeckeLEDVANCECLA60RGBWZ3_Color.sendCommand(OFF)])
    type: script.ScriptAction

This does the trick - a simple light switch. I’m so so happy I got it working. :slight_smile: