Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snmp: Sensor Errors of "ValueError: negative count" Since Upgrading to core-2024.4.0 #114789

Closed
BigThunderSR opened this issue Apr 3, 2024 · 5 comments · Fixed by #114795
Closed

Comments

@BigThunderSR
Copy link

The problem

Getting the following errors since upgrading to core-2024.4.0:

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:951
First occurred: 6:17:45 PM (107 occurrences)
Last logged: 6:35:15 PM

Update for sensor.ups1_output_efficiency fails
Update for sensor.ups2_output_efficiency fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1268, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/snmp/sensor.py", line 218, in async_update
    await self.data.async_update()
  File "/usr/src/homeassistant/homeassistant/components/snmp/sensor.py", line 264, in async_update
    self.value = self._decode_value(resrow[-1])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/snmp/sensor.py", line 273, in _decode_value
    bytes(value),
    ^^^^^^^^^^^^
ValueError: negative count

The value of this sensor can be positive or negative and has never been an issue prior to this.

What version of Home Assistant Core has the issue?

core-2024.4.0

What was the last working version of Home Assistant Core?

core-2024.3.x

What type of installation are you running?

Home Assistant OS

Integration causing the issue

SNMP

Link to integration documentation on our website

https://www.home-assistant.io/integrations/snmp/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:951
First occurred: 6:17:45 PM (107 occurrences)
Last logged: 6:35:15 PM

Update for sensor.ups1_output_efficiency fails
Update for sensor.ups2_output_efficiency fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1268, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/snmp/sensor.py", line 218, in async_update
    await self.data.async_update()
  File "/usr/src/homeassistant/homeassistant/components/snmp/sensor.py", line 264, in async_update
    self.value = self._decode_value(resrow[-1])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/snmp/sensor.py", line 273, in _decode_value
    bytes(value),
    ^^^^^^^^^^^^
ValueError: negative count

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Apr 3, 2024

@BigThunderSR BigThunderSR changed the title SNMP Sensor Errors of "ValueError: negative count" Since Upgrading to core-2024.4.0 snmp: Sensor Errors of "ValueError: negative count" Since Upgrading to core-2024.4.0 Apr 3, 2024
@BigThunderSR
Copy link
Author

/cc @lextm, possibly another one for you like #114619. Thanks.

@lextm
Copy link
Contributor

lextm commented Apr 4, 2024

We are able to reproduce and resolve this. Will send a pull request soon.

lextm added a commit to lextm/core that referenced this issue Apr 4, 2024
@lextm lextm mentioned this issue Apr 4, 2024
20 tasks
@lextm
Copy link
Contributor

lextm commented Apr 4, 2024

The initial change was made by @ChristianKuehnel a few years ago, and it seems that no need to cast the value to bytes in that log entry (as many input values are not Opaque).

Sent #114795 with a new test case and we are sure it will resolve this issue.

@BigThunderSR
Copy link
Author

@lextm , thanks a lot for the quick turnaround!

@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants