openHAB 5.2 Release discussion

Hello guys.

I faced this “case” in 5.2.1, and I wasn’t sure if it was important to mention it here.

I followed the topic through the thread and learned why it happens

And

I followed the recommendation and moved the other rule to another separate file, and the problem stopped, but I also read that there might be a solution in 5.2.1. However, it doesn’t work (if it was indeed implemented).

About my rule, the “parent” rule runs with a cron every minute to check the window contact sensors (4 at the moment) and evaluate if the window has been open longer than two thresholds (cold, very cold) specified for the room where the specific contact is located. If one of the thresholds has been exceeded, it sends a command to a Switch item (enable the alert. Each alert switch is member of a group switch), triggers a voice notification, and sends a message via Telegram. This rule finishes without issues in about 50 milliseconds.

The “sub-rule” gets triggered once the alerts group switch changes from OFF to ON. This rule stores the status of two lights, switches some sensors off, and changes the two lights to red. This is the rule that throws the error mentioned above.

Since I updated to 5.2.1, I also noticed that while Main UI loads quickly, many times the status of all items on every page takes 2-10 seconds to load, both on a laptop’s browser and on the iPhone’s app, connected via Wi-Fi to the network.
Since Main UI was introduced, I haven’t had this issue. Either the whole interface (including the status of the items) took a little while to load, or everything loaded at once.

I can’t say for sure whether it was fixed in 5.2.1, because I had already reworked my scripts in 5.2.0 to work around the issue.

I think you need to paste the rules (or a simplified version that still exhibit the problem) here to figure out what the problem is. I’m assuming that you’re using the shared cache to access the shared objects?

I don’t store or retrieve data from cache storage, only from persisted storage.

Here is the recurrent rule:

/*
    Version: 1.0
*/

// remove namespaces that are not needed by your code
//const { actions, cache, items, things, time, triggers, utils, Quantity } = require('openhab')
const { items, triggers, actions, time } = require('openhab')
var { PercentType } = require('@runtime');
var Heating = require('heating')
var Notification = require('notification')

rules.JSRule({
    name: "Check contact sensors",
    description: "This rule will check every minute if any contact sensor has been open for longer than the allowed time based on the outside temperature. If it finds any, it will trigger the alert for that sensor and send a notification to the user.",
    triggers: [triggers.GenericCronTrigger('0 0/1 * ? * *')],
    execute: () => {
        console.debug("Contact Sensors > Check contact sensors > STARTING.")
        if (items.Override_Home_Away.state === 'OFF' && items.Override_Vacation_Mode.state === 'OFF' && items.Season.state != "SUMMER") {
            console.debug("Contact Sensors > Check contact sensors > The home is in active mode and the season is " + items.Season.state)
            console.debug("Contact Sensors > Check contact sensors > Iterating through the members of the group group_Sensors_Contact_Open.")
            items.group_Sensors_Contact_Open.members.forEach(sensor => {
                if (sensor.type === 'Switch') {
                    console.debug("Contact Sensors > Check contact sensors > The item %s is a switch.", sensor.name)
                    var roomName = sensor.name.split("_")[0]
                    console.debug("Contact Sensors > Check contact sensors > Evaluating the %s contact sensor.", roomName)
                    var room_alert = items.getItem(roomName + "_Sensor_Contact_Window_1_Alert")
                    var contactsensor_override = items.getItem(roomName + "_Sensor_Contact_AutomationOverride")
                    if (sensor.state === 'ON' && room_alert.state === 'OFF' && contactsensor_override.state === 'ON') {
                        console.debug("Contact Sensors > Check contact sensors > The sensor's status is open, the alarm is off, and the sensor's override is ON.")
                        var time_open = time.toZDT(items.getItem(roomName + "_Sensor_Contact_Window_1_LastOpened").state)
                        const outside_temp = items.Weather_OWM_Temperature.numericState
                        const threshold_cold = items.HM_Temperature_Threshold_Cold.numericState
                        const threshold_cool = items.HM_Temperature_Threshold_Cool.numericState
                        const forecastTemperature = items.Weather_OWM_Temp_h2.numericState
                        var threshold_minutes = 0.00
                        const roomName_transformed = actions.Transformation.transform('MAP', 'locations.map', roomName)
                        console.debug("Contact Sensors > Check contact sensors > Evaluating the temperature outside.")
                        if (outside_temp <= threshold_cold && forecastTemperature <= threshold_cold) {
                            console.debug("Contact Sensors > Check contact sensors > The current and forecasted temperatures are below the cold threshold. Evaluating the rules for cold weather.")
                            threshold_minutes = items.HM_Time_Threshold_Cold_Open.numericState
                            if (time.ZonedDateTime.now().minusMinutes(threshold_minutes).isAfterTime(time_open)) {
                                console.debug("Contact Sensors > Check contact sensors > The %s has been open longer than required. Notifying and triggering the alarm.", roomName)
                                room_alert.sendCommand("ON")
                                var message = "The window in the " + roomName_transformed + " has been open for more than " + threshold_minutes + " minutes. It's time to close it."
                                actions.Voice.say(message, new PercentType(items.Home_Notifications_DefaultVolumeLevel.numericState))
                                Notification.alert("Rosie > " + message)
                            }
                        } else if (outside_temp <= threshold_cool && forecastTemperature <= threshold_cool) {
                            console.debug("Contact Sensors > Check contact sensors > The current and forecasted temperatures are below the cool threshold. Evaluating the rules for cool weather.")
                            threshold_minutes = items.HM_Time_Threshold_Cool_Open.numericState
                            if (time.ZonedDateTime.now().minusMinutes(threshold_minutes).isAfterTime(time_open)) {
                                console.debug("Contact Sensors > Check contact sensors > The %s has been open longer than required. Notifying and triggering the alarm.", roomName)
                                room_alert.sendCommand("ON")
                                var message = "The window in the " + roomName_transformed + " has been open for more than " + threshold_minutes + " minutes. It's time to close it."
                                actions.Voice.say(message, new PercentType(items.Home_Notifications_DefaultVolumeLevel.numericState))
                                Notification.alert("Rosie > " + message)
                            }
                        } else {
                            console.debug("Contact Sensors > Check contact sensors > The current or forecasted temperatures are above the cool threshold. No changes will be applied")
                        }
                    } else {
                        console.debug("Contact Sensors > Check contact sensors > The contact sensor is off, the room alert is already on, or the contact sensor override is off. No changes will be applied")
                    }
                } else {
                    console.debug("Contact Sensors > Check contact sensors > There is a strange item in the list: %s", sensor.name)
                }
            })
        }
        console.debug("Contact Sensors > Check contact sensors > ENDING.")
    },
    tags: ["Sensors","Contact Sensors"],
    id: "CheckContactSensors"
})

