core: Lock/Unlock - ERROR - bytearray index out of range

The problem

since ver 2023.3.0 cant using my lock, see error as below

What version of Home Assistant Core has the issue?

2023.3.0

What was the last working version of Home Assistant Core?

all previous version

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Home Assistant WebSocket API

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/switchbot/lock.py:54
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 15:50:22 (15 occurrences)
Last logged: 21:57:14

[547079408560] bytearray index out of range
[546638650944] bytearray index out of range
[546973367792] bytearray index out of range
[547390320752] bytearray index out of range
[546960781424] bytearray index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 198, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1808, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 686, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 961, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 726, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/lock/__init__.py", line 106, in _async_unlock
    await entity.async_unlock(**remove_entity_service_fields(service_call))
  File "/usr/src/homeassistant/homeassistant/components/switchbot/lock.py", line 54, in async_unlock
    self._last_run_success = await self._device.unlock()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 168, in unlock
    return await self._lock_unlock(
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 196, in _lock_unlock
    self._update_parsed_data(self._parse_basic_data(basic_data))
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 175, in _parse_basic_data
    "battery": basic_data[1],
IndexError: bytearray index out of range

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 19

Most upvoted comments

The only way around right now is setting up a reload automation of lock every 10 mins. In that way lock is loaded every 10 mins and stays active it’s a known home assistant issue