sebr/bhyve-home-assistant

Update for sensor.XXXX_smart_hose_tap_timer_battery_level fails

dinan5 opened this issue · 3 comments

dinan5 commented

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

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

  • Core 2024.1.1
  • Supervisor 2023.12.0
  • Operating System 11.3
  • Frontend 20240104.0
    ..but have been seeing this for a while so can't remember exactly when it started and what version I was running at that time.
jhemak commented

Same here

sebr commented

Fixed with #236