openHAB 4.0 Release discussion

Apologies, changed my post to “unclear to me”. Of course, it depends on knowledge of the reader.

I know, that there are many changes to the UoM. I had prepared my openHAB (file based) configuration and correct some items in openHAB 3.4.4 before I upgraded. I also read the information about Humidity and added the “,unit=”%" to the Netatmo items. This worked. Also one Shelly H&T was changed later after the openHAB 4 migration (and before I wrote here).

Then I start to go to all properties and checked them and found as a result the rain gauge items with wrong units. After I changed them and it rained two hours later, nothing happened with the measured values.

There was nothing. I checked last night. I restarted last night openHAB 4 again and have now to wait. Today it was dry, no rain anywhere.

Hi Florian,

I can check and try on Friday or weekend, actually I am not at home and my configuration is file based. I will replay again later this week.

When I use the iOS openHAB-App (version 2.4.46), all properties are in English. The menu is called in German “Eigenschaften” and then I changes to English:

ColorTemperature, Current, Energy, Humidity, …

I can swear that the same menu in the app was with openHAB 3.4 translated to German. Also when I used the WebUI over Safari, everything is translated to German. It is only the app view, cache was clear for testing.

Sorry about that! It will now also instruct users to install Java 17 on Download openHAB | openHAB.

3 Likes

Well, there is a ton that happens between a device and seeing an Item updated. Nothing you describe points to the UoM having anything to do with the behavior you describe. It is much more likely that the binding isn’t connecting to the device or the Items are not linked correctly to the Channel.

There is nothing about UoM that would prevent an Item from updating silently. So if you see no errors complaining about incompatible units or something, the Item was never attempted to be updated. Your problem lies elsewhere.

Netatmo rain gauge is working fine for me in OH4.
As you can see, 8 mm of rain today.

And here are my item definition:

Number:Length PluieJour "Précipitations jour [%.0f mm]" <rain> (GNetatmoMeteoExt) [ "Measurement", "Rain" ] {channel="netatmo:rain:compte:station:pluviometre:rain#sum-24", unit="mm"}

Can you show also the state description?

Hello,

Meanwhile I fixed it. I have deleted the values and linked it new. Include the % in the unit.
It is shown now currect…

1 Like

After the update to 4.0 everything seems to work correctly again. However, I had to spend a whole day troubleshooting and solving one error message after the other. Fortunately, most errors are already discussed and solved here in the forum. But a simple update is something else.

1 Like

After upgrade from 3.4.4 to 4.0 when calling setTimer from JavaScript it returns undefined instead of a timer id.

To reproduce create testTimer.js with the following code:

console.info('before');
const id = setTimeout(() => {
  console.info('timer reached');
}, 1000);
console.info(`timer ${id} created`);

With release 3.4.4 I get:

2023-07-26 11:21:00.638 [INFO ] [ort.loader.AbstractScriptFileWatcher] - Loading script '/openhab/conf/automation/js/testTimer.js'
2023-07-26 11:21:13.275 [INFO ] [.automation.script.file.testTimer.js] - before
2023-07-26 11:21:13.281 [INFO ] [.automation.script.file.testTimer.js] - timer 1 created
2023-07-26 11:21:14.284 [INFO ] [.automation.script.file.testTimer.js] - timer reached

But in 4.0.0 with the same script I get:

