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 254 forks source link

vacuum_clean_segment for default(xiaomiMiio) uses vacuum.send_command instead of documented xiaomi_miio.vacuum_clean_segment #717

Open bartowl opened 9 months ago

bartowl commented 9 months ago

Checklist

The problem

Despite Documentation when I load up the card and configure rooms, this is what "copy service call" reports (which of course does not work):

{
  "domain": "vacuum",
  "service": "send_command",
  "serviceData": {
    "command": "app_segment_clean",
    "entity_id": "vacuum.roborock_vacuum_m1s",
    "params": [
      {
        "segments": [
          17
        ],
        "repeat": 1
      }
    ]
  }
}

It should use xiaomi_miio.vacuum_clean_segment and not vacuum.send_command

What version of a card has described problem?

v2.2.2

What was the last working version card?

No response

What vacuum model do you have problems with?

roborock.vacuum.m1s

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

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

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

Edge/Chrome

What version of Home Assistant do you use?

core-2024.2.3

What type of installation are you running?

Home Assistant Container

Card's configuration

type: custom:xiaomi-vacuum-map-card
entity: vacuum.roborock_vacuum_m1s
vacuum_platform: default
map_source:
  camera: camera.xiaomi_cloud_map_extractor
calibration_source:
  camera: true
map_locked: true
map_modes:
  - template: vacuum_clean_segment
    predefined_selections:
      - id: 17
        label:
          text: Room
          x: 31200
          'y': 24000
        outline:
          - - 29150
            - 20350
          - - 32500
            - 20350
          - - 32500
            - 25950
          - - 29150
            - 25950
  - template: vacuum_goto

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

No response

Additional information

No response

bartowl commented 9 months ago

Located the problem here: https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/blob/14bc2aa8b99f89a12a8ffb14c6a948f964e6c032/src/model/generators/platform_templates/xiaomiMiio.json#L16

bartowl commented 9 months ago

expected (working) event would be:

event_type: call_service
data:
  domain: xiaomi_miio
  service: vacuum_clean_segment
  service_data:
    entity_id:
      - vacuum.roborock_vacuum_m1s
    segments:
      - 17

I'm not sure about where to put (and if it will work) the repeat though...

PiotrMachowski commented 9 months ago

This has been done on purpose as a workaround for a bug in HA. Apparently this workaround doesn't work with all vacuums

bartowl commented 9 months ago

Hmm, found the commit https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/commit/a3e9f484f30bbef596e6829d80c5646f4f330a09 Question is - is this issue stil present? If yes, would it be possible to create an alternative profile that does use xiaomi_miio.vacuum_clean_segment? I mean - that's why there are those profiles for (btw great idea to deal with this topic!)

bartowl commented 9 months ago

Ok, managed to write a workaround by not using template but static code, should someone else be interested. Basicaly I needed to replace:

  - template: vacuum_clean_segment
    predefined_selections:
      - id: 17
...

with

  - name: Rooms
    icon: mdi:floor-plan
    run_immediately: false
    coordinates_rounding: true
    coordinates_to_meters_divider: 1000
    selection_type: ROOM
    id_type: number
    max_selections: 999
    repeats_type: REPEAT
    max_repeats: 3
    service_call_schema:
      service: xiaomi_miio.vacuum_clean_segment
      service_data:
        segments: "[[selection]]"
        entity_id: "[[entity_id]]"
    predefined_selections:
      - id: 17
...

This works for me. It is then up to you if what you decide to do with this. With my vacuum vacuum.send_command does not seem to work though.

PiotrMachowski commented 9 months ago

https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/issues/538

PiotrMachowski commented 9 months ago

You can use this workaround instead:

  - template: vacuum_clean_segment
    service_call_schema:
      service: xiaomi_miio.vacuum_clean_segment
      service_data:
        segments: "[[selection]]"
        entity_id: "[[entity_id]]"
    predefined_selections:
      - id: 17
...
bartowl commented 9 months ago

Even better, thanks!

PiotrMachowski commented 9 months ago

https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/issues/294