[BTicino/OpenWebNet] New openHAB2 binding ready for testing

Thank you very much!!!

I hope that @massi will support by pointing in the right direction.
I think that the binding was built using some existing libraries, if I recall correctly massi mentioned them in the documentation of the binding .
But to be honest my understanding of coding is very limited😅

Great job really: the binding is working again now

Ty man!!! Was going mad.

Thanks Jebu,

All working again for me too now. I must say I am relieved and I don’t have to start learning how Eclispse IDE , gitHUB etc works just yet. It seemed an impossible mountain to climb but was starting out up it anyway. I will make a note in my diary for 14/3/2021 not to restart openHAB.

I am surprised by how things have turned out with Massi and Gozilla01. Massimo did excellent job and was for a long time a very enthusuastic developer of the binding and seemed happy with the community here. I am surprised because either something tragic happened, I hope not, or he has decided to turn his back on this community and for some reason is unable to say a decent goodbye to those folks here that got to know him a little bit and or helped with him with his work.

For anyone trying to work out if massi is or is not still interested in this binding read the following two links. Maybe we piece together some sort of explanation to confirm or allay the fears about the future of this binding and Massi’s involvement in it.

Sorry. I’ve not understood which kind of file or library must i modify and where i can find it. I’ve seen aldo the patch of Jebu but i don’t understand how to apply it.Thanks in advance

Just place it in the addons folder like you do for jar files. That’s it. Maybe clear cache and restart as well.

If you do clear the cache don’t forget to reinstall the dependencies as mentioned in the binding install instructions.

Thanks Mark. All is ok

Thanks Mark, everything works again !!!

Tnx for the tweak on JAR file, worked for me!

If I’m not wrong within readme file there’s a link to that Library:

This binding uses openwebnet-lib 0.9.x , an OpenWebNet Java lib partly based on openwebnet/rx-openwebnet client library by @niqdev, to support:

  • gateways and OWN frames for ZigBee
  • frame parsing
  • monitoring events from BUS

The lib also uses few modified classes from the old openHAB 1.x BTicino binding for socket handling and priority queues.

The library is based off rx-openwebnet but its not the one that’s used. See discussion here https://github.com/openhab/openhab-addons/pull/6213#discussion_r346251832

Worked for me too!
Big thanks!!!

The openwebnet binding/gateway sometimes goes OFFLINE… grrr!! . It’s a rare event but has a happened to me a few times for unknown reasons.

So, I set out to fix the sporadic offline gateway problem automatically and below is how to do it.

My system Raspberry Pi4 openhabian OH2.5.2

The fix is in two parts.

  • Part 1 Detection of offline Gateway Thing. I have a rule to check every 30mins if the binding is online or not. This sends me alerts if the binding is not online.
  • Part2 If the binding is not online the rule runs a script to bring it back online with a binding restart.

Part1 Detection
Expire binding is needed to create timers.
.items

//Limit email notifications to every 60mins
Switch GatewayOfflineNotification_Timer "Gateway offline notifications paused 60mins" <time> {expire="60m,command=OFF"}

Rule to check if gateway is online and if it’s not restart it

rule "Check BUS gateway status"
when 
    Time cron "0 0/30 * * * ?" //Every 30mins
