Sony Devices Binding

Hi @tmrobert8, welcome back
this is my script I’m using to convert the code for my bindings from 2.5.x to 3.x on a regular basis, because I’m still developing on 2.5.x.

find . -name *.java -exec sed -i '' -e "s/org.eclipse.smarthome.core.library.unit.SmartHomeUnits/org.openhab.core.library.unit.Units/g" {} \;
find . -name *.java -exec sed -i '' -e "s/tec.uom.se.unit.Units/org.openhab.core.library.unit.Units/g" {} \;
find . -name *.java -exec sed -i '' -e "s/, SmartHomeUnits/, Units/g" {} \;
find . -name *.java -exec sed -i '' -e "s/org.eclipse.smarthome.core/org.openhab.core/g" {} \;
find . -name *.java -exec sed -i '' -e "s/org.eclipse.smarthome/org.openhab.core/g" {} \;
mvn spotless:apply

Syntax is for Mac, other distributions have a slightly different syntax for the find command.

This is a good source of information: Guide: Binding development changes for openHAB 3 (from 2.5.x)

or as complete build script also copying the code (path and binding folders need to be adjusted):
buildpush.sh.txt (1.3 KB)
convert_v2_v3.sh.txt (971 Bytes)

  • apply mvn spotless
  • build v2
  • copy code to v3 directory
  • build v3
  • copy outputs to ~/Dev/myfiles/xxx (my private repo) & push

I keep pom.xml separate for both versions (this includes version number 2.5.12 vs. 3.1.0).

Most important

  • Namespace org.eclipse.smarthome.core has been renamed to org.openhab.core
  • ESH-INF has been renamed to OH-INF
  • Code changes are required around @NonNull (OH3 environment is more strict), e.g. map.get() and gson.fromJson are now @Nullable - this requires some code changes, backward compatible with v2
  • SmartHomeUnits has been renamed to Units, references to tec.uom.se.unit.Units have to be removed
  • There are some deprecated functions, which need to be replace
  • Usage of org.apache.commons needs to be replaced by native code

In general not a big job. This scripts help to to keep v2.5 and v3 codebase in sync. Working on 2.5 and transforming to 3 prevents from using new features of v3.

Adapt log filtering (optional): Log filtering in OH 3