mqtt_vacuum_camera: Obstacle View not working

Checklist

  • I have updated the integration to the latest version available
  • I have checked if the problem is already reported

The problem

Obstacle View not showing any obstacle images, just a “confirmed” popup but actually not doing anything. Using it with the Xiaomi Vacuum Map Card.

What version of an integration has described problem?

v2025.03.0

What was the last working version of an integration?

No response

What vacuum model do you have problems with?

Dreame L40 Ultra

Please firmware installed on your Vacuum.

Valetudo

What type of platform you use?

Intel NUC (or generic x86_64)

What version of Home Assistant do you use?

core-2025.5.2

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.

2025-05-19 18:16:08.563 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Obstacle view for camera.dreame_l40_camera
2025-05-19 18:16:08.563 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Firing event to search and view obstacle at coordinates 3590, 2914
2025-05-19 18:16:08.563 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Received event: mqtt_vacuum_camera_obstacle_coordinates, Data: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3590, 'y': 2914}}
2025-05-19 18:16:08.635 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Restoring the backup image.
2025-05-19 18:16:13.297 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Obstacle view for camera.dreame_l40_camera
2025-05-19 18:16:13.297 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Firing event to search and view obstacle at coordinates 3492, 2765
2025-05-19 18:16:13.297 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Received event: mqtt_vacuum_camera_obstacle_coordinates, Data: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3492, 'y': 2765}}
2025-05-19 18:16:13.323 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Restoring the backup image.
2025-05-19 18:16:15.230 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Obstacle view for camera.dreame_l40_camera
2025-05-19 18:16:15.230 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Firing event to search and view obstacle at coordinates 3397, 2680
2025-05-19 18:16:15.230 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Received event: mqtt_vacuum_camera_obstacle_coordinates, Data: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3397, 'y': 2680}}
2025-05-19 18:16:15.255 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Restoring the backup image.
2025-05-19 18:16:17.631 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Obstacle view for camera.dreame_l40_camera
2025-05-19 18:16:17.631 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Firing event to search and view obstacle at coordinates 3318, 2678
2025-05-19 18:16:17.631 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Received event: mqtt_vacuum_camera_obstacle_coordinates, Data: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3318, 'y': 2678}}
2025-05-19 18:16:17.661 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Restoring the backup image.
2025-05-19 18:16:23.096 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Obstacle view for camera.dreame_l40_camera
2025-05-19 18:16:23.097 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Firing event to search and view obstacle at coordinates 3182, 3560
2025-05-19 18:16:23.097 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Received event: mqtt_vacuum_camera_obstacle_coordinates, Data: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3182, 'y': 3560}}
2025-05-19 18:16:23.122 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Restoring the backup image.
2025-05-19 18:16:30.297 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Obstacle view for camera.dreame_l40_camera
2025-05-19 18:16:30.297 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Firing event to search and view obstacle at coordinates 3903, 3158
2025-05-19 18:16:30.298 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Received event: mqtt_vacuum_camera_obstacle_coordinates, Data: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3903, 'y': 3158}}
2025-05-19 18:16:30.325 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Restoring the backup image.

Function, that in your opinion is creating the issue.

Not sure / none of the above.

Additional information

Here is the card config:

type: custom:xiaomi-vacuum-map-card
map_source:
  camera: camera.dreame_l40_camera
calibration_source:
  camera: true
entity: vacuum.valetudo_dreamel40
vacuum_platform: Hypfer/Valetudo
internal_variables:
  topic: valetudo/DreameL40
icons: []
tiles: []
map_modes:
  - template: vacuum_clean_zone
    max_repeats: 4
  - template: vacuum_goto
  - name: Obstacles View
    icon: mdi:map-marker
    run_immediately: false
    coordinates_rounding: true
    coordinates_to_meters_divider: 100
    selection_type: MANUAL_POINT
    max_selections: 999
    repeats_type: NONE
    max_repeats: 1
    service_call_schema:
      service: mqtt_vacuum_camera.obstacle_view
      service_data:
        coordinates_x: "[[point_x]]"
        coordinates_y: "[[point_y]]"
      target:
        entity_id: camera.dreame_l40_camera
      variables: {}
map_locked: false
two_finger_pan: true

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 25 (15 by maintainers)

Most upvoted comments

The problem with the no json is on the list 😉 but I will also correct the no obstacle found… thanks once again 😃

@MattiaBasso it looks like I used a quite old version of this part of the code thanks again for the data really valuables… I need to sort out the priorities and I guess the 2025.05.0b7 was the best release for this function would you confirm please?

Changing the aspect ratio to 1:1 got me a much smoother experience. Sometimes the obstacles are not loading, don’t understand why. Integration reload is needed. Everything else seems fine to me.

@MattiaBasso please would you confirm the 2025.06.0b0 I hope I didn’t brake anything with the last changes and honestly I didn’t test it… as I need to recode the test mode.

@MattiaBasso I just released the new beta number 7 this should fix the issues you faced. Please give it a test and let me know if anything else happens.

@MattiaBasso glad to know that this worked, I will change the time out on the final version. to summarise:

  • Problem with the aspect ratio -> if not selected will ignore the resize of the image.
  • Problem with the time out -> will double it, it is configured to follow the frame time of the camera.
  • You had to reboot HA to get it working = this would need some additional investigation but, apparently now it works.

I do not have yet a vacuum with this capability this is why I trust on your and others feedbacks to make it work (as shown on the video in the docs).

If you like this work, consider to star the project this helps and is my pleasure to help here.

No log needed, everything is working as expected. Changing the ratio did the trick.

