Hello -
I have the following which I found online running as package.yaml, in fact there is two of them which is why you will see in the code below to distinguish between them I needed to add _2. I am not sure how to troubleshoot the error based on what is in the log. Help graciously appreciated.
Logger: homeassistant
Source: components/sensor/__init__.py:594
First occurred: July 11, 2023 at 6:29:27 AM (1499 occurrences)
Last logged: 7:56:29 PM
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 590, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'unknown'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 918, in _update_entity_states
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 713, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 810, in _async_write_ha_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 594, in state
raise ValueError(
ValueError: Sensor sensor.ups_itemp_2 has device class 'None', state class 'None' unit '°C' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unknown' (<class 'str'>)
Code:
sensor:
- platform: snmp
scan_interval: 90
name: ups_nompower_2
host: 192.168.10.13
baseoid: 1.3.6.1.4.1.3808.1.1.1.4.2.5.0
accept_errors: true
unit_of_measurement: Watts - platform: snmp
scan_interval: 90
name: ups_nominv_2
host: 192.168.10.13
baseoid: 1.3.6.1.4.1.3808.1.1.1.3.2.1.0
accept_errors: true
unit_of_measurement: Volts
value_template: ‘{{((value | int) / 10) | int}}’ - platform: snmp
scan_interval: 90
name: ups_itemp_2
host: 192.168.10.13
baseoid: 1.3.6.1.4.1.3808.1.1.1.2.2.3.0
accept_errors: true
unit_of_measurement: “°C” - platform: snmp
scan_interval: 90
name: ups_timeleft_2
host: 192.168.10.13
baseoid: 1.3.6.1.4.1.3808.1.1.1.2.2.4.0
accept_errors: true
unit_of_measurement: ‘minutes’
value_template: ‘{{((value | int) / 6000) | int}}’ - platform: snmp
scan_interval: 90
name: ups_status_2
host: 192.168.10.13
baseoid: 1.3.6.1.4.1.3808.1.1.1.4.1.1.0
accept_errors: true
value_template: >-
{% set status = (value | int) %}
{%- if status == 2 -%}
Online
{%- elif status == 3 -%}
On Battery
{%- elif status == 4 -%}
On Boost
{%- elif status == 5 -%}
On Sleep
{%- elif status == 6 -%}
Off
{%- elif status == 7 -%}
Rebooting
{%- elif status == 8 -%}
On ECO
{%- elif status == 9 -%}
On Bypass
{%- elif status == 10 -%}
On Buck
{%- elif status == 11 -%}
On Overload
{%- else -%}
Unknown
{%- endif -%}
group:
ups_2:
name: UPS 2
entities:
- sensor.ups_status_2
- sensor.ups_nompower_2
- sensor.ups_nominv_2
- sensor.ups_itemp_2
- sensor.ups_timeleft_2
homeassistant:
customize:
sensor.ups_nompower_2:
friendly_name: ‘UPS Nominal Output Power’
icon: mdi:flash
sensor.ups_nominv_2:
friendly_name: ‘UPS Nominal Input Voltage’
icon: mdi:flash
sensor.ups_status_2:
friendly_name: ‘UPS Status’
icon: mdi:information-outline
sensor.ups_itemp_2:
friendly_name: ‘UPS Internal Temperature’
icon: mdi:thermometer
sensor.ups_timeleft_2:
friendly_name: ‘UPS Time Left’
icon: mdi:clock-alert