Snmp values read by HA, not correspond with value sended by device

Hi,

I want monitor my UPS status by HA. I decided use snmp protocol.

My configuration is:

- platform: snmp
  name: 'UPS Voltaje Bateria'
  host: 192.168.1.100
  baseoid: 1.3.6.1.4.1.6574.4.3.2.1.0 # ups battery voltage value "27.1000003814697"
  unit_of_measurement: 'voltios'

So if a use a snmp software to sniffing the value, i obtain:

imagen

And when i see value in HA state, i see this:

What i’m doing wrong?

thanks

Do you get a value in the Template engine?

Try
{{states.sensor.ups_voltaje_bateria}}

Sorry, where i need test if i obtain a value? where i can find Template engine in HA menu?

If i did this:

i obtain this:

That’s the state engine, icon <>, use the icon two steps to the right of that (icon looks like a grey page with <>).

OK, i did, and the result is:

Ok, that tells us that there is communication between the UPS and HASS but HASS isn’t able to interpret the UPS response.

Did you enable SNMP on the UPS and what community name did you use? According to the SNMP component docs, community name is a required field in the sensor declaration. Do you get any messages in the log?

Well i enabled snmp in my NAS, and using a software in my PC (Paessler snmp tester), i can read the snmp of the ups that is connected to the NAS.

The community is the default one (public).

In that case, using software i can read, meanwhile by HA, i can’t.

In log, i don’t see anything about snmp or “sensor.ups_voltaje_bateria”

It seems to me you’ve done everything the right way, I don’t know what else to try.

Yes, i dunno where can be the problem.

Maybe someone else has experience with snmp… and can help

You might need to set version: 2c on that sensor. The component defaults the version to 1

Hi @cbulock,

I did it and all continue the same:

- platform: snmp
  name: 'UPS Voltaje Bateria'
  host: 192.168.1.100
  baseoid: 1.3.6.1.4.1.6574.4.3.2.1.0  # ups battery voltage value "27.1000003814697"
  version: 2c
  unit_of_measurement: 'voltios' 

something else that maybe i forget?

thanks,

Sorry, that was the only idea I had. Everything else looks like it should be correct.

This is a known issue I reported myself quite some time ago: #2767

Someone was kind enough to start working on a fix: PR #11239. The code in that PR works (tested it myself for a while) but unfortunately it hasn’t been finalized and merged (yet).

Hi,

I saw. Also in github, i saw that you show some values. How did you obtained?

Please other question is which is the OID to know the status of the UPS.

thanks

The answers to your questions should be in my first post in my issue (linked above), where I included all the snmp sensors I used.

Keep in mind that the bottom 4 sensors in that printscreen only work with the code in the PR (linked above). Without that, those bottom 4 sensors would look exactly like yours.

Hi @fanaticDavid,

I copied the new file snmp.py in custom_components of my HA. but i have some errors

  File "/usr/src/app/homeassistant/config.py", line 645, in async_process_component_config
    platform = get_platform(domain, p_name)
  File "/usr/src/app/homeassistant/loader.py", line 104, in get_platform
    return get_component(PLATFORM_FORMAT.format(domain, platform))
  File "/usr/src/app/homeassistant/loader.py", line 142, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/sensor/snmp.py", line 205
    return str(value)

Maybe i don’t need to put it in custom_components and need to overwrite file snmp.py?

thanks

When I was testing the code, I renamed the original snmp.py file on my system and put the one from the PR there instead. I never tried it as a custom component.
Of course, I had to repeat the actions above anytime I updated Home Assistant to a newer version.

Hi,

Someone knows if in lastest version of HA, this problem was solved?

thanks

I have found a Workaround Using pythons webservice i wrote.
it uses flask and pysnmp. this way i can get the snmp values correctly using rest api.

image