romedtino / simple-wyze-vac

Home Assistant Custom Component for Wyze Vacuum
49 stars 8 forks source link

Protobuff error on startup #25

Closed sergeknystautas closed 2 years ago

sergeknystautas commented 2 years ago

I used to be able to access my vacuum state using the wyze add-on and the simple-wyze hacs, but I assume from the recent updates that I'm now seeing a protobuff parse error in the logs and my vacuum entity is not available. I'm on simple-wyze 1.6.1 and wyze 0.1.8.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/simple_wyze_vac/vacuum.py", line 76, in setup_platform
    vacs.append(WyzeVac(hass.data[WYZE_VAC_CLIENT], pl, username, password, polling))
  File "/config/custom_components/simple_wyze_vac/vacuum.py", line 108, in __init__
    self.update()
  File "/config/custom_components/simple_wyze_vac/vacuum.py", line 303, in update
    self._rooms = self.get_rooms(vacuum)
  File "/config/custom_components/simple_wyze_vac/vacuum.py", line 347, in get_rooms
    for room in vacuum.current_map.rooms:
  File "/usr/local/lib/python3.9/site-packages/wyze_sdk/models/devices/vacuums.py", line 368, in rooms
    map_data = self.parse_blob(blob=self._blob)
  File "/usr/local/lib/python3.9/site-packages/wyze_sdk/models/devices/vacuums.py", line 406, in parse_blob
    map, typedef = blackboxprotobuf.protobuf_to_json(base64.b64decode(base64.b64encode(decompressed)), 'robot_map')
  File "/usr/local/lib/python3.9/site-packages/blackboxprotobuf/lib/interface.py", line 75, in protobuf_to_json
    value, message_type = decode_message(buf, message_type)
  File "/usr/local/lib/python3.9/site-packages/blackboxprotobuf/lib/interface.py", line 62, in decode_message
    value, typedef, _ = blackboxprotobuf.lib.types.length_delim.decode_message(buf, message_type)
  File "/usr/local/lib/python3.9/site-packages/blackboxprotobuf/lib/types/length_delim.py", line 271, in decode_message
    if isinstance(output[field_number], list):
KeyError: '5'
romedtino commented 2 years ago

Hi, do you mind checking what your vacuum firmware version is? This might be a duplicate already here - https://github.com/romedtino/simple-wyze-vac/issues/9

sergeknystautas commented 2 years ago

Yes, my firmware is 1.6.173 as I wanted the multi-room support, but this was working a week ago so I don't think it's in the same place of the code. Also, this is when simply getting status and reading the map data, not when sending a sweep command. I would guess the status was working previous with 1.6.173 but when reading the map image was added, it would break, but that's just by reading what was part of the release and a scan of the methods in the stack trace, not reading the code.

sergeknystautas commented 2 years ago

Ok, so we're both sort of right. romedtino in the commit 6fb756 to add room as attributes makes a call to vacuum.current_map.rooms. This is the call that prior to this commit was happening in sweep_room.

So it is the same root cause, that vacuum.current_map.rooms does not support firmware 1.6.173. The problem is that instead of only breaking one action, it now breaks the entire integration. And my guess that it was reading the map image was a bad guess... it's for the room attributes improvement. :(

Is there a bug report in the wyze_sdk project to get support? It would be nice to remove this call since it's now in the critical path, but that's just a workaround and we'll have to get this fixed in the wyze_sdk code.

romedtino commented 2 years ago

Gotcha, yeah that makes sense. I think I can actually workaround that json issue since I ended up forking wyze-sdk. For now, if you don't mind just use an older release. And I'll get that fix out. Thanks!

romedtino commented 2 years ago

@sergeknystautas Do you mind trying pre-release 1.6.2? Update information in HACS, make sure show beta versions is checked and try 1.6.2? Since it's just a workaround, you probably won't see the rooms attribute fill in correctly since it can't actually parse the blob correctly but hopefully it still allows you to do other things not related to rooms. Thanks!

sergeknystautas commented 2 years ago

