- Raspberry Pi 5 Model B Rev 1.0, 8GB, SD Card 128GB
- Debian GNU/Linux 12.5 (bookworm)
- Linux openhabian 6.1.0-rpi7-rpi-2712 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux
- openjdk 17.0.11 2024-04-16
- OpenJDK Runtime Environment (build 17.0.11+9-Debian-1deb12u1)
- OpenJDK 64-Bit Server VM (build 17.0.11+9-Debian-1deb12u1, mixed mode)
- openHAB 4.1.2 - Release Build
Recently I migrated my system from openHAB3 running on a RPi3+ to openHAB4 on a RPi5. While most of the bindings are working properly I really struggle to get the JS rule run on the new version.
The easy task was to modify the item handling (infortunately I did not find a list of these changes in the internet):
itemRegistry.getItem("someItemName").getState(); => items.someItemName.state;
events.sendCommand(someItem, ON); => someItem.sendCommand('ON');
if (someItem.getState() === ON) => if (someitem.state == 'ON');
For some statements that worked on openHAB3 I could not find a working solution:
-
PointType
var HomeLocation = new PointType(new DecimalType(21.12345), new DecimalType(10.853317)); => var HomeLocation = new PointType(21.12345, 10.853317);
Gives: [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘rule name’ failed: org.graalvm.polyglot.PolyglotException: ReferenceError: “PointType” is not defined) -
Group Item Members
var MemberList = Java.from(itemRegistry.getItem(groupItemName).members); => var MemberList = items.groupItemName.members;
MemberList is empty though the item ‘groupItem’ is an item of type Group with 3 Direct Group Members.var N = items.NetworkDevicesOnline.size;
var O = items.NetworkDevicesOnline.members.filter(i => i.state == ‘ON’).size;
Both N and O are reported as undefined.
Another problem I’m facing after the version change is that the oh-input-card I use to enter timestamp items (string type item, semantic class Point, semantic property Timestamp).
I use the oh-input-card as Default LIst Item Widget and as Default Standalone Widget.
Wherever the item is displayed it just shows “–:–”. The time can be either typed in or selected by time widget, but when I click the checkmark the time disappears and “–:–” is shown again.
Something I’m not really sure of is the syntax differences between the JS rule, the Widgets Expression Tester and the YAML code.
This makes searching the internet really frustrating due to these syntax differences and the changes of the syntax in different versions.
I worked my whole life as successful C++ programmer but Java Script makes me mad.
I’m sure there are people that are able to help me out of my misery. Any hint that helps me to sucessfully work with this great system is thoroghly appreciated.
Thanks a lot, Norbert