PiotrMachowski / lovelace-xiaomi-vacuum-map-card

This card provides a user-friendly way to fully control map-based vacuums in Home Assistant. Supported brands include Xiaomi (Roborock/Viomi/Dreame/Roidmi/Valetudo/Valetudo RE), Neato, Wyze, Roomba, Ecovacs (and probably more).
MIT License
1.48k stars 253 forks source link

Roborock s7 + vacuum_platform: send_coomand -> REPEAT ROOM not working (unless using a service call schema) #756

Closed andre00-py closed 2 months ago

andre00-py commented 2 months ago

Checklist

The problem

Robot: Roborock s7

Home Assistant integration for vaccum Official Roborock integration

Vacuum platform in xiaomi vacuum map card send_command

Problem When I try to clean a room, the repeat function doesn't work (it always cleans the room only 1 time, even if I select 2 or 3 times in the UI), unless I manually configure a service call schema.

Manual solution I've tried developer tools, in order to see how to call a service that repeats a room. I've figured out that this is the correct code with my configuration:

data:
  command: app_segment_clean
  params:
    - segments:
        - 16
      repeat: 2
target:
  entity_id: vacuum.roborock_s7
action: vacuum.send_command

So I've added to my xiaomi vacuum map card the following service call schema: map_modes:

  - template: vacuum_clean_segment
    repeats_type: EXTERNAL
    max_repeats: 3
    service_call_schema:
      service: vacuum.send_command
      service_data:
        command: app_segment_clean
        params:
          - segments: '[[selection]]'
            repeat: '[[repeats]]'
      target:
        entity_id: '[[entity_id]]'
    predefined_selections:
      - id: 16

Optimal solution It would be awesome it the repeat function could work without the need to manually configure a service call schema (but it's a little bug; I've already figured out a solution that works for me)

My whole card configuration:

SCR-20240829-kddo
type: custom:xiaomi-vacuum-map-card
entity: vacuum.roborock_s7
vacuum_platform: send_command
map_source:
  camera: image.roborock_s7_levanto
  crop:
    top: 40
    bottom: 40
    left: 40
    right: 40
calibration_source:
  calibration_points:
    - vacuum:
        x: 25500
        'y': 25500
      map:
        x: 238
        'y': 103
    - vacuum:
        x: 21000
        'y': 26000
      map:
        x: 152
        'y': 93
    - vacuum:
        x: 24500
        'y': 16000
      map:
        x: 220
        'y': 294
map_modes:
  - template: vacuum_clean_segment
    repeats_type: EXTERNAL
    max_repeats: 3
    service_call_schema:
      service: vacuum.send_command
      service_data:
        command: app_segment_clean
        params:
          - segments: '[[selection]]'
            repeat: '[[repeats]]'
      target:
        entity_id: '[[entity_id]]'
    predefined_selections:
      - id: 16
        outline:
          - - 23850
            - 14600
          - - 25200
            - 14600
          - - 25200
            - 19900
          - - 26500
            - 19900
          - - 26500
            - 21700
          - - 23850
            - 21700
        label:
          text: corridoio 1
          x: 25200
          'y': 20700
          offset_y: 30
        icon:
          name: mdi:walk
          x: 25200
          'y': 20700
      - id: 17
        outline:
          - - 18500
            - 17800
          - - 23850
            - 17800
          - - 23850
            - 21700
          - - 23850
            - 21700
          - - 26500
            - 21700
          - - 26500
            - 26700
          - - 18500
            - 26700
        label:
          text: soggiorno
          x: 21500
          'y': 24000
          offset_y: 30
        icon:
          name: mdi:sofa
          x: 21500
          'y': 24000
      - id: 18
        outline:
          - - 18500
            - 15200
          - - 23850
            - 15200
          - - 23850
            - 17800
          - - 18500
            - 17800
        label:
          text: cucina
          x: 19900
          'y': 16600
          offset_x: 42
        icon:
          name: mdi:silverware-fork-knife
          x: 19900
          'y': 16600
      - id: 19
        outline:
          - - 18300
            - 7700
          - - 22500
            - 7700
          - - 22500
            - 10800
          - - 23760
            - 10800
          - - 23760
            - 12100
          - - 18300
            - 12100
        label:
          text: camera 1
          x: 20400
          'y': 10500
          offset_y: 30
        icon:
          name: mdi:bed
          x: 20400
          'y': 10500
      - id: 20
        outline:
          - - 29350
            - 7400
          - - 33100
            - 7400
          - - 33100
            - 11200
          - - 29350
            - 11200
        label:
          text: camera 4
          x: 31300
          'y': 9500
          offset_y: 30
        icon:
          name: mdi:bed
          x: 31300
          'y': 9500
      - id: 21
        outline:
          - - 23760
            - 10800
          - - 26000
            - 10800
          - - 26000
            - 11200
          - - 30950
            - 11200
          - - 30950
            - 12590
          - - 25130
            - 12590
          - - 25130
            - 14600
          - - 23760
            - 14600
        label:
          text: corridoio 2
          x: 25000
          'y': 11900
          offset_x: 55
        icon:
          name: mdi:walk
          x: 25000
          'y': 11900
      - id: 22
        outline:
          - - 30950
            - 11200
          - - 33100
            - 11200
          - - 33100
            - 12590
          - - 30950
            - 12590
        label:
          text: sgabuzzino
          x: 32000
          'y': 11900
          offset_y: -30
        icon:
          name: mdi:washing-machine
          x: 32000
          'y': 11900
      - id: 23
        outline:
          - - 22500
            - 7700
          - - 26000
            - 7700
          - - 26000
            - 10800
          - - 22500
            - 10800
        label:
          text: camera 2
          x: 24000
          'y': 9800
          offset_y: 30
        icon:
          name: mdi:bed
          x: 24000
          'y': 9800
      - id: 24
        outline:
          - - 26000
            - 7400
          - - 29350
            - 7400
          - - 29350
            - 11200
          - - 26000
            - 11200
        label:
          text: camera 3
          x: 27700
          'y': 9800
          offset_y: 30
        icon:
          name: mdi:bed
          x: 27700
          'y': 9800
      - id: 25
        outline:
          - - 18300
            - 12100
          - - 23760
            - 12100
          - - 23760
            - 14500
          - - 18300
            - 14500
        label:
          text: bagno 1
          x: 19900
          'y': 13280
          offset_x: 46
        icon:
          name: mdi:shower
          x: 19900
          'y': 13280
      - id: 26
        outline:
          - - 25130
            - 12590
          - - 27500
            - 12590
          - - 27500
            - 14400
          - - 25130
            - 14400
        label:
          text: bagno 2
          x: 26100
          'y': 13500
          offset_y: -30
        icon:
          name: mdi:shower
          x: 26100
          'y': 13500
  - template: vacuum_goto
  - template: vacuum_clean_zone
language: it
append_icons: true
icons:
  - type: menu
    menu_id: quantità acqua
    icon_id: quantità acqua
    entity: select.roborock_s7_quantita_acqua
    available_values_attribute: options
    icon: mdi:water
    icon_mapping:
      'off': mdi:water-remove
      mild: mdi:water-minus
      moderate: mdi:water
      intense: mdi:water-plus
      custom: mdi:water-sync
    tap_action:
      action: call-service
      service: select.select_option
      service_data:
        option: '[[value]]'
        entity_id: '[[entity_id]]'
tiles:
  - entity: vacuum.roborock_s7
    label: Stato
  - entity: sensor.roborock_s7_batteria
    label: Batteria
    icon: mdi:battery-charging
  - entity: vacuum.roborock_s7
    attribute: fan_speed
    label: Aspirazione
    icon: mdi:fan
  - entity: select.roborock_s7_quantita_acqua
    label: Acqua
  - entity: number.roborock_s7_volume
    label: Volume
    icon: mdi:volume-high
  - entity: binary_sensor.roborock_s7_contenitore_dell_acqua_collegato
    label: Serbatoio acqua
    icon: mdi:cup-water
  - entity: binary_sensor.roborock_s7_panno_attaccato
    label: Panno
    icon: mdi:square-rounded
  - entity: sensor.roborock_s7_errore_aspirapolvere
    label: Errori
    icon: mdi:alert
  - entity: sensor.roborock_s7_tempo_residuo_del_sensore
    label: Tempo residuo sensori
    icon: mdi:eye-circle
  - entity: sensor.roborock_s7_tempo_residuo_della_spazzola_laterale
    label: Tempo residuo spazzola laterale
    icon: mdi:dots-circle
  - entity: sensor.roborock_s7_tempo_residuo_della_spazzola_principale
    label: Tempo residuo spazzola principale
    icon: mdi:vacuum
  - entity: sensor.roborock_s7_tempo_di_filtraggio_rimanente
    label: Tempo residuo filtro
    icon: mdi:air-filter
  - entity: sensor.roborock_s7_area_di_pulizia_totale
    label: Tot area pulita
    icon: mdi:texture-box
  - entity: sensor.roborock_s7_tempo_totale_di_pulizia
    label: Tot tempo pulizia
    icon: mdi:clock
