[BTicino/OpenWebNet] New openHAB2 binding ready for testing

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

Ok, ma dato che il codice c’è non basterebbe ricompilarlo anzichè decompilarlo/modificarlo?
Nessuno ha un contatto diretto con lo sviluppatore?

nell’ultima comunicazione che ha avuto con uno sviluppatore olandese del core quest’ultimo chiedeva chiarimenti sull’origine codice… poi dopo qualche delucidazione, fine delle trasmissioni.

I ask apologize to wrote in Italian language but I didn’t understand how to write a private message to the user question. to understand why the binding isn’t working anymore please look at english posts linked in my Italian answer. Thank you

The fix is posted a few posts above. The binding has expired and massi seems to be unavailable. So, jebu came up with a temporary solution, hack, which is posted here:

Just put the hacked addon in the addons folder as normal.

The binding will expire again in one years time!

Hi Roberto, first of all thanks for the answer, I’m sorry because I had done a hard job (and for me who is a layman I would also say very complex) of research on the web to automate the whole house having bought all bticino components and amazes me as a company a certain caliber cannot integrate a functioning binding for its loyal customers. However, I am waiting for updates on this.

Thanks again
Greetings Marco

1 Like

Hey guys,

I have been alerted to a mistake of mine. I previously said massi’s last post was Jan 2019. I read the date thing wrong. It was Jan 19 not Jan 2019. So, massi hasn’t been gone as long as I thought. It just felt like a year to me. So, lets hope he is just busy with other stuff for while. I will fix my post to avoid further ‘panic’. Sorry

Thank you Mark, we hope the developer will be back soon, as we use to say in these days “#andrà tutto bene” :slight_smile: (all will be fine)

:+1: