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.46k stars 251 forks source link

Add viomise to supported platforms #215

Closed Gooman-rus closed 2 years ago

Gooman-rus commented 2 years ago

Checklist

The problem

I have integrated my Viomi SE (V-RVCLM21A) using this custom integration: https://github.com/marotoweb/home-assistant-vacuum-viomise. Basic commands and attributies work fine: start, stop, battery percent etc.

I have also installed xiaomi cloud map extractor:

camera:
  - platform: xiaomi_cloud_map_extractor
    host: !secret vacuum_host
    token: !secret vacuum_token
    username: !secret vacuum_username
    password: !secret vacuum_password
    draw: ['all']
    attributes:
      - calibration_points    
      - charger
      - map_name

Trying to use xiaomi-vacuum-map-card. The map displays fine. I can also start, stop, change cleaning mode from the card. But I can't start zone cleaning or point cleaning. Also zone dimensions are always equals zero: empty_dimensions

When I click start button near the zone creation button I can see "Success" notification but vacuum does not start cleaning. Also in homeassistant logs I can see this error:

Logger: custom_components.viomise.vacuum
Source: custom_components/viomise/vacuum.py:308
Integration: viomise (documentation, issues)
First occurred: 16:21:52 (7 occurrences)
Last logged: 16:24:51

Unable to send command to the vacuum: {'code': -9999, 'message': 'user ack timeout'}

Some info from the map extractor "camera":

calibration_points: 
- vacuum:
    x: 0
    'y': 0
  map:
    x: 400
    'y': 399
- vacuum:
    x: 1
    'y': 0
  map:
    x: 420
    'y': 399
- vacuum:
    x: 0
    'y': 1
  map:
    x: 400
    'y': 379

charger: 
x: -0.051763810217380524
'y': 0.19318516552448273

map_name: 0
model: viomi.vacuum.v19

Viomise is a custom integration for Viomi SE (V-RVCLM21A). Is there any way to use zone cleaning and point cleaning with this vacuum cleaner?

What version of a card has described problem?

v2.0.3

What was the last working version card?

No response

What vacuum model do you have problems with?

Viomi SE (V-RVCLM21A). Xiaomi cloud map extractor says it is "viomi.vacuum.v19".

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

https://github.com/marotoweb/home-assistant-vacuum-viomise

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

Chrome

What version of Home Assistant do you use?

core-2021.11.2

What type of installation are you running?

Home Assistant Supervised

Card's configuration

type: custom:xiaomi-vacuum-map-card
map_source:
  camera: camera.xiaomi_cloud_map_extractor
calibration_source:
  camera: true
entity: vacuum.viomi_se
vacuum_platform: send_command
camera_calibration: true

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

{
  "domain": "vacuum",
  "service": "send_command",
  "serviceData": {
    "command": "app_zoned_clean",
    "params": [
      [
        -1,
        -1,
        3,
        2,
        1
      ]
    ],
    "entity_id": "vacuum.viomi_se"
  }
}

Additional information

No response

PiotrMachowski commented 2 years ago

This is not a bug. Viomise integration uses a non-standard service calls, so it has to be added to supported vacuum platforms or manually using service call schema

Gooman-rus commented 2 years ago

Ok, I will try to create template for viomise. But why zone dimensions are always equal zero (look at me screenshot in the first message)?

PiotrMachowski commented 2 years ago

There are 2 coordinate systems used by Xiaomi vacuums: 25500-based and 0-based. In the first one 1m = 1000, in the second one 1m = 1. Platform that you used (send_command) uses the first coordinate system, but your vacuum uses the second one.

Gooman-rus commented 2 years ago

Should coordinate system be specified in the platform template file? I can't find it there.

PiotrMachowski commented 2 years ago

It is currently specified by setting coordinates_rounding. false -> 1-based, true -> 25500 based

Gooman-rus commented 2 years ago

I have tried to add coordinates_rounding with false but zone dimensions still remain equal zero. Also I have tried to clean browser's cache and this is not changing anything.

PiotrMachowski commented 2 years ago

I suggest trying to configure it in card's config and sending it here, I can do the rest. Example

Gooman-rus commented 2 years ago

I don't actually understand what should I achive. Do I need to add map_modes object to my card configuration with selection_type, for example, MANUAL_RECTANGLE and specify the service for custom integration viomise?

The thing is confuses me is that I can't understand how I can override vacuum_platform using map_modes. Could you please provide more detailed instructions?

PiotrMachowski commented 2 years ago

This is exactly what I need. Additionally you can provide a list of tiles.

You do not have to, vacuum_platform is used to generate map_modes and tiles, which you will override anyway

Gooman-rus commented 2 years ago

MANUAL_RECTANGLE provides 5 values but viomise integration requires only 4 values.

Here is what I trying to do:

map_modes:
  - name: Zones
    icon: mdi:select-drag
    selection_type: MANUAL_RECTANGLE
    max_selections: 5
    repeats_type: INTERNAL
    max_repeats: 3
    service_call_schema:
      service: vacuum.xiaomi_clean_zone
      service_data:
        zone: '[[selection]]'
        repeats: '[[repeats]]'
      target:
        entity_id: '[[entity_id]]'

Log from the browser (5 values in zone array):

{
  "domain": "vacuum",
  "service": "xiaomi_clean_zone",
  "serviceData": {
    "zone": [
      [
        -1,
        -1,
        0,
        0,
        1
      ]
    ],
    "repeats": 1
  },
  "target": {
    "entity_id": "vacuum.viomi_se"
  }
}

