sca075 / mqtt_vacuum_camera

Camera Integration for Home Assistant to export and render all Vacuums connected via MQTT( including Valetudo Hypfer and RE(rand256)) Maps.
Apache License 2.0
102 stars 5 forks source link

Camera does not Work with Rand256 : ValueError: not enough values to unpack (expected 2, got 0) #227

Closed Minims closed 2 months ago

Minims commented 3 months ago

Checklist

The problem

I have the error ValueError: not enough values to unpack (expected 2, got 0) while loading the camera integration.

What version of an integration has described problem?

2024.07.4

What was the last working version of an integration?

unknown (first Use)

What vacuum model do you have problems with?

Roborock.S5

Please firmware installed on your Vacuum.

Valetudo RE 0.10.10 + 3.5.8_002034

What type of platform you use?

ARM (Raspberry Pi, Odroid, etc.) > 4GB

What version of Home Assistant do you use?

core-2024.7.4

What type of installation are you running?

Home Assistant Supervised

Logs or Errors shown in the HA snapshots (please enable the Debug Mode) text will be auto formatted to code.

2024-08-04 15:36:55.339 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.roger_camera fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1296, in async_device_update
    await self.async_update()
  File "/config/custom_components/mqtt_vacuum_camera/camera.py", line 426, in async_update
    pil_img = await self.hass.async_create_task(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/camera_processing.py", line 193, in run_async_process_valetudo_data
    images = await gather(*tasks)
             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/camera_processing.py", line 167, in process_valetudo_data
    result = loop.run_until_complete(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/camera_processing.py", line 125, in async_process_rand256_data
    ) = await self._re_handler.get_rooms_attributes(destinations)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/valetudo/rand256/image_handler.py", line 576, in get_rooms_attributes
    self.room_propriety = self.extract_room_properties(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/valetudo/rand256/image_handler.py", line 190, in extract_room_properties
    dummy_segments, outlines = ImageData.get_rrm_segments(
    ^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 0)


### Function, that in your opinion is creating the issue.

None

### Additional information

<img width="1210" alt="Roborock S5" src="https://github.com/user-attachments/assets/02d14862-10b8-4353-aebc-820fc3182ebe">
sca075 commented 3 months ago

@Minims I will try to fix it in the next release, I think to know where is the problem. Can you please downgrade it for the time be. I will change the firmware of my S5 later today to test the Camera with Rand256. It was in plan to do it... but anyhow thanks, this is really appreciated.

Minims commented 3 months ago

Ok, Thx. What do i need to downgrade ? The addon MQTT Camera ? Valetudo RE ? Roborock Firmware ?

sca075 commented 3 months ago

Ok, Thx. What do i need to downgrade ? The addon MQTT Camera ? Valetudo RE ? Roborock Firmware ?

The Camera should be okay with 2024.07.2

Minims commented 3 months ago

I have rollback to 2024.07.2, .1 and .0

the error is now

2024-08-04 16:19:34.198 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.roger_camera fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1296, in async_device_update
    await self.async_update()
  File "/config/custom_components/mqtt_vacuum_camera/camera.py", line 423, in async_update
    pil_img = await self.hass.async_create_task(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/camera_processing.py", line 192, in run_async_process_valetudo_data
    images = await gather(*tasks)
             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/camera_processing.py", line 166, in process_valetudo_data
    result = loop.run_until_complete(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/camera_processing.py", line 124, in async_process_rand256_data
    ) = await self._re_handler.get_rooms_attributes(destinations)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/valetudo/rand256/image_handler.py", line 576, in get_rooms_attributes
    self.room_propriety = self.extract_room_properties(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/valetudo/rand256/image_handler.py", line 190, in extract_room_properties
    dummy_segments, outlines = ImageData.get_rrm_segments(
    ^^^^^^^^^^^^^^^^^^^^^^^^
sca075 commented 3 months ago

Okay then 2024.06.x or just please wait for a couple of hours, I will fix this and let you know ;)

sca075 commented 3 months ago

@Minims I'm right now flashing the robot with Rand256 and will start to work in order to fix this as soon the robot is ready to work with it. Thanks for your kind understanding.

sca075 commented 3 months ago

@Minims Okay finally I got the robot connected with Rand256. It can take a little longer than expected but I think to know where is the problem. Will update as soon :)

sca075 commented 2 months ago

@Minims problem found and fixed, just few adjustments to do and I will release a beta 2024.08.0b3. I will remove the limitation of pillow requirements so that you can run it on the 2024.7.4 of HA and check if all works as expected.

Once again thanks for highlighting this issue.

sca075 commented 2 months ago

@Minims 2024.08.0b3 was published just few minutes ago, the PR closed automatically the issue, if there is the need, please fill free to re-open it again or just comment in here. There are still quite some change to do on the Rand side, but for instance now the camera will boot as it should ;) The issue was on the Async addressing of a routine that was called several time. The current implementation is just a work around, will think about a more elegant way to fix this :)

Minims commented 2 months ago

I have just install the 2024.08.0b3 version, but i still have something similar. How can i help to debug. this ?

2024-08-05 17:34:43.910 WARNING (roborock-s5_camera_0) [custom_components.mqtt_vacuum_camera.valetudo.rand256.image_handler] roborock-s5 : Error in get_image_from_json: not enough values to unpack (expected 2, got 0)
Traceback (most recent call last):
  File "/config/custom_components/mqtt_vacuum_camera/valetudo/rand256/image_handler.py", line 380, in get_image_from_rrm
    self.segment_data, self.outlines = await self.data.async_get_rrm_segments(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 0)
sca075 commented 2 months ago

Give me a second.. I will check it.. strange although..

sca075 commented 2 months ago

@Minims, i think you have experience with Python, don't you? in the /utils/image_data.py lines 494 to 500

        # if count_seg > 0:
        #     if out_lines:
        #         return segments, outlines
        #     else:
        #         return segments
        # else:
        return segments, outlines

Would you please comment the checks and just return the values (there should be a flag set to true actually but I wanna confirm also the counter).

EDIT: I mean in this moment the function should return both values independently, so if it work will remove those lines.

Minims commented 2 months ago
2024-08-05 18:57:52.519 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.roger_camera fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1296, in async_device_update
    await self.async_update()
  File "/config/custom_components/mqtt_vacuum_camera/camera.py", line 432, in async_update
    pil_img = await self.hass.async_create_task(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/camera_processing.py", line 193, in run_async_process_valetudo_data
    images = await gather(*tasks)
             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/camera_processing.py", line 167, in process_valetudo_data
    result = loop.run_until_complete(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/camera_processing.py", line 121, in async_process_rand256_data
    (
TypeError: cannot unpack non-iterable NoneType object

How can I add some logs that will be output in homeassistant.log

sca075 commented 2 months ago

Off course but is strange on the OS in the PI4 it working and I have 3 Cameras active. The only difference is that I'm running the beta 3 of HA 2024.8.0. if you check the logs adding the segments there should be a lot of data (those are the raw decoded data from the vacuum). The connector.py will grab the payload and unzip it, then the raw data are converted in json, the json is then worked somehow to get the segments.. and then the handler (that I'm working to improve) will get and draw from the json the image. I could reproduce the issue you reported at the beginning that the b2 should still have, the b3 normally should work. Let me know how I can help too :) in any case.. we will solve it, it is math in the end ;)

Screenshot 2024-08-05 at 19 12 23

Minims commented 2 months ago

So I have add some logs :

2024-08-05 19:15:22.781 WARNING (roborock-s5_camera_0) [custom_components.mqtt_vacuum_camera.utils.img_data] seg_data:{'count': 1, 'id': []}, seg_ids:[]

need to go a bit deeper why there is no data here.

sca075 commented 2 months ago

mmm got it, the vacuum has no segments.. did you activate the setting to retain the maps in the vacuum?

sca075 commented 2 months ago
{"spots":[],"zones":[],"rooms":[{"name":"#16","id":16},{"name":"#17","id":17},{"name":"#18","id":18},{"name":"#2","id":2}],"updated":1722875888833}
sca075 commented 2 months ago

The above is the payload that generate the segments = destinations, when the camera start we request this data.. there should be in the logs something similar to what above from MQTT. can you please confirm?

Minims commented 2 months ago

Ok so I have ask to Valetudo to split the map in segments. I had run my first cleaning, but map was not splitted at the end of the cleaning. Once split is done, the camera works !!

Thanks !!

sca075 commented 2 months ago

In the other hand you made a great catch.. when I run the vacuum the first time there was already two segments this is why I didn't got it before, thanks to you @Minims

Minims commented 2 months ago

Thank you too for availability and your work. Hope this will help new comers too. I only use Valetudo since few days.