romedtino / simple-wyze-vac

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

Unknown error when sending sweep_rooms command #9

Closed kevinyc closed 2 years ago

kevinyc commented 2 years ago

All other commands/service calls work except for sweep_rooms. I'm using the beta with multi-floor mapping.

2021-12-01 19:31:56 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139928878595472] Error handling message: Unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 523, in handle_execute_script
    await script_obj.async_run(msg.get("variables"), context=context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1243, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 353, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 371, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 571, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 667, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 863, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 704, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/vacuum/__init__.py", line 262, in async_send_command
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/simple_wyze_vac/vacuum.py", line 223, 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])
  File "/usr/local/lib/python3.9/site-packages/wyze_sdk/models/devices/vacuums.py", line 356, 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 394, 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

Hmm my vacuum is at Firmware 1.6.113 and Plugin 1.15.15 and the command seems to work. Even when I give it a bogus room, it handles it alright. Perhaps it's related to the beta? What firmware and plugin version is that?

This also looks like it's breaking within wyze-sdk/blackboxprotobuf which might make this harder to debug/fix

kevinyc commented 2 years ago

My vacuum firmware is 1.6.173 but my plugin version is 1.15.13. I'll check out the wyze-sdk and see if I can figure out whats changed.

rykermorgan commented 2 years ago

I'm getting the same error when trying to run sweep_rooms. My vacuum firmware is 1.6.127 and plugin version is 1.17.10. I'm using the iOS beta application, I'm not sure if the vacuum firmware is beta. The last firmware listed on Wyze Vacuum release notes is 1.6.113 on 2021-04-19.

I get two error outputs in the logs. Here's the first:

This error originated from a custom integration.

Logger: homeassistant.helpers.script.websocket_api_script
Source: custom_components/simple_wyze_vac/vacuum.py:214
Integration: Simple Wyze Vacuum (documentation)
First occurred: 12:45:09 PM (5 occurrences)
Last logged: 12:52:12 PM

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: '5'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 381, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 584, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/vacuum/__init__.py", line 263, in async_send_command
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/simple_wyze_vac/vacuum.py", line 214, 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])
  File "/usr/local/lib/python3.9/site-packages/wyze_sdk/models/devices/vacuums.py", line 356, 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 394, 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'

Here's the second:

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/simple_wyze_vac/vacuum.py:214
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:27:44 PM (14 occurrences)
Last logged: 12:52:12 PM

[548184501792] '5'
[548179392256] '5'
[548162089840] '5'
[548179392256] Error handling message: Unknown error
[548423419360] Error handling message: Unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 273, in service_handler
    await script_entity.async_turn_on(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 377, in async_turn_on
    await coro
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 403, in _async_run
    return await self.script.async_run(script_vars, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1260, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 363, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 381, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 584, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/vacuum/__init__.py", line 263, in async_send_command
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/simple_wyze_vac/vacuum.py", line 214, 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])
  File "/usr/local/lib/python3.9/site-packages/wyze_sdk/models/devices/vacuums.py", line 356, 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 394, 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

Yeah, this is a bug in wyz_sdk due to the newer (beta) firmware installed in the vacuum. The latest official release is still on 1.6.113 and it seems anything newer than this firmware has this issue with wyze_sdk

I opened an issue for wyze_sdk here - https://github.com/shauntarves/wyze-sdk/issues/63

I think it's related to the map changes they introduced in the beta. The robot_map protobuf definition in 1.6.113 is probably different.

sergeknystautas commented 2 years ago

I'm glad to see we've largely tracked down this problem. I'm on the same beta and was experiencing this. I'd hope after a fix to support multiple rooms, we could also add an attribute to indicate what room the robot thinks it's in.

kennethpangky commented 2 years ago

I'm on firmware 1.6.113, plugin 1.19.15.

The sweep_rooms command works, but it goes to all the wrong rooms. I guess there hasn't been any resolution to this thus far?

romedtino commented 2 years ago

Unfortunately not :(. There hasn't been any changes/progress for this feature.

romedtino commented 2 years ago

For anyone still interested, I have a beta release https://github.com/romedtino/simple-wyze-vac/releases/tag/1.6.5 that should have this custom component working even if you have the newer firmware. The sweep_rooms command will still not work nor will you have the rooms attribute but the rest of the feature set should still be there (start/stop/pause/go home/filter info). Let me know how that goes.

romedtino commented 2 years ago

Merged in https://github.com/romedtino/simple-wyze-vac/releases/tag/1.6.6

shauntarves commented 2 years ago

@romedtino @kennethpangky @kevinyc Is anyone able to test out some fixes for the vacuum mapping? I only now joined the beta program and I don't have the new firmware available to me yet.