Valetudo Vacuums Map Camera for Home Assistant

I added large googly-eyes and moustache stickers to my two, but I have not named them.

Good news, no binary mqtt message warnings!

1 Like

Super :slight_smile: then we solved the problem :face_with_peeking_eye: in the end it was the decoding of the payload as I wrote earlier. So just few new adjustments and when Home Assistant 2024.8.0 come out and we can test the Camera with the beta releases we should be able to release the 2024.08.0. As there are issues for the guys using one vacuum on multi floors (using maploader) I will add an option to create the pre-loaded trims file or not, this means old way reload (warning can occur) or new stile with pre-loaded trims (no warnings) will be selectable.
Edit: I would need also to re-flash the S5 with Rand256 to make sure that also this firmware works this is also why this will take time :wink:

1 Like

The version 2024.08.0 of the Camera will be fully packed and include the ā€œreset_trimsā€ service as well a Camera ā€œreloadā€ Service. It also fixes from the tests done the binary data conversion issues faced in the new versions of Home Assistant (due to an update miss interpretation from my side of the new decoding specs of MQTT).
As per there was several changes in the last month, and I couldnā€™t honestly fully test the Rand256, the robot just now booted with Rand and hopefully 2024.08.0 will also correct the issues that are facing up since the 2024.07.x versions of the Camera.

Note that to beta test the Camera your Home Assistant should be min. 2024.8.0b0.

2 Likes

Screenshot 2024-08-03 at 10.43.04

This are new ā€œActionsā€ that are now available with the version 2024.08.0 of our Camera. The reset_trims action is the one that will automatically reset the images trims (when you for example reset/change the vacuums maps) and reload the Camera automatically.

We got also Rand256 to work again, and once again sorry for taking so long :wink:

Pillow dependencies are right now a little on the large, but this give the possibility to the users that will not update HA to still run our updates. The aim is to keep it woking and improving it not forcing anyone in the endā€¦ ā€œnever touch a running systemā€ is the role one :slight_smile:

No more binary Warning / conversions errors from MQTT with this new version.

Thank-you very much for making this integration.

I have a query on the ā€œactionā€/service for resetting image trims - will this carry-out/run the same task as the ā€œReset Map Trimsā€ option under the advanced options?

The reason I ask is because Iā€™m using the valetudo map-loader (GitHub - pkoehlers/maploader: Map loader for Dreame robot vacuums running Valetudo) addon to switch valetudo maps so that I can move the robot from one floor to another in my home. When I reload the vacuum camera, the vacuum map is trimmed/clipped and only part of it shows. If I use the ā€œReset Map Trimsā€ option, this fixes it. So, it would be great to have that available as a service/ā€œactionā€ if thatā€™s possible

@FireCheetah you are really welcome, yes in theory it should do the same. There is although some issue right now ā†’ it looks it isnā€™t working as expected. I will do my best to make it fully functional on the 2024.08.1 next week. There is a discussion on the Camera GitHub page that can give you more details of it.

reset_trims ā€œActionā€ is design to do the same operations required for ā€œReset Map Trimsā€ including reload the camera. In the case you use only one vacuum this should work. Mainly I noticed that sometimes the reload fails, but as I stated above I will make sure it woks in full by next week.

@FireCheetah I just released the version 2024.08.1 that fixes a couple of thinks on the ā€œActionsā€.
With this version the ā€œspecificationsā€ for the Actions are now fixed.

  • Action ā€œreloadā€ = All MQTT Vacuum Cameras are reload no need to specify witch one.
  • Action ā€œreset-trimsā€ All auto_crop*.json will be deleted from the storage folder, also here no need to specify the camera. This ā€œActionā€ will invoke the reload one while executing (no need to reload the camera afterword).
    So to invoke the action reset_trims:
action: mqtt_vacuum_camera.reset_trims
data: {}

Those changes ensures that when needed also using map-loader is possible to configure a script to manage those scenarios, and the Camera should render the maps correctly.

Another point, is that the auto_crop data will be written only when the vacuum is ā€œdockedā€.

For those that didnā€™t yet update the camera the version compatible with Home Assistant 2024.8.x is >= 2024.08.0. If you are running the Camera version 2024.06.3 or earlier, please do not hesitate to let me know, but in generalā€¦

  1. Update the Camera to 2024.06.4.
  2. Follow the instruction for the migration process.
  3. Update HACS repository of this integration to MQTT_Vacuum_Camera
  4. Update the MQTT Vacuum Camera to at least 2024.08.0

If you do not want to use / canā€™t use the 2024.06.4 to migrateā€¦ some other users had just updated the HACS url for the repository and manually setup the Camera, you off course would need to remove the Valetudo_Vacuum_Camera once you are done (this is automatically done with the 2024.06.4 migration procedure).

@gsca075 Thanks for the update - the reset-trims action is working perfectly :+1:.

