Disable Binding temporaly

How do you handle binding errors if the device is not in network. For example i have a binding for Sonos and Denon. When i do not need them i power of the switch so they are not longer connected to power. They are not reachable until i am back home and power them up. But openhab bindings are still trying to reach them and output errors.

The errors are not that big problem but as i am a developer i do not like see errors in my log. :smile:

How do you handle them, is there a way to disable bindings temporaly or another way i do not know?

you could do something like this:

First get a listing of the running bindings:

osgi> lb binding
START LEVEL 6
   ID|State      |Level|Name
   16|Resolved   |    4|XML Binding for Java (2.2.0.v201105210648)
   43|Starting   |    4|JFace Data Binding (1.4.1.v20120912-132807)
   44|Starting   |    4|JFace Data Binding Observables (1.4.1.v20120521-2329)
   45|Starting   |    4|JFace Data Binding (1.4.100.v20120523-1955)
  188|Active     |    4|openHAB AutoUpdate Binding (1.8.0.201508130117)
  222|Active     |    1|openHAB NTP Binding (1.8.0.201508130117)
  223|Active     |    1|openHAB Weather Binding (1.8.0.201508130117)
  224|Active     |    1|openHAB tivo Binding (1.8.0.201508130117)
  225|Active     |    1|openHAB Mqttitude Binding (1.8.0.201508130117)
  228|Active     |    1|openHAB Nest Binding (1.8.0.201508130117)
  232|Active     |    1|openHAB ZWave Binding (1.8.0.201508130117)
osgi>

optionally I could have used the “ss” command like this:

osgi> ss org.openhab.binding
"Framework is launched."


id	State       Bundle
222	ACTIVE      org.openhab.binding.ntp_1.8.0.201508130117
223	ACTIVE      org.openhab.binding.weather_1.8.0.201508130117
224	ACTIVE      org.openhab.binding.tivo_1.8.0.201508130117
225	ACTIVE      org.openhab.binding.mqttitude_1.8.0.201508130117
228	ACTIVE      org.openhab.binding.nest_1.8.0.201508130117
232	ACTIVE      org.openhab.binding.zwave_1.8.0.201508130117

then just disable the one in question like so:

osgi> stop 232
osgi> 2015-09-21 07:31:41.431 [INFO ] [.service.AbstractActiveService] - ZWave Refresh Service has been shut down

You can re-start it with the start command:

osgi> start 232
osgi> 2015-09-21 07:34:11.249 [INFO ] [.service.AbstractActiveService] - ZWave Refresh Service has been started

Hope that helps.

Is it possible to do it with scripting? I do not want to enable and disable bindings manual because the automation system should do that.

An automated system shouldn’t be powered down … :confused:

1 Like

Not the system, only some parts of it. I do not want my devices in standby
and consum energy. I have devices like sonos, denon AV receiver, tv, that
are not needed when I am not at home so I power them down. Saving energy,
but the bindings are throwing errors if devices are not reachable.

Am Montag, 21. September 2015 schrieb SiHui :

Probably this is what should be addressed then :smile:
In openHAB 2, devices that are not reachable definitely won’t log any errors (at least if not being used).

With script you could create a switch that Initiates copying the file from addon folder and back.

That disables the binding aß well.

I have the same “problem” as the thread owner. Harmony, Denon and my TV are turned off most of the day. But as Kai already said, the binding should handle this. But is there no workaround with osgi?
So it is not possible to execute a script that calls osgi commands?

This works pretty well :slight_smile:
For all who are interested an example below using the network health and exec bindings: if the radio leaves the local network, the radio binding is disabled. if the radio appears in the local network, it is (re)activated. The bindings jar files are removed and added by the exec binding - make sure to adjust the paths!

Items:

Switch presentRadio "Radio [%s]" <network> (gPresence) { nh="radio" }

/*
 * this items can be used to enable/disable binding as follows:
 * switch on: copy binding jar from runtime/addons-all/ to runtime/addons/
 * switch off: delete binding jar from runtime/addons/
 * input: this is only needed if the jar files are modified externally, so a very log refresh rate is sufficient (e.g. once every 6 hours: 21.600.000)
 */
Switch binding_radio (gBinding) { exec=">[ON:/bin/sh@@-c@@sudo cp /home/pi/o/runtime/addons-all/org.openhab.binding.frontiersiliconradio-*.jar /home/pi/o/runtime/addons/]
  >[OFF:/bin/sh@@-c@@sudo rm /home/pi/o/runtime/addons/org.openhab.binding.frontiersiliconradio-*.jar] 
  <[/bin/sh@@-c@@sudo test -f /home/pi/o/runtime/addons/org.openhab.binding.frontiersiliconradio-*.jar && echo ON || echo OFF:21000000:]" }

Rules:

rule "radio binding off when radio leaves LAN"
when Item presentRadio changed from ON to OFF then
	binding_radio.sendCommand(OFF)
end
rule "radio binding on when radio appears in LAN"
when Item presentRadio changed from OFF to ON then
	binding_radio.sendCommand(ON)
end
4 Likes