Zigbee and zwave manual install script

its strange that when I tested it i got the errors but when you tested it you didnt, so I thought maybe you were running a different distro to me, I have tested this on fresh installs of centos 7 and ubuntu 18.10 and I can see that it works on centos but not ubuntu

CENTOS 7

1st time executing


Addons path: /usr/share/openhab2/addons
OpenHAB account: openhab
Requested action: Install or upgrade Zigbee binding
Current OpenHAB snapshot version: 2.5.0
Requested Zigbee version: OpenHAB baseline (included in OpenHAB snapshot)
Requested Zigbee library version: 1.1.6

Is this correct?
1) Yes, start now                      3) Exit
2) No, take me back to the first menu
#? 1

Uninstalling any managed binding(s) and installing openhab-serial-transport...
Logging in as openhab
Error executing command: No matching bundles
... a 'No matching bundles' error mesage is normal, if a binding had not been previously installed.

Backing up and uninstalling any unmanaged installs of Zigbee...
mv: cannot stat ‘*.jar’: No such file or directory              done.

Downloading new Zigbee jars... done.

Installing unmanaged Zigbee binding...

!!!!! It has taken more than two minutes to install the Zigbee binding, so exiting !!!!!


2nd time executing


     *****     SUMMARY     *****

Addons path: /usr/share/openhab2/addons
OpenHAB account: openhab
Requested action: Install or upgrade Zigbee binding
Current OpenHAB snapshot version: 2.5.0
Requested Zigbee version: OpenHAB baseline (included in OpenHAB snapshot)
Requested Zigbee library version: 1.1.6

Is this correct?
1) Yes, start now                      3) Exit
2) No, take me back to the first menu
#? 1

Uninstalling any managed binding(s) and installing openhab-serial-transport...
Logging in as openhab
... a 'No matching bundles' error mesage is normal, if a binding had not been previously installed.

Backing up and uninstalling any unmanaged installs of Zigbee... done.

Downloading new Zigbee jars... done.

Installing unmanaged Zigbee binding... done.

Complete!

Ubuntu 18.10 I get the following error every time I execute it (also note that ubuntu has the cannot create directory error)

     *****     SUMMARY     *****

Addons path: /usr/share/openhab2/addons
OpenHAB account: openhab
Requested action: Install or upgrade Zigbee binding
Current OpenHAB snapshot version: 2.5.0
Requested Zigbee version: OpenHAB baseline (included in OpenHAB snapshot)
Requested Zigbee library version: 1.1.6

Is this correct?
1) Yes, start now                      3) Exit
2) No, take me back to the first menu
#? 1

Uninstalling any managed binding(s) and installing openhab-serial-transport...
mkdir: cannot create directory ‘/usr/share/openhab2/userdata/tmp’: No such file or directory
KARAF_BASE is not valid: /usr/share/openhab2/userdata
... a 'No matching bundles' error mesage is normal, if a binding had not been previously installed.

Backing up and uninstalling any unmanaged installs of Zigbee... done.

Downloading new Zigbee jars...


!!!!! It has taken more than two minutes to install the Zigbee binding, so exiting !!!!!


both environments were configured identically only difference being that the ubuntu environment used the deb packages via the apt repo instead of the rpm’s via the yum repo

I’m testing the Fedora 29 (rpm). I really thought using the -E option for sudo would resolve this for you, but maybe there is something different in the deb packages.

If you just run sudo -E -u openhab /usr/share/openhab2/runtime/bin/client, you get the same KARAF_BASE is not valid error?

I guess the next option is to use openhab-cli console for package installations. Is that how you normally get into the console?

yeah i ran it with the -E option on both distro’s
yes i’d run openhab-cli console to access the console

I setup a VM of Ubuntu, and I’m seeing the same error you are reporting, just as I did before using -E. I changed the script to check for the existence of /usr/bin/openhab-cli, and if it exists, I use that to launch the console. If not, I call ../runtime/bin/client directly. This worked on my Ubuntu setup. Hopefully that gets the script working for everyone! Please try running it again (and have it grab the latest).

curious you are needing to specify the path to the executable, openhab-cli should be in the path and executable without specifying the full path to the executable
on both rpm installs and apt installs it is anyway not sure if it would be for a manual install