Iā€™ve included below my scripts for running maploader and the reset-trims actions in case it helps anyone, although theyā€™re quite simple - I included a 20 second pause between both steps as that seems to be enough time for maploader to finish and for the map files on the robot to be updated.

Main / Ground floor script [ID = main]:

alias: Robot Vacuum Cleaner - Main
sequence:
  - if:
      - condition: state
        entity_id: vacuum.valetudo_homecleanrobot
        state: docked
    then:
      - action: select.select_option
        target:
          entity_id: select.valetudo_homecleanrobot_maploader_map
        data:
          option: main
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - action: mqtt_vacuum_camera.reset_trims
        data: {}
description: ""
icon: mdi:robot-vacuum

First floor / upstairs floor script [ID = first_floor]:

alias: Robot Vacuum Cleaner - First Floor
sequence:
  - if:
      - condition: state
        entity_id: vacuum.valetudo_homecleanrobot
        state: docked
    then:
      - action: select.select_option
        target:
          entity_id: select.valetudo_homecleanrobot_maploader_map
        data:
          option: first_floor
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - action: mqtt_vacuum_camera.reset_trims
        data: {}
description: ""
icon: mdi:robot-vacuum

Then for the Xiaomi Vacuum Interactive Map Card Iā€™m using the following code twice with a different segments and the card visibility settings depending on the maploader floor status. I included a menu selection (menu_id: House Floor Map) to switch between each floor map.

type: custom:xiaomi-vacuum-map-card
map_source:
  camera: camera.robot_vacuum_cleaner_camera
calibration_source:
  camera: true
internal_variables:
  topic: valetudo/homecleanrobot
entity: vacuum.valetudo_homecleanrobot
vacuum_platform: Hypfer/Valetudo
card_mod:
  style: |
    ha-card {
      --map-card-room-outline-line-width: 0px;
    }
map_modes:
  - template: vacuum_clean_segment
    predefined_selections:
      - id: '1'
        icon:
          name: mdi:countertop
          x: 3575
          'y': 3170
        label:
          text: Kitchen & Dining Room
          x: 3575
          'y': 3170
          offset_y: 30
        outline:
          - - 3200
            - 3005
          - - 3950
            - 3005
          - - 3950
            - 3385
          - - 3200
            - 3385
      - id: '2'
        icon:
          name: mdi:paper-roll
          x: 3897
          'y': 3463
        label:
          text: Bathroom
          x: 3897
          'y': 3463
          offset_y: 30
        outline:
          - - 3795
            - 3430
          - - 4000
            - 3430
          - - 4000
            - 3550
          - - 3795
            - 3550
      - id: '3'
        icon:
          name: mdi:chair-rolling
          x: 3890
          'y': 3645
        label:
          text: Study
          x: 3890
          'y': 3645
          offset_y: 30
        outline:
          - - 3800
            - 3550
          - - 4000
            - 3550
          - - 4000
            - 3820
          - - 3800
            - 3820
      - id: '4'
        icon:
          name: mdi:stairs-down
          x: 3652
          'y': 3712
        label:
          text: Hallway
          x: 3652
          'y': 3712
          offset_y: 30
        outline:
          - - 3585
            - 3365
          - - 3800
            - 3365
          - - 3800
            - 3840
          - - 3585
            - 3840
      - id: '5'
        icon:
          name: mdi:sofa
          x: 3362
          'y': 3595
        label:
          text: Living Room
          x: 3362
          'y': 3595
          offset_y: 30
        outline:
          - - 3200
            - 3325
          - - 3585
            - 3325
          - - 3585
            - 3865
          - - 3200
            - 3865
  - template: vacuum_clean_zone
  - template: vacuum_goto
map_locked: false
append_tiles: true
tiles:
  - entity: sensor.valetudo_homecleanrobot_maploader_status
    label: Map Load Status
    icon: mdi:map-legend
append_icons: true
icons:
  - type: menu
    menu_id: Water_Amount
    tooltip: Water Amount
    entity: select.valetudo_homecleanrobot_water
    available_values_attribute: options
    icon: mdi:water
    icon_mapping:
      low: mdi:water-outline
      medium: mdi:water-opacity
      high: mdi:water
    tap_action:
      action: call-service
      service: select.select_option
      service_data:
        option: '[[value]]'
        entity_id: '[[entity_id]]'
  - type: menu
    menu_id: Robot Mode
    tooltip: Robot Mode
    entity: select.valetudo_homecleanrobot_mode
    available_values_attribute: options
    icon: mdi:robot-vacuum
    icon_mapping:
      mop: mdi:waves
      vacuum: mdi:fan-chevron-up
      vacuum_and_mop: mdi:hydro-power
    tap_action:
      action: call-service
      service: select.select_option
      service_data:
        option: '[[value]]'
        entity_id: '[[entity_id]]'
  - type: menu
    menu_id: House Floor Map
    tooltip: House Floor Map
    entity: select.valetudo_homecleanrobot_maploader_map
    available_values_attribute: options
    icon: mdi:home-floor-0
    icon_mapping:
      main: mdi:home-floor-0
      first_floor: mdi:home-floor-1
    tap_action:
      action: call-service
      service: script.turn_on
      service_data:
        entity_id: script.robot_vacuum_cleaner_[[value]]