2023-07-26 11:19:33.707 [INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/openhab/conf/automation/js/testTimer.js'
2023-07-26 11:19:37.257 [INFO ] [.automation.script.file.testTimer.js] - before
2023-07-26 11:19:37.259 [INFO ] [.automation.script.file.testTimer.js] - timer undefined created
2023-07-26 11:19:38.259 [INFO ] [.automation.script.file.testTimer.js] - timer reached

Openhab is running as docker container on a raspberry.

Is this a known issue?

It wasn’t, but yet it is :wink:

I will provide a fix ASAP.

EDIT: Fix is already merged and will come with openHAB 4.0.1 soon.

3 Likes

Updated from OH3.4 via apt with reading all your (awesome) documentations and it worked flawlessly.
Using mostly file-based configs and rules and many add-ons and stuff.
Big thanks to all your great work! I am deeply impressed! Now discovering all new features. :slight_smile:
I like you! :heart_eyes:

5 Likes

4.0 works almost perfect, great job. But I have an issue with one of my blocky scipts. It is a proxy item, processing a string command “ON”, “OFF”, “ON TIMER” or a number. I have a longer if else structure but that is broken. When send “ON” or “OFF” (variable received_command) I now always end up in the entire else block, instead of entering the ones where I ask “ON”==received_command. The relevant code is at the end of the paste.

Ideas?

var pulse_level, target_level, tiggering_name, received_command;

// Describe this function...
function sequence_toggle() {
  items.getItem('KuchenLicht').sendCommand('ON');
  if ('OFF' == event.oldItemState) {
  } else {
    set_level('0');
    items.getItem('KuchenLicht').postUpdate('OFF');
  }
}

// Describe this function...
function sequence_motion_detected() {
  if (items.getItem('KuchenLicht').state == 'OFF') {
    if ('75' <= items.getItem('OpenWeatherMap_Wetter_Bewolkung').state) {
      items.getItem('KuchenLicht').sendCommand('ON TIMER');
    } else if ('6' >= items.getItem('Lokale_Sonnendaten_Hohenwinkel').state) {
      items.getItem('KuchenLicht').sendCommand('ON TIMER');
    }
  }
}

// Describe this function...
function sequence_briefly_on() {
  set_level(pulse_level);
  if (cache.private.exists('KuchenLichtTimer') === false || cache.private.get('KuchenLichtTimer').hasTerminated()) {
    cache.private.put('KuchenLichtTimer', actions.ScriptExecution.createTimer('KuchenLichtTimer', time.ZonedDateTime.now().plusSeconds(75), function () {
      if ('OFF' == items.getItem('SNZB03_N01_Motion_Intrusion').state) {
        items.getItem('KuchenLicht').sendCommand('OFF');
      } else {
        set_level(pulse_level * 2);
        if (cache.private.exists('KuchenLichtTimer')) { cache.private.get('KuchenLichtTimer').reschedule(time.ZonedDateTime.now().plusSeconds(30)); };
      }
      cache.private.remove('KuchenLichtTimer');
    }));
  } else {
    // do nothing
  };
}

// Describe this function...
function set_level(target_level) {
  items.getItem('IKEA_TRADFRI_1_Control').sendCommand(target_level);
  items.getItem('TRADFRI_N02_Level').sendCommand(target_level);
}


pulse_level = '20';
tiggering_name = event.itemName;
received_command = event.itemCommand;
console.info(('KüchenProxy: processing: ' + String(received_command)));
if (tiggering_name.indexOf('Motion') + 1 > 0) {
  console.info('KüchenProxy: entering motion sequence');
  sequence_motion_detected();
} else {
  if (cache.private.exists('KuchenLichtTimer')) { cache.private.remove('KuchenLichtTimer').cancel(); };
  if ('ON TIMER' == received_command) {
    console.info('KüchenProxy: starting ON TIMER');
    sequence_briefly_on();
  } else if ('OFF' == received_command) {
    console.info('KüchenProxy: starting OFF');
    set_level('0');
  } else if ('ON' == received_command) {
    console.info('KüchenProxy: starting ON');
    set_level('100');
  } else if ('TOGGLE' == received_command) {
    sequence_toggle();
  } else {
    console.info('KüchenProxy: got number, setting it');
    set_level(received_command);
    items.getItem('KuchenLicht').postUpdate('ON');
  }
}

1 Like

There is an unfortunate bit here which, if I can figure out how to fix I would in a heartbeat.

This code is JS Scripting with the helper library which is what Blockly converts to in OH 4. The JS Scripting library goes to great lengths to present everything as a pure JavaScript class/object/etc.

Unfortunately, in UI rules, we get the raw Java event Object. That means event.<anything> is going to give you a Java Object. event.oldItemState therefore is a Java State Object, not a String. The Java org.openhab.core.library.types.OnOffType.OFF does not equal the String "OFF".

The easiest thing to do will be convert the event.oldItemState to a String before comparing it to 'OFF'. Of course, you could also import OnOffType and compare to OnOffType.OFF instead but you’d need to use an inline script block to do that.

Note, this is going to do a string compare meaning '8' <= '75' will be false. You probably want to get the numeric state of the Item instead of the .state (the “get [name] of item” block let’s you get the numeric state) and compare to a number 75.

This comparison is fine because the state is a String so you are comparing String to String and it will match.

1 Like

Built small remote server from scratch to replace one of my 3.44 devices. The install worked great and I have it running perfectly as a remote back to my 3.44 server. I have had so much trouble with Logs in the past, that I decided to do this one from scratch instead of update. Since it worked so well, I will probably do the rest that way. Just wish there was a way to export my configs and import into the new device. I have 3 RPi3b+ remotes reporting to my main server. Main server is RPi4 with 100 Things, 256 Items and 63 Rules. Thanks for a great update.

1 Like

Thanks! I added the blocky “create text with” in between, solving the thing with 4.0 now! YAY! This leads to the code received_command = String(event.itemCommand);

And the numeric comparison worked with your other proposal to get the state, leading to the code if (75 <= items.getItem(‘OpenWeatherMap_Wetter_Bewolkung’).numericState)

Yesterday i make a clean Openhabian install with OH4 and restore my configuration from by 3.4.4 system. When I select a trigger “a trigger channel fires” in the rule UI, I cannot select a channel to fire. Also old Rules with a trigger channel fired will not work on the new system. I use the Astro Binding for sunset, sunrise etc…

Maybe you’ll have to update the FireMotD cache. Try

sudo FireMotD -G all

I have a major issue since upgrade, seems to be JAVA related, I’m a but confused about what Java version I should : I have Ubuntu server which Zulu 11 and Oracle v8 java versions

  Selection    Path                                         Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/zulu11/bin/java                  2116601   auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
* 2            /usr/lib/jvm/java-8-oracle/jre/bin/java       1081      manual mode
  3            /usr/lib/jvm/zulu11/bin/java                  2116601   manual mode

java -version
java version “1.8.0_191”

when I upgrade I got warning:

[openHAB] WARNING: We were unable to detect Java 17 on your system. This is needed before openHAB can be started.

now I get errors during startup

2023-07-29 13:23:50.648 [ERROR] [ternal.service.BootFeaturesInstaller] - Error installing boot features
org.apache.felix.resolver.reason.ReasonException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=openhab-runtime-base; type=karaf.feature; version="[4.0.0,4.0.0]"; filter:="(&(osgi.identity=openhab-runtime-base)(type=karaf.feature)(version>=4.0.0)(version<=4.0.0))" [caused by: Unable to resolve openhab-runtime-base/4.0.0: missing requirement [openhab-runtime-base/4.0.0] osgi.identity; osgi.identity=openhab-core-base; type=karaf.feature [caused by: Unable to resolve openhab-core-base/4.0.0: missing requirement [openhab-core-base/4.0.0] osgi.identity; osgi.identity=org.openhab.core.config.core; type=osgi.bundle; version="[4.0.0,4.0.0]"; resolution:=mandatory [caused by: Unable to resolve org.openhab.core.config.core/4.0.0: missing requirement [org.openhab.core.config.core/4.0.0] osgi.wiring.package; filter:="(&(osgi.wiring.package=org.openhab.core.common.registry)(version>=4.0.0)(!(version>=5.0.0)))" [caused by: Unable to resolve org.openhab.core/4.0.0: missing requirement [org.openhab.core/4.0.0] osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=17))"]]]]
        at org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1341) ~[org.eclipse.osgi-3.18.0.jar:?]