Hi All, I’m interested in creating a custom sensor for my APC UPS, more specific:
- the snmp OID is 1.3.6.1.4.1.318.1.1.1.11.1.1.0 and the value is represented as follows: "0001010000000000001000000000000000000000000000000000000000000000"
in a nutshell, each bit represents an event as follows:
Flag 1: Abnormal Condition Present
Flag 2: On Battery
Flag 3: Low Battery
Flag 4: On Line
Flag 5: Replace Battery
… and so on
I am interested in creating a sensor as this one:
- platform: snmp
name: ups_smart_status
host: SNMP_IP
baseoid: 1.3.6.1.4.1.318.1.1.1.4.1.1.0
accept_errors: true
value_template: >-
{%if value == '1' %}
Unknown
{% elif value == '2' %}
On Line
{% elif value == '3' %}
On Battery
{% elif value == '4' %}
On Smart Boost
{% elif value == '5' %}
Timed Sleeping
{% elif value == '6' %}
Software Bypass
{% elif value == '7' %}
Off
{% elif value == '8' %}
Rebooting
{% elif value == '9' %}
Switched Bypass
{% elif value == '10' %}
Hardware Failure Bypass
{% elif value == '11' %}
Sleeping Until Power Returns
{% elif value == '12' %}
On Smart Trim
{% endif %}
the only problem being the “value”, witch in my case is not an integer number.
Any ideeas that could point me in the right direction ?
Many thanks, Gigel