visibility:
  - condition: or
    conditions:
      - condition: state
        entity: select.valetudo_homecleanrobot_maploader_map
        state: main
      - condition: state
        entity: select.valetudo_homecleanrobot_maploader_map
        state: unavailable
      - condition: state
        entity: select.valetudo_homecleanrobot_maploader_map
        state: unknown
1 Like

The new 2024.08.2 version of the camera is enabling the Auto Zoom functionality also for Rand256 users.
Did also made a substantial refactor of the rrpaser.py mainly to make it more pythonic (easy to read). Also updated the docs.
With almost 600 download of the previous version, if you appreciate this camera, please star this project on our GitHub Repository if you didnā€™t yet. This would be really appreciated :wink: and also help us to grow up this project.

Improvements and Refactoring

In the quest of improving the code of the Camera the init process and quality of the code was at focus on the 2024.09.0 that was released yesterday.

The camra also improve the compatibility with Home Assistant as per from state idle goes in streaming while rendering the images :wink:

In the next releases Iā€™m planning to detect whenever the maps change or have been reload on the Vacuums.

1 Like

Hi, thank you for your hard work! Reading this thread and your github, I understand the bug Iā€™m hitting is identified. The map doesnā€™t seem to update dynamically (roborock s5, latest valetudo), unless I call the ā€œreloadā€ action. I guess the refactoring mentionned on github is, amongst others, about fixing this? Or should I report it as an issue?

1 Like

Hello @hayvan96,

Yep, in order to load the camera a little faster I had to write down the maps trimsā€¦ this is why in the last versions I introduced the reset_trims action.
I hope to found a solution a little more friendly for it. As well when the maps of the vacuums will change the camera will probably detect it and do this reset_trims automatically (not store them till the vacuum is again docked). What Iā€™m currently working out is although going to be publish on the 2024.10.0 as there will be a lot of changes that are going a little slow due to personal reasons. I opened an issue as per Iā€™m aware of this ā€œinconvenienceā€. Anyhow once the maps are defined in the vacuumā€¦ the camera operate normally, isnā€™t it also in your case? I mean how often you rescan the complete floor? With Rand256 actually is possible to save (with the S5) the maps if you need to change often the maps. I will create on the next version a service that will do this (for the Rand256 vacuums, not clear with the official one is possible).

Thanks in any cases for using this camera, you are really welcome whenever you want or need to open issues, request new features or cooperate actively on this development.

Well our flat has a one step stair in the middle of it, so I have two parts (lower, higher). So saving map is not a option for me,as it should remember two different ā€œfloorsā€ knowing that the charger is only in one of them.

So once the whole area is mapped, itā€™s perfect. But before that, walls donā€™t update, or map doesnā€™t extend progressively to the extensive map, unless of course I call the reload action.

Okay I got itā€¦ so just for curiosity, your S5 is mapping with the Start command correct? thatā€™s just to understand if I can solve this or I need to add an enable / disable the store trim to cover this case :wink:

Yes it starts mapping (every time) when I launch it. Because of these two levels/floors, I havenā€™t enabled Persistent Maps in Valetudo

But when it finish the cycle, if the dock is not on the second levelā€¦ and there are no maps predefinedā€¦ mmmmm how the vacuum stop? Manually? you can build a kind of slide for the vacuum to go up and down from the step :laughing: of course I joke.

Anyhow I think we can work on a solution for this :slight_smile: especially because I donā€™t like it too that the walls are missing and it is necessary to reload constantly. Surely this will be fix on next version, please give me the time to complete it okay?

I repeat with Rand256 you can easily store the floors (Iā€™m not sure if with the official is possible to do it).

On the floor without dock, it returns to where it started, and then complains ā€œcanā€™t return to the dockā€.

Well probably you can use HA to detect when the vacuum is in returning to stop it and send it a precise pointā€¦I mean it looks it is a really particular scenario.

The vacuum has no problem to locate itself and works perfectly like it used to when connected to the Xiaomi cloud. Itā€™s exactly like having two or three floors in an house and one vacuum.The issue is only being able to follow how it is cleaning and if all the floor has been cleaned. I can do it via the Valetudo interface (webserver), not in homeassistant.
I know where I put it where I launch it on the chargerless floor and it will always return to the point, itā€™s fine.
At the beginning, the s5 was not able to save maps so it used to re scan the whole floor every time, even the one where the dock is.