And the one triggered once the alert group changes to ON. This is the one that throws the error.

var Lights = require('lights')

rules.JSRule({
    name: "Alert On",
    description: "When the alert for a contact sensor is turned on, this rule will set the color of the lights in the master bedroom and living room to red and disable the motion sensors and automated lights in those rooms.",
    triggers: [triggers.ItemStateChangeTrigger('group_Sensors_Contact_Alert', 'OFF', 'ON')],
    execute: () => {
        console.debug("Contact Sensors > Alert On > STARTING.")
        console.debug("Contact Sensors > Alert On > The group sensor item switched from OFF to ON. Storing the current state of the light switches.")
        if (items.MBR_Sensor_Contact_Light_OldStatus.state != items.group_MBR_Lamp_1_Switch.state) {
            items.MBR_Sensor_Contact_Light_OldStatus.postUpdate(items.group_MBR_Lamp_1_Switch.state)
        }
        if (items.LR_Sensor_Contact_Light_OldStatus.state != items.group_LR_Lamp_1_Switch.state) {
            items.LR_Sensor_Contact_Light_OldStatus.postUpdate(items.group_LR_Lamp_1_Switch.state)
        }
        console.debug("Contact Sensors > Alert On > LR Switch Status: " + items.LR_Sensor_Contact_Light_OldStatus.state +
             " | MBR Switch Status: " + items.MBR_Sensor_Contact_Light_OldStatus.state)
        console.debug("Contact Sensors > Alert On > Disabling the motion sensors and light automations.")
        items.Override_MBR_Sensor_Motion.sendCommand("OFF")
        items.Override_LR_Sensor_Motion.sendCommand("OFF")
        items.Override_MBR_Automated_Lights.sendCommand("OFF")
        items.Override_LR_Automated_Lights.sendCommand("OFF")
        console.debug("Contact Sensors > Alert On > Settings the color lights to red.")
        Lights.updateColorLight(items.group_MBR_Lamp_1_Color,342,90,100)
        Lights.updateColorLight(items.group_LR_Lamp_1_Color,342,90,100)
        console.debug("Contact Sensors > Alert On > ENDING.")
    },
    tags: ["Sensors","Contact Sensors"],
    id: "AlertOn"
})

Sorry if this isn’t the right place to report errors encountered during an upgrade from 5.1.4 to 5.2.1-Does anyone know why I’m getting these error messages? Thank you.

Err:1 https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable/main arm64 openhab all 5.2.1-1
  Error reading from server - read (5: Input/output error) [IP: 142.250.217.251 443]
Get:2 https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable/main arm64 openhab-addons all 5.2.1-1 [609 MB]
Ign:2 https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable/main arm64 openhab-addons all 5.2.1-1
Err:2 https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable/main arm64 openhab-addons all 5.2.1-1
  Error reading from server - read (5: Input/output error) [IP: 142.250.217.251 443]
