openHAB 5.2 Release discussion

According to docs for openHAB 5.2, one can specify the UID for a DSL rule.
However, VS Code complains about no viable alternative at input 'uid'

rule "test2" [uid = "test_rule"]
when
    Item rule_test2 received command ON
then
    logError("test","test2")
    logError("test", triggeringItemName)
end

The same error is logged by openHAB when saving the rule:

2026-07-16 07:56:15.434 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading DSL model 'test.rules'

2026-07-16 07:56:15.460 [WARN ] [el.core.internal.ModelRepositoryImpl] - DSL model 'test.rules' has errors, therefore ignoring it: [31,15]: no viable alternative at input 'uid'

Did I miss something?

try without the brackets

rule "test2" uid = "test_rule"

The brackets are a syntactic way to tell you that the elements inside them are optional, but in actual use you don’t include the brackets.

When they need to be literally used, you’d see them quoted like '['. In which case you don’t actually type the quotes, just the brackets :grinning_cat: and to add to the confusion
 when you see “test_rules” you do have to type the quotes :man_facepalming:

I have a question why I see in the Items overview 0.7

but if i click on it I see 70%

Is anyone else seeing variables not defined in ECMAScript?

I have defined colour but then I see red dots everywhere saying they are not defined but yet it still runs and I get no errors in the logs?

afaik these do not apply your state description / formatting.

Is that the mainui code tab? Can you paste the full code so we can try to reproduce it?

Well, don’t I feel silly right now?
Thanks, @jimtng !

but is this as programmed or is it an issue?



// set the total maximum output power in watts (might vary depending)
let DIMDEFAULT = 2000;

let ONBATTERY =
  (items.getItem("Solar_battery_solar_generation").numericState !== 0);



if (ONBATTERY) {
  gridpower = Math.round(
    parseFloat(items.getItem("Solar_battery_pb").state)
  );

  solarpower = Math.round(
    parseFloat(items.getItem("Solar_battery_solar_generation").state)
  );

} else {
  // we are not running on battery  
  gridpower = Math.round(
    parseFloat(items.getItem("FroniusSymoInverter_GridPower").state)
  );

  solarpower = Math.round(
    parseFloat(items.getItem("FroniusSymoInverter_CurrentSolarYield").state)
  );
}

// calculate the percentage
let LIGHTPERCENTAGE = ((gridpower / DIMDEFAULT) * 100).toFixed(0);

// console.log("LIGHTPERCENTAGE b4: " + LIGHTPERCENTAGE);

if (gridpower >= 0 && solarpower != 0) {

  if (LIGHTPERCENTAGE > 0) {

    if (LIGHTPERCENTAGE > 100) {
      LIGHTPERCENTAGE = 100;
    }

    // HSB Hue, Saturation, Brightness
    // Below is 50% bright  
    items.getItem("Brilliant1_colour")
      .sendCommand("350,99," + LIGHTPERCENTAGE); // red

    colour = "255,0,0"; // red
  }

} else if (solarpower == 0) {

  items.getItem("Brilliant1_colour")
    .sendCommand("225,99," + 50); // blue

  colour = "0,0,255"; // blue

} else {

  // grid exporting / negative logic
  if (LIGHTPERCENTAGE < 0) {
    LIGHTPERCENTAGE = LIGHTPERCENTAGE * -1;
  }

  if (LIGHTPERCENTAGE > 100) {
    LIGHTPERCENTAGE = 100;
  }

  items.getItem("Brilliant1_colour")
    .sendCommand("100,99," + LIGHTPERCENTAGE); // green

  colour = "0,255,0";
}

// wled

//if on the battery cahnge the colur depending if negative or positive
if (ONBATTERY) {
  colour = (gridpower < 0) ? "3, 252, 252" : "255, 255, 0";  //3, 252, 252 ligh blue 255, 255, 0 yellow
}


// make it positive so the minus sign doesn't display
if (gridpower < 0) {
  gridpower = gridpower * -1;
}


// run the rule to send to wled (sends parameters data and colour)
let parameter = {
  data: gridpower,
  colour: colour
};

rules.runRule("wled_rule", parameter);

// result = actions.Exec.executeCommandLine(time.Duration.ofSeconds(5),
// "/usr/bin/mosquitto_pub","-h","192.168.1.164","-t","" + TOPIC,"-m",PAYLOAD);

// console.log("LIGHTPERCENTAGE after: " + LIGHTPERCENTAGE);

/*
console.log("Brilliant light = " + items.getItem("Brilliant1_switch").state);
console.log("gridpower = " + gridpower);
console.log("solarpower = " + solarpower);
*/

I think it is because I have declared them inside if statements and not at the start of the code. BUT it used to work before going to 5.2. Maybe it is stricter?

AFAIK it has been like that since the beginning. Try firing up OH 3 or OH4 and see!

Can it be improved? Probably. Or probably not worth it if it involves additional REST queries for every single item on the list.

I put this at the start and it is now fine:

// set the total maximum output power in watts
let DIMDEFAULT = 2000;

let gridpower = 0;
let solarpower = 0;
let colour = "";

Strange I never saw that in 5.1


Thank you @jimtng

I will find time to debug and revert with the findings.

To answer your question, though, the container has been rebooted multiple times with the same handler error.

Will keep you posted

A good day

Espresso

It is possible that it’s trying to listen on a port that’s already in use. Ideally it should’ve logged an error to ease troubleshooting.

If you are referring to the container ports, they are unique (I did a manual check again on all the containers).

I have as well Tuya Binding working on my “production” on 5.1.1. I had done a test to disable that binding on 5.1.1 and see if 5.2.0 tuya binding comes up. It did not.

I know it is a separate binding, but the Sonoff binding is acting up as well. The connector is always online. The item sometimes disconnects (when i check the next day), giving Hander_Missing_Error, but then goes online again. (i run another scan, disable, re-enable, it then decides to come online) (Not related but thought worth mentioning)

Edit I did the steps shared in the link here is the result the binding is in waiting state, resolve command did not do anything

I see a problem in Tuya binding’s error handling. Give me a moment I’ll build a test jar for you that should handle it more gracefully.

Uninstall the official binding and drop this jar into your addons folder https://github.com/jimtng/openhab-addons/releases/download/tuya-v0.0.1/org.openhab.binding.tuya-5.3.0-SNAPSHOT.jar

It isn’t going to fix anything - just a quick “fix”. It will:

  • Issue a warning log telling you which port it is unable to listen on
  • Let the bundle status continue to be Active
  • To make it retry the listening port, you’ll need to restart the bundle.

Hi @jimtng

Applying your jar worked!

The project and different sensors came online! almost immediately.

Port-related warning

(Not sure where to change those)

additional logs for your reference

Thank you again for your time and, more importantly, patience :slight_smile:

Let me know if you need to debug or share any logs.

Cheers,

Espresso

Something within your container (or on the host computer - depending on how the container networking is configured?) is also listening on those ports. You’d need to find it. Ask google for help in identifying it.

I have zero knowledge how the Tuya binding works. I don’t know how important those UDP listeners are and whether you can just ignore this issue or try to resolve it. I “suspect” it’s for new device discovery but once again I have no idea.

I will submit my changes as a PR anyway - hopefully someone else will improve it, but I think it at least fixes this particular issue letting you get your things to come online(?) :see_no_evil_monkey:

what is the benefit of not having it?