Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List Index out of Range #71

Open
malammar opened this issue Aug 4, 2023 · 3 comments
Open

List Index out of Range #71

malammar opened this issue Aug 4, 2023 · 3 comments

Comments

@malammar
Copy link

malammar commented Aug 4, 2023

I have a couple of Wyze Lock Bolts and they seem to be causing an out of range error in this integration:

home-assistant  | 2023-08-04 13:48:31.221 ERROR (MainThread) [homeassistant.components.lock] wyzeapi: Error on device update!
home-assistant  | Traceback (most recent call last):
home-assistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 570, in _async_add_entity
home-assistant  |     await entity.async_device_update(warning=False)
home-assistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 940, in async_device_update
home-assistant  |     await self.async_update()
home-assistant  |   File "/config/custom_components/wyzeapi/token_manager.py", line 45, in inner_function
home-assistant  |     await func(*args, **kwargs)
home-assistant  |   File "/config/custom_components/wyzeapi/lock.py", line 149, in async_update
home-assistant  |     lock = await self._lock_service.update(self._lock)
home-assistant  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
home-assistant  |   File "/usr/local/lib/python3.11/site-packages/wyzeapy/services/lock_service.py", line 18, in update
home-assistant  |     device_info = await self._get_lock_info(lock)
home-assistant  |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
home-assistant  |   File "/usr/local/lib/python3.11/site-packages/wyzeapy/services/base_service.py", line 499, in _get_lock_info
home-assistant  |     device_uuid = device.mac.split(".")[2]
home-assistant  |                   ~~~~~~~~~~~~~~~~~~~~~^^^
home-assistant  | IndexError: list index out of range

I don't really need those locks supported but this is impacting updates to my other Wyze devices.

@SecKatie
Copy link
Owner

SecKatie commented Aug 5, 2023

Looks like they changed how the device address is configured... Is it possible to find what the actual value is so we can parse it correctly?

@malammar can you add a debug log statement to wyzeapy/services/base_service.py and share the line in the log?

@malammar
Copy link
Author

malammar commented Aug 6, 2023

I have an old debug log from lock_service.py which might have what you're looking for:

[
  {
    "available": false,
    "raw_dict": {
      "mac": "YD_BT1.39aa4f3a9267557ddee4043da924c704",
      "first_activation_ts": 1654131355000,
      "first_binding_ts": 1654131355000,
      "enr": "",
      "nickname": "Front Door",
      "timezone_name": "America/Los_Angeles",
      "product_model": "YD_BT1",
      "product_model_logo_url": "",
      "product_type": "Lock",
      "hardware_ver": "0.0.0.0",
      "firmware_ver": "1.0.0",
      "user_role": 1,
      "binding_user_nickname": "REDACTED",
      "conn_state": 1,
      "conn_state_ts": 0,
      "push_switch": 1,
      "device_params": {},
      "is_in_auto": 0,
      "event_master_switch": 1,
      "parent_device_mac": "",
      "parent_device_enr": "",
      "binding_ts": 1654131355000,
      "timezone_gmt_offset": -7.0
    }
  }
]

@JoeSchubert
Copy link
Collaborator

JoeSchubert commented Oct 25, 2023

@SecKatie

Looking at the output malamar posted there, I feel like they used to have "something.somethingelse.uuid" and they removed one of the somethings.

however, I'm not sure if some versions of the lock still have 3 fields? So maybe it's just worth changing
device_uuid = device.mac.split(".")[2]
to
device_uuid = device.mac.split(".")[-1]

Those changes will need to be here:

device_uuid = device.mac.split(".")[2]
and here:
device_uuid = device.mac.split(".")[2]

I think it was always the last segment of the mac when split by .'s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants