Dummy Switches work for a week or so, and then simply stop

  • Platform information:

    • Hardware: Running inside a VirtualBox VM, with 2 GB Ram + 2 Cores (Host Machine is an Intel Xenon E3-1281 v3, 32GB Ram)
    • OS: Ubuntu 20.04.2 LTS
    • Java Runtime Environment:
      openjdk version “11.0.11” 2021-04-20 LTS
      OpenJDK Runtime Environment Zulu11.48+21-CA (build 11.0.11+9-LTS)
      OpenJDK 64-Bit Server VM Zulu11.48+21-CA (build 11.0.11+9-LTS, mixed mode)
    • openHAB version: 3.0.2
  • Issue of the topic: I’ve noticed after about a week or so of OpenHAB being up and running, certain rules suddenly stop triggering, namely Dummy Switches I’ve created which other rules are based off of, that are set by the Astro binding.

  • Please post configurations (if applicable):

Home.rules:

// Sunrise
rule "Sunrise Functions"
when
    Channel 'astro:sun:local:rise#event' triggered START
then
    logInfo("home.rules", "Sunrise Functions Active")

    logInfo("home.rules", "IsItDark OFF.")
    Switch_IsItDark.postUpdate(OFF)

    logInfo("home.rules", "Switch_IsItNight OFF.")
    Switch_IsItNight.postUpdate(OFF)

    logInfo("home.rules", "Switch_BathroomLightDim OFF.")
    Switch_BathroomLightDim.postUpdate(OFF)

    createTimer(now.plusSeconds(5), [|
        logInfo("home.rules", "LightSwitchLEDs OFF.")
        LightSwitchLEDs.sendCommand(OFF)
    ])
end

// Sunset
rule "Sunset Functions"
when
    Channel 'astro:sun:local:civilDusk#event' triggered START
then
    logInfo("home.rules", "Civil Dusk Functions Active")

    logInfo("home.rules", "IsItDark ON.")
    Switch_IsItDark.postUpdate(ON)

    logInfo("home.rules", "LightSwitchLEDs ON.")
    LightSwitchLEDs.sendCommand(ON)
end

// Night
rule "Night Functions"
when
    Channel 'astro:sun:local:night#event' triggered START
then
    logInfo("home.rules", "Night Functions Active")

    logInfo("home.rules", "Switch_IsItNight ON.")
    Switch_IsItNight.postUpdate(ON)
end

// Persistence and Time-Based Rules
rule "Bathroom Light set to Dim at 11:30pm"
when
    Time cron "0 30 23 1/1 * ? *"
then
    logInfo("home.rules", "Switch_BathroomLightDim ON.")
    Switch_BathroomLightDim.postUpdate(ON)
end

home.items:

Switch    Switch_IsItDark              "IsItDark (Dusk to Dawn)"    <moon>
Switch    Switch_IsItNight                                          <moon>

Switch    Switch_BathroomSwitchUsed    "Bathroom Switch Used"
Switch    Switch_BathroomLightDim      "Bathroom Light Dim"

(After a week +/- a couple days of uptime, the following simply does not trigger. I can see in my events.log that the astro items are still updating, and found the Triggered START for the sunrise event in events.log as well:
2021-05-02 06:08:00.001 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:local:rise#event triggered START Just this morning, but none of the dummy switches changed from On to Off, and I have to trigger them manually through a Debug page I set up on my Sitemap so I can toggle them myself.

The “Switch_IsItDark” is used for automatically enabling certain lights to come on/go off when doors are opened/closed in the evening once CivilDusk is triggered.

The “Switch_IsItNight” is used for automatically setting the brightness of certain lights when you flip a switch (Kitchen/Bedroom etc, once Night is triggered.

The “BathroomLightDim” switch is triggered at a time specifically, which when the Bathroom Door, or Bathroom switch is used, overrides the default brightness to 3% so mid-night bathroom usage provides enough light to see what you are doing without fully waking you up.

autolights.rules Example:

rule "Bathroom Light On"
when
    Item Light_UL_BathroomBrightness received command ON or
    Item Light_UL_BathroomBrightness changed from 0 or
    Item Sensor_UL_BathroomDoor changed from OPEN to CLOSED
then 

    if((Light_UL_BathroomBrightness.state > 1) && (Sensor_UL_BathroomDoor.state == OPEN)){
        //Light triggered by switch, Ignore Door.
        Switch_BathroomSwitchUsed.postUpdate(ON)
    }

    if (Switch_BathroomLightDim.state == ON){
        Light_UL_BathroomBrightnessLevel = 3    
    } else {
        Light_UL_BathroomBrightnessLevel = 100
    }

    if (Switch_IsItDark.state == ON){

        if (Switch_BathroomSwitchUsed.state == ON){
            createTimer(now.plusSeconds(1), [|
                Light_UL_BathroomBrightness.sendCommand(100)
            ])

        } else {
            Light_UL_BathroomBrightness.sendCommand(Light_UL_BathroomBrightnessLevel)
        }

    } else {

        if (Switch_BathroomSwitchUsed.state == ON){
            createTimer(now.plusSeconds(2), [|
                Light_UL_BathroomBrightness.sendCommand(100)
            ])
        }

    }

rule "Bathroom Light Off Switch Used"
when
    Item Light_UL_BathroomBrightness changed to 0
then

    if(Switch_BathroomSwitchUsed.state == ON){
        Switch_BathroomSwitchUsed.postUpdate(OFF)
    }
    
end

rule "Bathroom Light Off Door Used"
when
    Item Sensor_UL_BathroomDoor changed from CLOSED to OPEN
then

    if(Switch_BathroomSwitchUsed.state == OFF){
        createTimer(now.plusSeconds(2.5), [|

            //Double check door is still open before turning off.
            if(Sensor_UL_BathroomDoor.state == OPEN){
                Light_UL_BathroomBrightness.sendCommand(OFF)
            }

        ])
        //}
    }
    
end

I don’t mind occasionally rebooting OpenHAB, but I don’t believe this should be something that is required just to keep things functioning. This issue seems to have cropped up within the past 2 months, and I’ve just been living with it until now. My biggest issue with rebooting, is all my Sonoff ZigBee Door Sensors and switches, require toggling 2-3 times after a reboot before they are picked back up and are detected, so I have to go and open/close each door 2-3 times about 5 minutes after rebooting to get OpenHab to pick them back up again, else they just show Offline or Unknown under my OpenHAB things in the Web UI.

Any suggestions on what can be done to mitigate having to reboot quite so often just to get my Astro Binding to start triggering properly again?