[SOLVED] Two Rules stopped working on OpenHAB 4.0.4

Hi Friends,
I’m currently using OpenHAB 4.0.4 on Unraid using a docker install.
After updating to 4.0.4 two of my rules stopped working. They did work before and other rules appear to be working properly.
One rule is a Good Morning rule, that automates opening all my house’s windows blinds when I press a wall switch to ON state.
The other rule is for Good Night, which turns OFF all the lights and closes all window blinds when I turn the same wall switch to OFF state.

Can some please go over my rules and tell me if they have issues that causes them not to work?

Good Morning rule:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Bedroom_Switch3
      state: ON
      previousState: OFF
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: |
        sendCommand(BedRight_Dimmer3, 72)
          Thread::sleep(300)
        sendCommand(SalonWindow_Dimmer3, 72)
          Thread::sleep(300)
        sendCommand(SalonDesk_Dimmer3, 69)
          Thread::sleep(300)
        sendCommand(Kitchen_Dimmer3, 67)
          Thread::sleep(300)
        sendCommand(Balcony_Dimmer3, 100)
          Thread::sleep(300)
            
        if(SalonBalcony_Dimmer2.state > 72) {
            SalonBalcony_Dimmer2.sendCommand(71)
          }
           //else do nothing

        Thread::sleep(3000) 

        //if(SalonTV_Switch1.state == OFF) {
            //SalonTV_Switch1.sendCommand(ON)
           }
            // else do nothing
    type: script.ScriptAction

Good Night rule:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Bedroom_Switch3
      state: OFF
      previousState: ON
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: |
        
        sendCommand(Entrance_Switch2, OFF)
           Thread::sleep(300) 
        sendCommand(Bedroom_Switch4, OFF)
          Thread::sleep(300)
        sendCommand(SalonTV_Switch1, OFF)
          Thread::sleep(300)
        sendCommand(SalonTV_Switch2, OFF)
          Thread::sleep(300)
        sendCommand(SalonTV_Switch4, OFF)
          Thread::sleep(300)
        sendCommand(SalonDesk_Switch2, OFF)
          Thread::sleep(300)
        sendCommand(Kitchen_Switch1, OFF)
            Thread::sleep(300)
        sendCommand(Kitchen_Switch2, OFF)
          Thread::sleep(300)
        sendCommand(Bathroom_Switch2, OFF)
          Thread::sleep(300)
        sendCommand(Bathroom_Switch4, OFF)
          Thread::sleep(300)
        sendCommand(Balcony_Switch1, OFF)
          Thread::sleep(300)
        sendCommand(Balcony_Switch2, OFF)
          Thread::sleep(300)
        sendCommand(Bedroom_Switch2, OFF)
          Thread::sleep(300)
        sendCommand(Bedroom_Switch4, OFF)
          Thread::sleep(300)



        sendCommand(BedRight_Dimmer3, 0)
          Thread::sleep(300)
        sendCommand(SalonWindow_Dimmer3, 0)
          Thread::sleep(300)
        sendCommand(SalonDesk_Dimmer3, 0)
          Thread::sleep(300)
        sendCommand(Kitchen_Dimmer3, 0)
          Thread::sleep(300)
        sendCommand(Balcony_Dimmer3, 0)
          Thread::sleep(300)
        sendCommand(SalonBalcony_Dimmer2, 0)
          Thread::sleep(300)
        sendCommand(SalonBalcony_Dimmer1, 0)
          Thread::sleep(300)
        sendCommand(Kitchen_Dimmer3, 0)

          Thread::sleep(3000) 
        sendCommand(Kitchen_Dimmer3, 91)
    type: script.ScriptAction

What are the Thread::Sleep commands used/useful for ?

1 Like

These two words can include an infinity. What specifically isn’t working? Errors in the log? Rule doesn’t appear to run at all? Ribs but doesn’t do the right thing?

How it is failing will drive how to discover the problems and fix them.

Add logging to the rules to answer the above question if you don’t already have the answer (e.g. if the first line of the rule is a log and you don’t see that printed you know the rule never triggered).

1 Like

I included the Thread::Sleep commands, because I was advised by other forum users to add pauses between actual commands sent to devices. This way the system won’t send all the commands too fast to all the devices.

By the looks of things, the rules seems to be triggered, but nothing happens.
No commands are being run by the devices that are supposed to run them.

This is only required for certain technologies like Hue. Most support getting all the commands all at once.

How are you verifying this? Show us the logs or whatever evidence you are using to verify this.

How are you verifying this? Show us the logs or whatever evidence you are using to verify this.

In short, there is nothing obviously wrong with the rule. We still have nearly an infinity of “not working” to narrow down to the real cause and you are giving us very little to work with.

1 Like

Thanks, Rick, for your ongoing willingness to help.
I managed to solve the problem by using the code of a still functioning rule as a new basis for the rules that stopped working.
All rules are now working again. I guess I somehow introduced a coding error into the the two failing rules.
All is good now.