Sometimes I have this error but reloading the integration fixes it:

Traceback (most recent call last):
  File "/config/custom_components/mqtt_vacuum_camera/utils/camera/camera_processing.py", line 292, in download_image
    obstacle_image = await response.read()
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_reqrep.py", line 1218, in read
    self._body = await self.content.read()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 418, in read
    block = await self.readany()
            ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 440, in readany
    await self._wait("readany")
  File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 347, in _wait
    await waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/mqtt_vacuum_camera/camera.py", line 661, in _debounced_obstacle_handler
    await self._obstacle_view_debouncer.async_call()
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 114, in async_call
    await task
  File "/config/custom_components/mqtt_vacuum_camera/camera.py", line 675, in _process_obstacle_event
    await self.handle_obstacle_view(event)
  File "/config/custom_components/mqtt_vacuum_camera/camera.py", line 804, in handle_obstacle_view
    image_data = await asyncio.wait_for(
                 ^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for
    return await fut
           ^^^^^^^^^
  File "/config/custom_components/mqtt_vacuum_camera/utils/camera/camera_processing.py", line 299, in download_image
    except aiohttp.ClientTimeoutError as e:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/__init__.py", line 264, in __getattr__
    raise AttributeError(f"module {__name__} has no attribute {name}")
AttributeError: module aiohttp has no attribute ClientTimeoutError. Did you mean: 'ClientTimeout'?

Anyway Thanks for the effort you put in this project. Awesome work.

@MattiaBasso se hai un momento… so in conclusion, the aspect ratio of your camera looks to be not setup. This it why of this error if you set an aspect ratio should not error anymore can you please confirm/test it under this conditions, try I don’t know 1:1 or 16:9 (this is cool for the most). If this error goes away and we still have no images hostly I think you should try one of the links in the attributes to see if the image open or not.

@MattiaBasso thank you… strange I didn’t got this errors during my tests at line 217 there is maybe to add an await there that I removed because of a lint error…

Tested the 2025.05.0b6 and it did not work 😦 . But there are some new insights:

2025-05-25 16:15:09.454 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Obstacle view for camera.dreame_l40_camera
2025-05-25 16:15:09.454 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Firing event to search and view obstacle at coordinates 3332, 3440
2025-05-25 16:15:09.454 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Processing debounced obstacle event: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3332, 'y': 3440}}
2025-05-25 16:15:09.455 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Executing obstacle view logic for event: mqtt_vacuum_camera_obstacle_coordinates, Data: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3332, 'y': 3440}}
2025-05-25 16:15:09.455 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Current camera mode: CameraModes.MAP_VIEW
2025-05-25 16:15:09.455 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Camera Mode Change to CameraModes.OBSTACLE_SEARCH, Obstacle View Requested
2025-05-25 16:15:09.455 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Finding in the nearest 61 pixels obstacle to coordinates: 3332, 3440
2025-05-25 16:15:09.456 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Nearest obstacle found: {'point': {'x': 3334, 'y': 3441}, 'label': 'Obstacle (83%)', 'link': [redacted]}
2025-05-25 16:15:09.456 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Camera Mode Change to CameraModes.OBSTACLE_DOWNLOAD, Downloading image: [redacted]
2025-05-25 16:15:09.536 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Image downloaded successfully!
2025-05-25 16:15:09.540 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Camera Mode Change to CameraModes.OBSTACLE_VIEW, Image downloaded successfully
2025-05-25 16:15:09.545 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/mqtt_vacuum_camera/camera.py", line 661, in _debounced_obstacle_handler
    await self._obstacle_view_debouncer.async_call()
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 114, in async_call
    await task
  File "/config/custom_components/mqtt_vacuum_camera/camera.py", line 675, in _process_obstacle_event
    await self.handle_obstacle_view(event)
  File "/config/custom_components/mqtt_vacuum_camera/camera.py", line 836, in handle_obstacle_view
    resize_result = await async_resize_image(params=resize_data)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/valetudo_map_parser/config/utils.py", line 487, in async_resize_image
    wsf, hsf = [int(x) for x in params.aspect_ratio.split(",")]
                ~~~^^^
ValueError: invalid literal for int() with base 10: 'None'
2025-05-25 16:15:36.300 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Obstacle view for camera.dreame_l40_camera
2025-05-25 16:15:36.301 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] Firing event to search and view obstacle at coordinates 3243, 3244
2025-05-25 16:15:36.301 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Processing debounced obstacle event: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3243, 'y': 3244}}
2025-05-25 16:15:36.301 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Executing obstacle view logic for event: mqtt_vacuum_camera_obstacle_coordinates, Data: {'entity_id': 'camera.dreame_l40_camera', 'coordinates': {'x': 3243, 'y': 3244}}
2025-05-25 16:15:36.302 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Current camera mode: CameraModes.OBSTACLE_VIEW
2025-05-25 16:15:36.302 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Camera Mode Change to CameraModes.MAP_VIEW, Obstacle View Exit Requested.
2025-05-25 16:15:36.302 DEBUG (MainThread) [custom_components.mqtt_vacuum_camera] dreamel40: Restoring the backup image.

This log is from two obstacle events. I redacted the links to the images.

@MattiaBasso Sorry stil working on this issue but the good news is that probably tomorrow the fix will be available as a beta release. I had to modify some code and I still need to clean it up. I tested it and now it seams working again 😉

@MattiaBasso I found the problem we can fix it 😉 the attributes of the camera wasn’t updated as per I switched to the library the shared data… apparently an easy fix but please wait for the next beta release and let’s test it. Note that this will use the ip of the vacuum and it will work only if the vacuum is in the local network.