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

ESPHome connection closed if numeric sensor has non-numeric value #93722

Closed
samuelolteanu opened this issue May 29, 2023 · 3 comments · Fixed by #93723
Closed

ESPHome connection closed if numeric sensor has non-numeric value #93722

samuelolteanu opened this issue May 29, 2023 · 3 comments · Fixed by #93723

Comments

@samuelolteanu
Copy link

The problem

This issue is related to #92479 except it disconnects the whole ESPHome node, including working sensors and connects back again when the value of that specific sensor is numeric again.
If #85605 introduced this bug, please revert those changes as they prevent me from permanently upgrading from Home Assistant 2023.4.6.
The buggy sensor is "calculated_lux" component of TSL2591 Ambient Light Sensor(https://esphome.io/components/sensor/tsl2591.html#tsl2591-ambient-light-sensor). It's either "0" or "inf" at night.
Not a pressing issue on older versions of HA Core.

What version of Home Assistant Core has the issue?

2023.5.x

What was the last working version of Home Assistant Core?

2023.4.6

What type of installation are you running?

Home Assistant OS

Integration causing the issue

esphome

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

#esphome yaml

sensor:
  calculated_lux:
          id: i_lux
          name: "Luminita Lux"
          unit_of_measurement: "lx"
          accuracy_decimals: 0
          filters:
               - or:
                  - throttle: 30s
                  - delta: 1000

Anything in the logs that might be useful for us?

Logger: homeassistant
Source: components/sensor/__init__.py:583
First occurred: 28 mai 2023 la 21:15:57 (249 occurrences)
Last logged: 28 mai 2023 la 21:23:13

Error doing job: Fatal error: protocol.data_received() call failed.
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 579, in state
    numerical_value = int(value)
ValueError: invalid literal for int() with base 10: 'inf'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 876, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/_frame_helper.py", line 182, in data_received
    self._callback_packet(msg_type_int, bytes(packet_data))
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/_frame_helper.py", line 102, in _callback_packet
    self._on_pkt(type_, data)
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/connection.py", line 690, in _process_packet
    handler(msg)
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 395, in on_msg
    on_state(cls.from_pb(msg))
  File "/usr/src/homeassistant/homeassistant/components/esphome/entry_data.py", line 270, in async_update_state
    self.state_subscriptions[subscription_key]()
  File "/usr/src/homeassistant/homeassistant/components/esphome/__init__.py", line 807, in _on_state_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 583, in state
    raise ValueError(
ValueError: Sensor sensor.luminita_lux has device class illuminance, state class measurement unit lx and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: inf (<class 'str'>)

Additional information

As I was testing HA 2023.5.4, i've still got a Riemann sensor reset wich shouldn't occur since #93137.

@home-assistant
Copy link

Hey there @OttoWinter, @jesserockz, mind taking a look at this issue as it has been labeled with an integration (esphome) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of esphome can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign esphome Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


esphome documentation
esphome source
(message by IssueLinks)

@bdraco
Copy link
Member

bdraco commented May 29, 2023

inf isn't a valid value for that unit of measurement

That seems like a bug in the esphome component

However it shouldn't cause a disconnection

@vampywiz17

This comment was marked as off-topic.

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.

5 participants