card_mod:
  style: |
    ha-card {
      --map-card-room-label-color: white
    }

Greetings Thank you very much @PiotrMachowski for your awesome work! :)

What version of a card has described problem?

v2.2.4

What was the last working version card?

never used this card before

What vacuum model do you have problems with?

vacuum.roborock_s7

Which integration do you use to control your vacuum (link)?

https://www.home-assistant.io/integrations/vacuum/

What browser (browsers/apps) does have this problem?

Safari / IOS app

What version of Home Assistant do you use?

2024.8.3

What type of installation are you running?

Home Assistant OS

Card's configuration

type: custom:xiaomi-vacuum-map-card
entity: vacuum.roborock_s7
vacuum_platform: send_command
map_source:
  camera: image.roborock_s7_levanto
  crop:
    top: 40
    bottom: 40
    left: 40
    right: 40
calibration_source:
  calibration_points:
    - vacuum:
        x: 25500
        'y': 25500
      map:
        x: 238
        'y': 103
    - vacuum:
        x: 21000
        'y': 26000
      map:
        x: 152
        'y': 93
    - vacuum:
        x: 24500
        'y': 16000
      map:
        x: 220
        'y': 294
map_modes:
  - template: vacuum_clean_segment
    repeats_type: EXTERNAL
    max_repeats: 3
    service_call_schema:
      service: vacuum.send_command
      service_data:
        command: app_segment_clean
        params:
          - segments: '[[selection]]'
            repeat: '[[repeats]]'
      target:
        entity_id: '[[entity_id]]'
    predefined_selections:
      - id: 16
        outline:
          - - 23850
            - 14600
          - - 25200
            - 14600
          - - 25200
            - 19900
          - - 26500
            - 19900
          - - 26500
            - 21700
          - - 23850
            - 21700
        label:
          text: corridoio 1
          x: 25200
          'y': 20700
          offset_y: 30
        icon:
          name: mdi:walk
          x: 25200
          'y': 20700
      - id: 17
        outline:
          - - 18500
            - 17800
          - - 23850
            - 17800
          - - 23850
            - 21700
          - - 23850
            - 21700
          - - 26500
            - 21700
          - - 26500
            - 26700
          - - 18500
            - 26700
        label:
          text: soggiorno
          x: 21500
          'y': 24000
          offset_y: 30
        icon:
          name: mdi:sofa
          x: 21500
          'y': 24000
      - id: 18
        outline:
          - - 18500
            - 15200
          - - 23850
            - 15200
          - - 23850
            - 17800
          - - 18500
            - 17800
        label:
          text: cucina
          x: 19900
          'y': 16600
          offset_x: 42
        icon:
          name: mdi:silverware-fork-knife
          x: 19900
          'y': 16600
      - id: 19
        outline:
          - - 18300
            - 7700
          - - 22500
            - 7700
          - - 22500
            - 10800
          - - 23760
            - 10800
          - - 23760
            - 12100
          - - 18300
            - 12100
        label:
          text: camera 1
          x: 20400
          'y': 10500
          offset_y: 30
        icon:
          name: mdi:bed
          x: 20400
          'y': 10500
      - id: 20
        outline:
          - - 29350
            - 7400
          - - 33100
            - 7400
          - - 33100
            - 11200
          - - 29350
            - 11200
        label:
          text: camera 4
          x: 31300
          'y': 9500
          offset_y: 30
        icon:
          name: mdi:bed
          x: 31300
          'y': 9500
      - id: 21
        outline:
          - - 23760
            - 10800
          - - 26000
            - 10800
          - - 26000
            - 11200
          - - 30950
            - 11200
          - - 30950
            - 12590
          - - 25130
            - 12590
          - - 25130
            - 14600
          - - 23760
            - 14600
        label:
          text: corridoio 2
          x: 25000
          'y': 11900
          offset_x: 55
        icon:
          name: mdi:walk
          x: 25000
          'y': 11900
      - id: 22
        outline:
          - - 30950
            - 11200
          - - 33100
            - 11200
          - - 33100
            - 12590
          - - 30950
            - 12590
        label:
          text: sgabuzzino
          x: 32000
          'y': 11900
          offset_y: -30
        icon:
          name: mdi:washing-machine
          x: 32000
          'y': 11900
      - id: 23
        outline:
          - - 22500
            - 7700
          - - 26000
            - 7700
          - - 26000
            - 10800
          - - 22500
            - 10800
        label:
          text: camera 2
          x: 24000
          'y': 9800
          offset_y: 30
        icon:
          name: mdi:bed
          x: 24000
          'y': 9800
      - id: 24
        outline:
          - - 26000
            - 7400
          - - 29350
            - 7400
          - - 29350
            - 11200
          - - 26000
            - 11200
        label:
          text: camera 3
          x: 27700
          'y': 9800
          offset_y: 30
        icon:
          name: mdi:bed
          x: 27700
          'y': 9800
      - id: 25
        outline:
          - - 18300
            - 12100
          - - 23760
            - 12100
          - - 23760
            - 14500
          - - 18300
            - 14500
        label:
          text: bagno 1
          x: 19900
          'y': 13280
          offset_x: 46
        icon:
          name: mdi:shower
          x: 19900
          'y': 13280
      - id: 26
        outline:
          - - 25130
            - 12590
          - - 27500
            - 12590
          - - 27500
            - 14400
          - - 25130
            - 14400
        label:
          text: bagno 2
          x: 26100
          'y': 13500
          offset_y: -30
        icon:
          name: mdi:shower
          x: 26100
          'y': 13500
  - template: vacuum_goto
  - template: vacuum_clean_zone
