SNMP - Error while setting up platform snmp

Hi - having some trouble with my SNMP configuration.

Sample Config:

  - platform: snmp
    host: 192.168.0.###
    community: <secret>
    baseoid: 3.6.1.4.1.12325.1.1.2.1.1

baseoid is confirmed working.

I’m receiving the data and it seems to be working fine but not sure what is creating the error. I’m a HA enthusiast, not really a developer so can’t tell from the error log below.

I’ve been researching a bit and it looks similar to this older, closed issue but not sure.

Thoughts?
Thanks!

Error text from HA:

2017-10-29 21:19:22 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform snmp
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pyasn1/type/univ.py", line 1319, in prettyIn
    tupleOfInts = tuple([int(subOid) for subOid in value if subOid >= 0])
  File "/usr/lib/python3.6/site-packages/pyasn1/type/univ.py", line 1319, in <listcomp>
    tupleOfInts = tuple([int(subOid) for subOid in value if subOid >= 0])
TypeError: '>=' not supported between instances of 'str' and 'int'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 170, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/snmp.py", line 82, in setup_platform
    ObjectType(ObjectIdentity(baseoid))))
  File "/usr/lib/python3.6/site-packages/pysnmp/hlapi/asyncore/sync/cmdgen.py", line 111, in getCmd
    lookupMib=options.get('lookupMib', True)))
  File "/usr/lib/python3.6/site-packages/pysnmp/hlapi/asyncore/cmdgen.py", line 129, in getCmd
    vbProcessor.makeVarBinds(snmpEngine, varBinds), __cbFun,
  File "/usr/lib/python3.6/site-packages/pysnmp/hlapi/varbinds.py", line 39, in makeVarBinds
    __varBinds.append(varBind.resolveWithMib(mibViewController))
  File "/usr/lib/python3.6/site-packages/pysnmp/smi/rfc1902.py", line 845, in resolveWithMib
    self.__args[0].resolveWithMib(mibViewController)
  File "/usr/lib/python3.6/site-packages/pysnmp/smi/rfc1902.py", line 421, in resolveWithMib
    self.__oid
  File "/usr/lib/python3.6/site-packages/pysnmp/smi/view.py", line 206, in getNodeNameByOid
    nodeName, mibMod['oidToLabelIdx'], mibMod['labelToOidIdx']
  File "/usr/lib/python3.6/site-packages/pysnmp/smi/view.py", line 188, in __getOidLabel
    nodeName[:-1], oidToLabelIdx, labelToOidIdx
  File "/usr/lib/python3.6/site-packages/pysnmp/smi/view.py", line 188, in __getOidLabel
    nodeName[:-1], oidToLabelIdx, labelToOidIdx
  File "/usr/lib/python3.6/site-packages/pysnmp/smi/view.py", line 188, in __getOidLabel
    nodeName[:-1], oidToLabelIdx, labelToOidIdx
  [Previous line repeated 5 more times]
  File "/usr/lib/python3.6/site-packages/pysnmp/smi/view.py", line 191, in __getOidLabel
    resLabel = label + tuple([str(x) for x in suffix])
  File "/usr/lib/python3.6/site-packages/pyasn1/type/univ.py", line 1249, in __add__
    return self.clone(self._value + other)
  File "/usr/lib/python3.6/site-packages/pyasn1/type/base.py", line 311, in clone
    return self.__class__(value, **initilaizers)
  File "/usr/lib/python3.6/site-packages/pyasn1/type/base.py", line 203, in __init__
    value = self.prettyIn(value)
  File "/usr/lib/python3.6/site-packages/pyasn1/type/univ.py", line 1323, in prettyIn
    'Malformed Object ID %s at %s: %s' % (value, self.__class__.__name__, sys.exc_info()[1])
pyasn1.error.PyAsn1Error: Malformed Object ID (3, '6') at ObjectName: '>=' not supported between instances of 'str' and 'int'

Are you sure your Oid shouldn’t start with 1, I.e. 1.3.6.1.4.1.12325.1.1.2.1.1

Did anyone manage to figure this out?

Hi yes. You need the full base lid from the snmpwalk. Start with a period as I recall. I’ll double check when I’m back at my pc.

Update: Here is my config for pfsense wan in:

- platform: snmp
  name: wan_in_gb
  host: 192.168.###.###
  community: <secret>
  baseoid: .1.3.6.1.2.1.2.2.1.10.4

Hope that helps!

Edit 2:
If you are including a 64 bit counter, you need to include the version. This is clearly specified on the snmp sensor page however I missed it the first time. I hope it helps you.

- platform: snmp
  name: wan_in_gb
  host: 192.168.###.###
  community: <secret>
  baseoid: .1.3.6.1.2.1.31.1.1.1.6.4
  version: 2c
  value_template: '{{ ((states.sensor.wan_in_gb.state | float ) / 1000000000 ) | round(3) }}'
  unit_of_measurement: 'Gb'

brilliant thanks

1 Like