Zigbee and zwave manual install script

ill rebuild my test vm and try today

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.