EXEC "Binding conf not correctly"

Please… I have an ITEM to receive connected Wifi network name from another computer. I use an SSH command to get this information:

shell$ sshpass -p password ssh pi@ipaddress "/sbin/iwconfig wlan0 | grep ESSID: | cut -d ':' -f2 | cut -d 'N' -f1 | xargs"

I did a shell script emoncms_wifi_nome.sh to call this command using EXEC binding, like:

String Emonhub_Wifi_nome "Rede Wifi [%s]" { exec="<[sudo /usr/share/openhab/configurations/scripts/emoncms_wifi_nome.sh]" }

However, I have this message error…

10:09:30.439 ERROR o.o.m.i.i.GenericItemProvider[:350]- Binding configuration of type 'exec' of item ‘Emonhub_Wifi_nome‘ could not be parsed correctly.
org.openhab.model.item.binding.BindingConfigParseException: bindingConfig 'sudo /usr/share/openhab/configurations/scripts/emoncms_wifi_nome.sh' doesn't represent a valid in-binding-configuration.
	at org.openhab.binding.exec.internal.ExecGenericBindingProvider.parseInBindingConfig(ExecGenericBindingProvider.java:140)
	at org.openhab.binding.exec.internal.ExecGenericBindingProvider.processBindingConfiguration(ExecGenericBindingProvider.java:120)
	at org.openhab.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:348)
	at org.openhab.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:324)
	at org.openhab.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:171)
	at org.openhab.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:390)

What could be wrong? Any idea?


I think you’re missing the refreshinterval?

in: exec="<[<commandLine to execute>:<refreshintervalinmilliseconds>:(<transformationrule>)]"

I already did with refresh interval… not difference. It is optional.

I think it is required. Have you tried using it like this:

String Emonhub_Wifi_nome "Rede Wifi [%s]" { exec="<[sudo /usr/share/openhab/configurations/scripts/emoncms_wifi_nome.sh:1000:]" }

Uses interval of 1000ms and no transformation, so your script has to return a valid switch value. You should have a : at the end when not using a transformation.

The binding config is parsed with a regular expression. Looking at the code that logs the error you are seeing, the regex is…


This implies you’ll need two trailing colons after the command since you are not providing a refresh interval or a transformation.

1 Like

Yes but according to the binding doc only transformation is optional so that means one trailing colon and a refresh interval.

in:  exec="<[<commandLine to execute>:<refreshintervalinmilliseconds>:(<transformationrule>)]"
out: exec=">[<openHAB-command>:<commandLine to execute>] (>[<openHAB-command>:<commandLine to execute>]) (>[...])"

where the parts in () are optional.

1 Like

sudo /usr/share/openhab/configurations/scripts/emoncms_wifi_nome.sh:1000:

ERROR o.o.p.e.internal.ExecService[:84]- Could not execute command [null]
java.lang.NullPointerException: null
at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
at java.util.regex.Matcher.reset(Matcher.java:309)
at java.util.regex.Matcher.(Matcher.java:229)
at java.util.regex.Pattern.matcher(Pattern.java:1093)
at java.util.Formatter.parse(Formatter.java:2547)
at java.util.Formatter.format(Formatter.java:2501)

Steve… solved:

<[sudo /usr/share/openhab/configurations/scripts/emoncms_wifi_nome.sh:10000:REGEX((.*?))]

script looks like:

sshpass -p PI_USER_PASS ssh -o StrictHostKeyChecking=no pi@SERVER_IP "/sbin/iwconfig wlan0 | grep ESSID: | cut -d ':' -f2 | cut -d 'N' -f1 | xargs"

1 Like