Unsure if this is the method to reporting this, but I have started testing SNMP 2 and come across an issues setting the thing as a switch value. While the onvalue works great, the offvalue is failing as the full OID is a dynamic one and just disappears, the parent OID of .18.104.22.168.22.214.171.124.1.3.800.1 reports all of the IPs from the ARP table.
Type switch : phone_thing1 [ oid=".126.96.36.199.188.8.131.52.1.3.800.1.192.168.1.5", mode="READ", datatype="IPADDRESS", onvalue="192.168.1.5", offvalue="nosuchinstance" ]
Type switch : phone_thing2 [ oid=".184.108.40.206.220.127.116.11.1.3.800.1.192.168.1.5", mode="READ", datatype="IPADDRESS", onvalue="192.168.1.5", offvalue="Null" ]
My openhab log file was flooded with the following when I left my house, as my phone left and the IP was cleared from the ARP table.
2019-08-14 11:36:29.031 [WARN ] [ding.snmp.internal.SnmpTargetHandler] - Error: request 192.168.1.1/161:18.104.22.168.22.214.171.124.1.3.800.1.192.168.1.5 returned '126.96.36.199.188.8.131.52.1.3.800.1.192.168.1.5 = noSuchInstance'
2019-08-14 11:37:29.030 [WARN ] [ding.snmp.internal.SnmpTargetHandler] - Error: request 192.168.1.1/161:184.108.40.206.220.127.116.11.1.3.800.1.192.168.1.5 returned '18.104.22.168.22.214.171.124.1.3.800.1.192.168.1.5 = noSuchInstance'
2019-08-14 11:38:29.031 [WARN ] [ding.snmp.internal.SnmpTargetHandler] - Error: request 192.168.1.1/161:126.96.36.199.188.8.131.52.1.3.800.1.192.168.1.5 returned '184.108.40.206.220.127.116.11.1.3.800.1.192.168.1.5 = noSuchInstance'
2019-08-14 11:39:29.032 [WARN ] [ding.snmp.internal.SnmpTargetHandler] - Error: request 192.168.1.1/161:18.104.22.168.22.214.171.124.1.3.800.1.192.168.1.5 returned '126.96.36.199.188.8.131.52.1.3.800.1.192.168.1.5 = noSuchInstance'
2019-08-14 11:40:29.032 [WARN ] [ding.snmp.internal.SnmpTargetHandler] - Error: request 192.168.1.1/161:184.108.40.206.220.127.116.11.1.3.800.1.192.168.1.5 returned '18.104.22.168.22.214.171.124.1.3.800.1.192.168.1.5 = noSuchInstance'
With SNMP v1.x I was able to create a map file as the result was Null and I mapped it to OFF; I don’t see a difference or know of a value I can map to the offvalue to have the switch work properly.
Open to thoughts or suggestions if anyone has any.
Are you referring to
SNMP v1 vs
SNMP v2 or different versions of the binding?
SNMP itself is v2c on the network switch.
SNMP binding is v2.x.
I think you should only have 1 thing. What is your Thing configuration for
Here are the docs with an example.
I do only have 1 thing defined, I listed both as different configurations I have tried so far to account for the OID not existing when the phone leaves the network. I used the OH doco to create what I have so far, when a phone is on the network it works as expected.
With the 1.x version of the SNMP binding requesting the OID .126.96.36.199.188.8.131.52.1.3.800.1.192.168.1.5 will return the IP address from the ARP table of the switch, when the ARP entry expires (as the phone has left) the OID is actually removed and a query will fail. With the way OH handled it was by returning a Null value, the new way is behaving differently and I am looking to find a way to have the ‘offvalue’ value change to OFF. I only discovered this problem as I was updating a topic I wrote on using SNMP as another method to determine phone presence.
Below is an example of how the parent OID of the ARP table looks like.
$ snmpwalk -v2c -c public 192.168.1.1 184.108.40.206.220.127.116.11.1.3.800.1
18.104.22.168.22.214.171.124.1.3.800.1.192.168.1.29 = IpAddress: 192.168.1.29
126.96.36.199.188.8.131.52.1.3.800.1.192.168.1.45 = IpAddress: 192.168.1.45
184.108.40.206.220.127.116.11.1.3.800.1.192.168.1.231 = IpAddress: h192.168.1.231
Let’s start at the beginning.
What are you trying to accomplish with this? What is your end goal?
That is what I am trying to do with the new binding, as arping is not an option when OH and phones are in two different subnets.
So while the detection of the phone works as the OID exists, it is when the phone leaves that the binding doesn’t know what to do. It spams the log file and doesn’t change the value of the item.
From the CODEOWNER file found here it appears @J-N-K is author, perhaps he’ll pop in and let us know how it should work
I would call that a bad design but anyway, I could set the channel-value to UNDEF if no response is received. You can map that to whatever you want then.
It was probably set that way to avoid keeping static entries in the MIB tables for ping sweeps/arp scans as by default the ARP table clears entries 4 hours by default.
Providing a UNDEF would probably resolve the issue, if the OID is not found; but I am receiving a response from the switch of ‘noSuchInstance’. So I’m unsure if this is something that is easy to change on the channel?
Also was unsure if a ‘onValue’ is specified, if you have to also define the ‘offValue’? Was going to also try applying a map statement on the phone2 item line to see if that could change the outcome of the switch state.
Please try this version
bundle:update <number> https://janessa.me/esh/org.openhab.binding.snmp-undef.jar. Exceptions (like the one above) now set the channel to UNDEF.
You’ll find a new configuration option (“advanced” in PaperUI)
ignoreException. If you set
true here, your log will not be flooded.
Awesome @J-N-K!!! I’ll comment out config files and set things up through PaperUI and test things out tonight as I don’t have a phone on the WiFi currently.
For doco purposes, if this replicates what I have working with the 1.x version of the binding; how can I add the ignoreException to config file?
2.X bindings do not use a config file like the 1.X ones do.
While that may be true for some bindings, the doco actually has a Thing file example along with a Item file example.
Some bindings require manual
Thing configuration. Others, such as zwave, automatically discover Things as the preferred method.
Just add it as an option to the channel configuration
So testing has taken place, the On-Value works; turned off my wireless and waited 3 mins and the log spamming does occur, and the value in /rest/items/phone2 has a state of UNDEF.
I added UNDEF to the Off-Value and had the following log:
2019-08-15 21:36:55.909 [WARN ] [ding.snmp.internal.SnmpTargetHandler] - illegal value configuration for channel snmp:target:switch:phone2_thing
Also tried another round of testing with the config files setup, and the ignoreException=“true” does flip to on in PaperUI on the channel. I checked in /rest/things/snmp:target:switch and it has the following value:
Checking /rest/things/snmp:target:switch2 reports the following:
Item state doesn’t change from UNDEF when I have a thing file in use; would a debug log be helpful for anything?
Awesome as always @J-N-K!!! I’ll wipe out the PaperUI and config files when I get home tonight and do another round of testing and report back results.