sebr / bhyve-home-assistant

Orbit BHyve custom component for Home Assistant
MIT License
251 stars 42 forks source link

Update for sensor.XXXX_smart_hose_tap_timer_battery_level fails #230

Closed dinan5 closed 4 months ago

dinan5 commented 8 months ago

Describe the bug Multiple times per day I get the following error message

Update for sensor.XXXX_smart_hose_tap_timer_battery_level fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 698, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 959, in async_device_update
    await self.async_update()
  File "/config/custom_components/bhyve/sensor.py", line 155, in async_update
    await super().async_update()
  File "/config/custom_components/bhyve/__init__.py", line 247, in async_update
    self._on_ws_data(ws_event)
  File "/config/custom_components/bhyve/sensor.py", line 148, in _on_ws_data
    battery_level = self.parse_battery_level(event)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bhyve/sensor.py", line 175, in parse_battery_level
    battery_level = battery_data.get("percent", 0)
                    ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'get'

Expected behaviour No error to occur

BHyve devices 2 devices - Smart Hose Tap, Orbit Sprinkler Controller

Device Diagnostics

AnthonyBe commented 7 months ago

Yeah, I'm seeing the same. Seems to be working OK, but spamming the log file.

2024-01-06 18:03:32.625 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.back_garden_battery_level fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 894, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1212, in async_device_update
    await self.async_update()
  File "/config/custom_components/bhyve/sensor.py", line 155, in async_update
    await super().async_update()
  File "/config/custom_components/bhyve/__init__.py", line 247, in async_update
    self._on_ws_data(ws_event)
  File "/config/custom_components/bhyve/sensor.py", line 148, in _on_ws_data
    battery_level = self.parse_battery_level(event)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bhyve/sensor.py", line 175, in parse_battery_level
    battery_level = battery_data.get("percent", 0)
                    ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'get'

I'm running

jhemak commented 6 months ago

Same here

sebr commented 4 months ago

Fixed with #236