language: it
append_icons: true
icons:
  - type: menu
    menu_id: quantità acqua
    icon_id: quantità acqua
    entity: select.roborock_s7_quantita_acqua
    available_values_attribute: options
    icon: mdi:water
    icon_mapping:
      'off': mdi:water-remove
      mild: mdi:water-minus
      moderate: mdi:water
      intense: mdi:water-plus
      custom: mdi:water-sync
    tap_action:
      action: call-service
      service: select.select_option
      service_data:
        option: '[[value]]'
        entity_id: '[[entity_id]]'
tiles:
  - entity: vacuum.roborock_s7
    label: Stato
  - entity: sensor.roborock_s7_batteria
    label: Batteria
    icon: mdi:battery-charging
  - entity: vacuum.roborock_s7
    attribute: fan_speed
    label: Aspirazione
    icon: mdi:fan
  - entity: select.roborock_s7_quantita_acqua
    label: Acqua
  - entity: number.roborock_s7_volume
    label: Volume
    icon: mdi:volume-high
  - entity: binary_sensor.roborock_s7_contenitore_dell_acqua_collegato
    label: Serbatoio acqua
    icon: mdi:cup-water
  - entity: binary_sensor.roborock_s7_panno_attaccato
    label: Panno
    icon: mdi:square-rounded
  - entity: sensor.roborock_s7_errore_aspirapolvere
    label: Errori
    icon: mdi:alert
  - entity: sensor.roborock_s7_tempo_residuo_del_sensore
    label: Tempo residuo sensori
    icon: mdi:eye-circle
  - entity: sensor.roborock_s7_tempo_residuo_della_spazzola_laterale
    label: Tempo residuo spazzola laterale
    icon: mdi:dots-circle
  - entity: sensor.roborock_s7_tempo_residuo_della_spazzola_principale
    label: Tempo residuo spazzola principale
    icon: mdi:vacuum
  - entity: sensor.roborock_s7_tempo_di_filtraggio_rimanente
    label: Tempo residuo filtro
    icon: mdi:air-filter
  - entity: sensor.roborock_s7_area_di_pulizia_totale
    label: Tot area pulita
    icon: mdi:texture-box
  - entity: sensor.roborock_s7_tempo_totale_di_pulizia
    label: Tot tempo pulizia
    icon: mdi:clock
card_mod:
  style: |
    ha-card {
      --map-card-room-label-color: white
    }

Javascript errors shown in the browser's console (if applicable)

No response

Additional information

No response

PiotrMachowski commented 2 months ago

send_command platform was not meant to work with Roborock integration. Your manual config should be included in the final version of dedicated config for Roborock integration.

At this moment it is included in #691