I get this error when trying to execute this action: Failed to call service vacuum/xiaomi_clean_zone. None @ data['zone'][0]

PiotrMachowski commented 2 years ago

The fifth parameter is repeats count, which is appended because repeats_type is set to INTERNAL. Following config should work:

  - name: Zones
    icon: mdi:select-drag
    selection_type: MANUAL_RECTANGLE
    max_selections: 5
    coordinates_rounding: false
    repeats_type: EXTERNAL
    max_repeats: 3
    service_call_schema:
      service: vacuum.xiaomi_clean_zone
      service_data:
        zone: '[[selection]]'
        repeats: '[[repeats]]'
        entity_id: '[[entity_id]]'
  - name: Clean point
    icon: mdi:map-marker-plus
    selection_type: MANUAL_POINT
    max_selections: 1
    coordinates_rounding: false
    repeats_type: NONE
    service_call_schema:
      service: vacuum.xiaomi_clean_point
      service_data:
        point: '[[selection]]'
        entity_id: '[[entity_id]]'
Gooman-rus commented 2 years ago

Clean point config works fine. The vacuum starts point cleaning. But when I start point cleaning, the fan mode changes to Turbo. And I have noticed that when I start point cleaning through the Mi Home app, it also changes fan mode to Turbo. Is it a default behaviour of xiaomi vacuum cleaners?

But Zones config is not working. First of all, now dimensions of the rectangle show real meters (above zero), very good. Also the positioning of the rectangle became very smooth. But when I click start button near the zone creation button, I can see "Success" notification and nothing happens.

In the homeassistant logs I can see this message:

Logger: custom_components.viomise.vacuum
Source: custom_components/viomise/vacuum.py:308
Integration: viomise (documentation, issues)
First occurred: 14:38:36 (1 occurrences)
Last logged: 14:38:36

Unable to clean zone: {'code': -9998, 'message': 'user ack invalid'}

Is it a bug with viomise integration?

PiotrMachowski commented 2 years ago

Is it a default behaviour of xiaomi vacuum cleaners?

It appears so. As far as I remember someone has found this "issue" on other vacuum as well.

Is it a bug with viomise integration?

It's possible, you can check service call and try to run it from dev tools to be sure.

Gooman-rus commented 2 years ago

Is it a right way to call the service from dev tools?

service: vacuum.xiaomi_clean_zone
data:
  zone:
  - - -1.095378490775417
    - -1.5482420966157804
    - 0.6180019504671357
    - -0.7262265578801923
  repeats: 1

This request causes the same error in logs and vacuum does not do anything.

PiotrMachowski commented 2 years ago

Yes, it should be ok. Just one more version to try:

service: vacuum.xiaomi_clean_zone
data:
  zone:
    - -1.0954
    - -1.5482
    - 0.6180
    - -0.7262
  repeats: 1
Gooman-rus commented 2 years ago

It is also not working: [140617283966960] Error handling message: None @ data['zone'][0]. Got None None @ data['zone'][1]. Got None None @ data['zone'][2]. Got None None @ data['zone'][3]. Got None

I have created the issue in the viomise integration repository. But it seems abandoned. Anyway, the point cleaning works fine, I can use it. Thank you.

My full config:

type: custom:xiaomi-vacuum-map-card
map_source:
  camera: camera.xiaomi_cloud_map_extractor
calibration_source:
  camera: true
entity: vacuum.viomi_se
camera_calibration: true
coordinates_rounding: false
two_finger_pan: true
tiles:
  - label: State
    entity: vacuum.viomi_se
    icon: mdi:robot-vacuum
    attribute: status
  - label: Battery
    entity: vacuum.viomi_se
    icon: mdi:battery-charging-100
    attribute: battery_level
    unit: '%'
  - label: Fan speed
    entity: vacuum.viomi_se
    icon: mdi:fan
    attribute: fan_speed
  - label: Filter
    entity: vacuum.viomi_se
    icon: mdi:air-filter
    attribute: filter_left
    unit: h
  - label: Side brush
    entity: vacuum.viomi_se
    icon: mdi:toothbrush
    attribute: side_brush_left
    unit: h
  - label: Main brush
    entity: vacuum.viomi_se
    icon: mdi:brush-variant
    attribute: main_brush_left
    unit: h
  - label: Mop
    entity: vacuum.viomi_se
    icon: mdi:format-color-fill
    attribute: mop_left
    unit: h
map_modes:
  - name: Zones
    icon: mdi:select-drag
    selection_type: MANUAL_RECTANGLE
    max_selections: 5
    coordinates_rounding: false
    repeats_type: EXTERNAL
    max_repeats: 3
    service_call_schema:
      service: vacuum.xiaomi_clean_zone
      service_data:
        zone: '[[selection]]'
        repeats: '[[repeats]]'
        entity_id: '[[entity_id]]'
  - name: Clean point
    icon: mdi:map-marker-plus
    selection_type: MANUAL_POINT
    max_selections: 1
    coordinates_rounding: false
    repeats_type: NONE
    service_call_schema:
      service: vacuum.xiaomi_clean_point
      service_data:
        point: '[[selection]]'
        entity_id: '[[entity_id]]'
PiotrMachowski commented 2 years ago

Thank you, I will add it to supported platforms 👍

PiotrMachowski commented 2 years ago

@Gooman-rus done! Thank you again!