then
    val thingStatusInfo = getThingStatusInfo("openwebnet:bus_gateway:gateway")
    val mailActions = getActions("mail","mail:smtp:emailserver")
    if ((thingStatusInfo !== null) && (thingStatusInfo.getStatus().toString() == "ONLINE")) {
        logInfo("Thing_Status", "BUS gateway is online")
    } 
    else { 
        logError("Thing_Status", "BUS gateway is OFFLINE") //or doesn't exist
        sendNotification(''email address','BUS gateway went OFFLINE at '+ now.toString("HH:mm dd-MM-yyyy"))
        val results = executeCommandLine("/etc/openhab2/scripts/restart_openwebnet.sh",10000)
        if (results == '') {
            logInfo("Thing_Status", "Restart openwebnet binding script successful")
            sendNotification(''email address','BUS gateway restarted at '+ now.toString("HH:mm dd-MM-yyyy"))
            if ( GatewayOfflineNotification_Timer.state !== ON) { //Limit emails to one every 30mins
                GatewayOfflineNotification_Timer.sendCommand(ON)
                mailActions.sendMail("'email address", "BUS gateway went offline", "BUS gateway restarted at " + now.toString("HH:mm dd-MM-yyyy") )
            }
        }
        else {
            logInfo("Thing_Status", "Restart openwebnet script failed. Result = " + results)
        }
    }
end

Part2. Restart binding with a script
As it is the above rule will not execute the command without some additional work. To restart the binding the karaf console is used and this requires a password to log in >> habopen. That’s a problem!

To get around this requirement I followed the recommended method to use rsa keys. These are generated as follows:

Create a directory to hold the key files. I think it needs full permisions
eg
/home/openhab/karaf_keys/

To generate the keys execute the following command while in the karaf_keys directory

sudo -u openhab ssh-keygen -t rsa -f openhab.id_rsa

Do not enter a passphrase when asked!!

Now we need to copy the keys, located in the .pub file, into a new line in this file… /srv/openhab2-userdata/etc/keys.properties

This is done as follows:

cat /home/openhabian/karaf_keys/openhab.id_rsa.pub

then copy the ouput so it’s in the buffer … just highlight it. You only need the long key part and not the rest.

Open the file

nano /srv/openhab2-userdata/etc/keys.properties

Add a new line as follows but replace the xxxx part with the copied key:

openhab= xxxxxxxxx,_g_\:admingroup

Save file

This is the script I created to restart the binding:

#!/bin/bash
ssh -p 8101 -i /home/openhabian/karaf_keys/openhab.id_rsa openhab@localhost bundle:restart org.openhab.binding.openwebnet

I put the script here
/etc/openhab2/scripts/restart_openwebnet.sh

That’s it. The rule and script should all work now.

To test the rule and that karaf can be accessed without password try the following to stop the binding. You will still need to enter the sudo password in the console for this test, but not the karaf password, habopen :slight_smile:

sudo -u openhab ssh -p 8101 -i /home/openhabian/karaf_keys/openhab.id_rsa openhab@localhost bundle:stop org.openhab.binding.openwebnet

To test the script try this:

sudo /etc/openhab2/scripts/restart_openwebnet.sh

No passwords should be needed.

Or if you wait 30mins after stopping the binding the rule should detect that the binding is not online and automatically restart it.

M

3 Likes

sorry my english, I use the google translator. I tested the latest binding on raspberry pizero w. use openhabian openhab version 5.2. At the moment it works well.
my gateway is mh201. this solution is optimal for those who make an economic system. Clearly this solution is not recommended for complex systems with many bindings.

Hello to all
i am new to the forum and inexperienced and i have a problem with the openwebnet binding. For about 3 days, unfortunately, bus gateway and things have been offline with offline bridge.
The binding version of Massimo Valla is org.openhab.binding.openwebnet-2.5.0.M2-1.jar.
can someone help me please.
thank you all
sorry for my bad english

Ciao Marco, stesso problema. Sembra che sia scaduto il binding. Se lo sviluppatore non lo aggiorna c’è poco da fare. Questi sono i problemi che accadono quando una sola persone si prende cura di un progetto Opensource. E’ un rischio da mettere in conto pur troppo. Qualcuno è riuscito a cambiare la data ma io ho provato il binding modificato e non funziona bene. I comandi impartiti da web rispondono con un fastidioso ritardo. A volte non rispondono nemmeno…Insomma, inutilizzabile

Same here. Things where working perfectly for months, now i have you same issue. Bridge is offline and the log says the Bridge is offline…

Scusa cosa intendi per “scaduto”?

Qui viene spiegato e proposta la patch… che a me funziona male