home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.35k stars 29.89k forks source link

SwitchBot Bot (finger) error on turning off - `IndexError: bytearray index out of range` #125347

Open Anto79-ops opened 1 week ago

Anto79-ops commented 1 week ago

The problem

Hello,

Not sure if this is a transient error, but noticed one of my action to turn off, was delayed by a couple of minutes (it did eventually work), and the logs show this at the time:

Logger: homeassistant.core
Source: core.py:2781
First occurred: 7:24:19 AM (1 occurrences)
Last logged: 7:24:19 AM

Error executing service: <ServiceCall switch.turn_off (c:01J715J55B595G5QVDDST6EJYM): entity_id=['switch.bot_0a53']>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2781, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/switchbot/entity.py", line 109, in async_turn_off
    self._last_run_success = bool(await self._device.turn_off())
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 96, in _async_update_after_operation_wrap
    await self.update()
  File "/usr/local/lib/python3.12/site-packages/switchbot/devices/device.py", line 574, in update
    if info := await self.get_basic_info():
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/switchbot/devices/bot.py", line 106, in get_basic_info
    "strength": _data[3],
                ~~~~~^^^
IndexError: bytearray index out of range

What version of Home Assistant Core has the issue?

2024.9.0

What was the last working version of Home Assistant Core?

not sure, first time seeing this

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Switchbot

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 week ago

Hey there @danielhiversen, @renierm26, @murtas, @eloston, @dsypniewski, mind taking a look at this issue as it has been labeled with an integration (switchbot) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `switchbot` 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 switchbot` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


switchbot documentation switchbot source (message by IssueLinks)