I edited the script and removed the path to the client executable on both ubuntu and centos and it worked fine calling openhab-cli console {karaf

this is all i did

  if [[ -f "/usr/bin/openhab-cli" ]]; then
        openhab-cli console ${KARAF_FUNCTION} --
        echo -e "apt installation"
    else
        openhab-cli console ${KARAF_FUNCTION} --
      echo -e "rpm installation" 
    fi

you could obviously remove all the logic and just call the command
if this wont work for manually installed environment i’d suggest checking for the manual installed environment and then calling that differently maybe

first time i run it I get the timeout 2 minutes thing (also had this on centos) but 2nd time I ran it success

It is not needed, but if I’ve tested for its existence in a specific path, why not fully qualify it? Both apt and yum/dnf based systems will have openhab-cli in /usr/bin/, so the else in your if/then would be unreachable, and will error for manual installations. That’s why I did this…

if [[ -f "/usr/bin/openhab-cli" ]]; then
    /usr/bin/openhab-cli console ${KARAF_FUNCTION} --
else
    ../runtime/bin/client ${KARAF_FUNCTION} --
fi

I was noticing that too and will look into it later. However, I don’t think manual installations are necessary in most cases, so I plan to make a version of the script that will just upgrade the binding in place, using this method…

bundle:update org.openhab.binding.zwave https://openhab.jfrog.io/openhab/online-repo-snapshot/2.5/org/openhab/binding/org.openhab.binding.zwave/2.5.0-SNAPSHOT/org.openhab.binding.zwave-2.5.0-SNAPSHOT.jar

For zwave, there’s not much need for a script, but it makes it convenient. For zigbee, you’d need to enter it four times, so much more convenient with a script. And no jar files or addons.cfg to worry about! Of course, the best solution is to add the ability to individually select which release/repository a binding is pulled from, and a UI for triggering the update.

ah fair enough I didn’t even check on my centos install if the openhab-cli existed there I assumed it didn’t (was late when I wrote that)

i’d still lean towards not specifying the path to the openhab-cli command, check for its existence (not in a specific location just that it exists) and then execute it
like this

command -v openhab-cli >/dev/null 2>&1 || { echo >&2 "I cant seem to find openhab-cli"; exit 1; }

it would allow for a broader range of openhab installation options and future proof the script

and I agree using the bundle:update method would probable be the best way

Also I think this script is essential for anyone wanting to run zigbee binding without upgrading to the testing branch of openhab2 so great work

I have pushed v1.2.0…

* Changed download directories for the bindings after the BND migration 
* Changed to openhab-core-io-transport-serial
* Added openhab-core-config-discovery-usbserial
* Added org.apache.servicemix.bundles.xstream

Note: when installing/upgrading Zigbee, I have found that a restart of OH is required :slightly_frowning_face:.

What are those? Will they fix the serial (USB) problems we´re having?

See these threads. There are additional dependencies required after the migration to the BND build system. There are still issues with serial, but I can restart OH now and zwave and zigbee both start while using the latest snapshot versions. The verdict is still out (I think) as to whether the new jars can be used with an older OH though.


Sorry for the late reply, Scott.
But I dont think I understand what you´re saying… I´m running 2.5M1 build 1575. But I´m not sure if using your script will do any god for the problems I´m having with the serial driver…
Atm z-wave is running, but everytime I restart OH, I have to change the /dev/USB port and resave the config file. They z-wave starts.
Zigbee I have given up for now… There are too many problems and requires to much hassle with devices out of the blue leaving/going offline, or they´re online but no longer respond. The other day even the coordinator went offline, again out of the blue.
I havn´t been able to get it back online yet, probably due to not having restartet OH in the last few days.

So question is (again). Will it solve my problems using your script and update the serial driver? I have read the links, but I cant really see if it´ll be worht a try at all.

I just downloaded the latest version of the script. I copied it to the /srv/openhab2-addons/…
When I try to run it, I get an error:

[23:47:07] openhabian@openHABianPi:/srv/openhab2-addons$ sudo -E -u openhab bash zzManualInstaller.sh
This script must be copied to the $OPENHAB_HOME/addons directory before running it

I´m 110% possitive the script is there.

What am I missing here? It a fresh new openhab 2.5M1 (openhabian) installation…

Try running the script after…

cd /usr/share/openhab2/addons

Thanks, I´ll give it a try later.

I´m curious…
Whats the difference between

/srv/openhab2-addons/

and

/usr/share/openhab2/addons/

And if any differences, does it matter where to copy .jar files when manually installing bindings as well?

I’ve never spent time looking through how openHABian is setup. /srv/openhab2-addons must be a symlink to /usr/share/openhab2/addons. I think I see how to fix this though. On line 122, you should see #echo "DEBUG: ${ADDONS}". On the next line, add cd $ADDONS. That might take care of people trying to run the script in a symlinked addons directory.

Worked fine, Scott. Thanks.

Hi,

I just used this script to install a snapshot version of the Zigbee binding. It did not complete, untill I manually uninstalled the Zigbee binding before starting the script. From the documentation it is no entirely clear to me if this is the way to go. The script seems to suggest it can install the stable Zigbee binding itself, but this was not the case in my situation.

Yes, the script should remove any installed version you already have, but I’ve seen it not work without restarting OH. The script waits for the old bind to uninstall and for the new one to install. If it takes longer than 2 minutes, the script will exit with a message. Running the script again sometimes helps, but restarting OH always seemed to get past this for me and rarely occurred. The REST API is used for checking, so if you have an issue with REST then the script will fail. If you see the binding installed in Paper UI, then it was not uninstalled properly (you won’t see the binding as installed in Paper UI if it was installed manually). You can also confirm this by running…

list -s |grep zigbee

… in the console. If you see multiple versions, then uninstall through Paper UI.

I have also not been able to get a manual installation of the current Zigbee binding to work with recent snapshot builds of OH.

Thanks for your reply! Restart of OpenHAB did not help for me, the binding just wasn’t uninstalled. After uninstalling it via PaperUI, the script completed successfully. I was afraid I’d lose the settings, but that wasn’t the case, fortunately.

Yep, removing the binding does not delete the Things. Strange that it did not uninstall for you. Were there any errors? Maybe the script couldn’t get into the console to uninstall the existing binding?