I picked up the 1.6.2 pre-release version, but I'm seeing the same stack trace (looked it over and the same line numbers). I'm guessing it's not picking up your forked wyze-sdk... is there a way I can check that? I poked around the file system but wasn't sure where HA is storing the cached python dependencies.

romedtino commented 2 years ago

Ah, yeah I flubbed updating the version number in version.py. There should now be a 1.6.3 beta release and hopefully that should be smart enough to get the newer wyze_sdk version. I just tried it on my box and it seems to have worked. Mind trying that?

sergeknystautas commented 2 years ago

Thanks, I super appreciate the iteration and happy to reload and debug this. 1.6.3 got me the new forked version of the wyze_sdk so progress, and now I get a different stack trace.

File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/simple_wyze_vac/vacuum.py", line 76, in setup_platform vacs.append(WyzeVac(hass.data[WYZE_VAC_CLIENT], pl, username, password, polling)) File "/config/custom_components/simple_wyze_vac/vacuum.py", line 108, in __init__ self.update() File "/config/custom_components/simple_wyze_vac/vacuum.py", line 303, in update self._rooms = self.get_rooms(vacuum) File "/config/custom_components/simple_wyze_vac/vacuum.py", line 347, in get_rooms for room in vacuum.current_map.rooms: File "/usr/local/lib/python3.9/site-packages/wyze_sdk/models/devices/vacuums.py", line 369, in rooms if 'roomDataInfo_' in map_data: TypeError: argument of type 'NoneType' is not iterable

romedtino commented 2 years ago

Alright, I think I quelled those None issues. Try beta 1.6.4?

sergeknystautas commented 2 years ago

1.6.4 worked like a charm for initialization.

I had never tried but went ahead and did sweep_room service call, and got a similar looking NoneType error as the one you were sorting, so thought I'd mention and then you might be able to close that related bug:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 367, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 570, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1636, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1673, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 671, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 949, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 708, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/vacuum/__init__.py", line 264, in async_send_command await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/simple_wyze_vac/vacuum.py", line 254, in send_command self._client.vacuums.sweep_rooms(device_mac=self._vac_mac, room_ids=[room.id for room in vacuum.current_map.rooms if room.name in desired_rooms]) TypeError: 'NoneType' object is not iterable

romedtino commented 2 years ago

ah dangit yea I missed the vacuum.current_map.rooms call there good catch at least that's only in the custom_component and not in wyze_sdk anymore. I'll do a fix for it. Thanks for all the help!

sergeknystautas commented 2 years ago

Sure thing... now I get a clean message on sweep_room call. Everything is functional now. No rooms from Wyze servers. You may have the unsupported multi-floor firmware. Sweep rooms currently does not work on this firmware.

Thank you for all of the work on this!

romedtino commented 2 years ago

Nice glad it works! When Wyze fully rolls out that firmware I'll take a stab and see if we can get sweep room support on that firmware.

romedtino commented 1 year ago

Gotcha, yeah that makes sense. I think I can actually workaround that json issue since I ended up forking wyze-sdk. For now, if you don't mind just use an older release. And I'll get that fix out. Thanks!

On Mon, Apr 4, 2022, 00:46 sergeknystautas @.***> wrote:

Ok, so we're both right. romedtino in the commit 6fb756 https://github.com/romedtino/simple-wyze-vac/commit/6fb756d313e29fb2ae2f3833586be6d2511974eb to add room as attributes makes a call to vacuum.current_map.rooms. This is the call that prior to this commit was happening in sweep_room.

So it is the same root cause, that vacuum.current_map.rooms does not support firmware 1.6.173. The problem is that instead of only breaking one action, it now breaks the entire integration.

— Reply to this email directly, view it on GitHub https://github.com/romedtino/simple-wyze-vac/issues/25#issuecomment-1087224159, or unsubscribe https://github.com/notifications/unsubscribe-auth/AENU7WDOHX3QAQ6O5ADETJLVDKM4BANCNFSM5SOLAPNA . You are receiving this because you commented.Message ID: @.***>