Thank you for the contribution! I am having some difficulty getting this to work in HA though.
I have verified that SNMP is okay by running snmpwalk manually from my HA machine to the machine that has the UPS connected to it, and all the values you reference in the configuration come back with actual values, a few examples:
bill@raspberrypi:~/homeassistant/config $ snmpwalk -c public -v1 192.168.x.x .1.3.6.1.4.1.3808.1.1.1.1.1.1.0
iso.3.6.1.4.1.3808.1.1.1.1.1.1.0 = STRING: "CP1500PFCRM2U"
bill@raspberrypi:~/homeassistant/config $ snmpwalk -c public -v1 192.168.x.x .1.3.6.1.4.1.3808.1.1.1.4.1.1.0
iso.3.6.1.4.1.3808.1.1.1.4.1.1.0 = INTEGER: 2
bill@raspberrypi:~/homeassistant/config $ snmpwalk -c public -v1 192.168.x.x .1.3.6.1.4.1.3808.1.1.1.3.2.6.0
iso.3.6.1.4.1.3808.1.1.1.3.2.6.0 = INTEGER: 1
bill@raspberrypi:~/homeassistant/config $ snmpwalk -c public -v1 192.168.x.x .1.3.6.1.4.1.3808.1.1.1.4.1.1.0
iso.3.6.1.4.1.3808.1.1.1.4.1.1.0 = INTEGER: 2
bill@raspberrypi:~/homeassistant/config $ snmpwalk -c public -v1 192.168.x.x .1.3.6.1.4.1.3808.1.1.1.2.2.1.0
iso.3.6.1.4.1.3808.1.1.1.2.2.1.0 = Gauge32: 100
bill@raspberrypi:~/homeassistant/config $ snmpwalk -c public -v1 192.168.x.x .1.3.6.1.4.1.3808.1.1.1.2.2.2.0
iso.3.6.1.4.1.3808.1.1.1.2.2.2.0 = INTEGER: 274
However HA spits up a bunch of errors:
Logger: homeassistant.core
Source: core.py:1571
First occurred: 6:49:20 PM (1 occurrences)
Last logged: 6:49:20 PM
Error running job: <Job onetime listen homeassistant_start <function _async_at_core_state.<locals>._matched_event at 0x7ffec4e02b60> HassJobType.Callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7ffec4e02b60>>>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 658, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'unknown'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 661, in state
numerical_value = float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1571, in async_fire_internal
self._hass.async_run_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 947, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/core.py", line 1429, in __call__
self.hass.async_run_hass_job(self.listener_job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 947, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 44, in _matched_event
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 947, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 487, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1065, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1251, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 947, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 435, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1009, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1015, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 665, in state
raise ValueError(
ValueError: Sensor sensor.ups_battery_capacity_2 has device class 'None', state class 'None' unit '%' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unknown' (<class 'str'>)
This is the only sensor in my configuration.yaml
Any ideas? I do Linux admin and write yaml for a living, but am an total HA newbie.