markvader / sonic

Sonic water shutoff valve Home Assistant integration by @markvader
MIT License
14 stars 4 forks source link

Battery sensor no longer displayed #23

Closed frazzyfin closed 1 year ago

frazzyfin commented 1 year ago

The battery sensor for the Sonic isn't displayed any more. The following error is showin the logs:

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: 'high'

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 504, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 788, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_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.battery has device class 'None', state class 'measurement' unit 'battery' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'high' (<class 'str'>)
markvader commented 1 year ago

Thanks for letting me know. I'll get a fix for this pushed out in the next day or so

markvader commented 1 year ago

Can you update to latest release v0.1.12 and see if that has fixed it okay.

frazzyfin commented 1 year ago

Yes that works now, thanks!