E: Failed to fetch https://openhab.jfrog.io/artifactory/openhab-linuxpkg/pool/main/5.2.1/openhab_5.2.1-1_all.deb  Error reading from server - read (5: Input/output error) [IP: 142.250.217.251 443]
E: Failed to fetch https://openhab.jfrog.io/artifactory/openhab-linuxpkg/pool/main/5.2.1/openhab-addons_5.2.1-1_all.deb  Error reading from server - read (5: Input/output error) [IP: 142.250.217.251 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
FAILED
2026-09-12_09:17:13_EDT [openHABian] Checking for default openHABian username:password combination... OK
2026-09-12_09:17:13_EDT [openHABian] We hope you got what you came for! See you again soon ;)

I think I thought you got another error than you do, to avoid all confusion: Exactly what is the error?

Sorry for my late reply, @Nadahar. Here is the exact error message:

2026-08-24 07:00:05.912 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule 'AlertOn': Failed to execute action '1' of rule 'AlertOn': Failed to acquire the lock for action '1' of rule 'AlertOn' within 5 seconds.

Are the two rules in the same .js file or not? Because, should only be a potential problem between rules in the same file.

I’m wondering if perhaps actions.Voice.say() and/or Notification.alert() are blocking and can take a long time. That could explain why the other rules would have to wait more than 5 seconds before running. It’s possible to configure the 5 seconds timeout to be something more, you could set it to e.g. 30 seconds and see if the problem goes away, or if it only takes longer before the problem manifests.

Yes, both rules were in the same file, but, now that you mention actions.Voice.say(), I don’t know if you are aware, but I also reported another issue on 5.2.1 where sound notifications stopped working (without errors). Sound notifications not working on OH 5.2.X with Sonos and MaryTTS/Piper - #18 by rlkoshak

I’ll comment that step and check if there is any improvements.

However, as I mentioned on my 1st comment, the Check contact sensors rule, which is the one returning the warning, ends its execution approx. 50 milliseconds after the start time. As far as I’ve seen, a rule doesn’t end its execution until all its steps (including calls to other rules) have ended. So it seem to me like this 5 seconds rule is not being respected.

For any rule to be able to execute (using JavaScript or Python), the “execution lock” must be released for the execution context itself (the file). So, it’s not really important which rule logs the error, all it takes is that any other rule in the same context/file doesn’t release the lock within the 5 seconds timeout. As such, it’s “irrelevant” if the rule that reports the failure completes in 50 ms, it’s probably not “conflicting” with itself, but with one of the other rules in the file.

If you don’t bother to figure out what goes wrong, you could just move the failing rule to a separate file, and you should be rid of the immediate problem. However, the original problem is likely to cause other issues too I’d guess, but whether or how they’ll show up is hard to predict.

I have the same problem with OH 5.2.1. Is there any solution or workaround for this behaviour ?

For me - only a complete restart of OpenHAB solves this problem actually…

I merged the rules back into a single file, but I’m not getting the 5-second error anymore. I had to restart the server a couple of times because I moved it to another physical location. Apart from that, I didn’t change anything to the rules. I didn’t even comment the actions.Voice.say command. :man_shrugging:

Apart from the previous topic, I’m experiencing sluggishness in the UIs (MainUI, iPhone App) with v5.2.1. Page elements load as fast as always. Only the item values take 5 to 12 seconds to load when I haven’t accessed a page for a while during the day.

Updating items also takes 5 seconds or sometimes more to be reflected on the UI. I.e., even though physical devices are instantly updated, item values don’t change instantly on the UIs as they used to before.

Before v5.2, both page elements as well as values were loaded almost at the same time, quite fast.

At home, my laptop, phone, OH server, and devices are connected to the same local network. When I’m away from home, I’m connected via Twingate to my home network. For the mobile app, it’s always a local connection (not myopenhab.org). In both cases, I face the same issue.

Is anyone else experiencing the same?

I think this might be [rest.core] Stop flushing the SSE stream manually by digitaldan · Pull Request #5863 · openhab/openhab-core · GitHub, which will ship with M2 soon. Once we’ve confirmed that issue is gone, we should backport this PR.

@digitaldan, @florian-h05, @wborn, you guys rock!

Hi,

After updating openHAB to 5.2.2 in Docker, remote login through the cloud portal at myopenhab.org connects successfully and shows the instance online. However, clicking the login icon on the bottom left fails with an unauthorized_client error, whereas local login (http://192.168.X.X) works normally. Purging caches and relogging into the cloud portal did not resolve the issue.

see also here: Openhab 5.2.2 -> https://myopenhab.org/ -> unauthorized_client (Why trying to login in Openhab Clout)

Did you read the breaking changes?

(Also, I assume those are not applicable if one uses myopenhab.org, and a ‘normal’ installation, i.e. not via Docker etc.?)

Indeed, something is broken when trying to log as a admin via the cloud…looking.

So it looks like we merged a security advisory into core, and backported it to 5.2.x . I think this breaks admin login not only for cloud but for reverse proxy setups that serve https, but then proxy back to openHAB via HTTP (cloud uses loopback connection over http for communications).

See:

This will require a fix in core, working on a PR now.