Valetudo Vacuums Map Camera for Home Assistant

@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