Reading the Network Binding Configuration

openHAB 3.2.0.M4
I’m using jython scripts …

Can I query the Network binding for a configuration parameter? I want to read the “Retry” value of a network:pingdevice:xxxxx Thing … is this possible from jython scripts?

Have you tried accessing the REST API ?

Good suggestion :slight_smile: yes I can access it through REST … thanks! I’ll dig more see if I can access it directly without making a REST call.

Well, perhaps the REST call method is the only way, it is really easy. I wrote a generic function for getting config attributes if someone else has the need:

def getThingConfig(thing,attr):
    import json

    auth = {'Authorization' : 'Bearer YOUR_AUTH_FROM_OPENHAB'}
    response = HTTP.sendHttpGetRequest("http://openhabian.local:8080/rest/things/" + thing + "/", auth, 10000)

    Config = json.loads(response)
    if (attr != ""):
        Config = str(Config["configuration"][attr])
        Config = str(Config["configuration"])

You can pass in the configuration attribute if you know it, or pass in a null string and it will return the full JSON string which you can then inspect for the parameter you are looking for.

Thanks @Wolfgang_S for pointing me in the right direction :slight_smile:

1 Like