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.45k stars 249 forks source link

Map rotate causes issues with zone cleaning #173

Closed PiotrMachowski closed 2 years ago

PiotrMachowski commented 2 years ago

Discussed in https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/discussions/172

Originally posted by **geezer54** November 17, 2021 First, I wanted to say how impressed I am with your new card. Its quite a significant upgrade from your previous release! When the map is rotated 90% via [Xiaomi-Cloud-Map-Extractor config](https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor#map-transformation-configuration), the selection box in zone cleaning does not work correctly. Mouse movement up causes selection box lower edge to move down and vice versa. Also, the x,y coordinates appear to be exchanged. FYI: I'm using chrome browser on Windows 10. https://user-images.githubusercontent.com/67194877/142241761-f3f7a701-3cb2-4473-9518-eeae0528dba3.mp4
heisenberg2980 commented 2 years ago

Following. Same issue here with map rotated 180 degrees

jacekpaszkowski commented 2 years ago

I have same issue but with my camera map - images generated from ValetudoRE

2021-11-21_15h26_50 E

PiotrMachowski commented 2 years ago

I already have a solution, it will be included in the next release.

@jacekpaszkowski what is your setup to make card work with valetudo?

jacekpaszkowski commented 2 years ago

My vacuum is connected via standard HA integration and also via Valetudo RE MQTT. I'm also able to read predefined zones from sensor using custom:config-template-card Have to use both because of problems eg. with fan speed :(

Still work in progress, but most of all works okey

type: custom:config-template-card
    variables:
      zones: >-
        states['sensor.rockrobo_valetudo_zones_processed'].attributes['predefined_selections']
    entities:
      - sensor.rockrobo_valetudo_zones_processed
      - vacuum.xiaomi_vacuum_cleaner
      - camera.rockrobo_map
      - vacuum.rockrobo
    card:
      type: custom:xiaomi-vacuum-map-card
      entity: vacuum.xiaomi_vacuum_cleaner
      map_source:
        camera: camera.rockrobo_map
      language: pl
      vacuum_platform: send_command
      calibration_source:
        calibration_points:
          - vacuum:
              x: 25210
              'y': 19057
            map:
              x: 35
              'y': 20
          - vacuum:
              x: 25210
              'y': 27625
            map:
              x: 35
              'y': 1035
          - vacuum:
              x: 35388
              'y': 27625
            map:
              x: 1255
              'y': 1035
      map_modes:
        - name: Pokoje
          icon: mdi:floor-plan
          selection_type: PREDEFINED_RECTANGLE
          max_selections: 5
          coordinates_rounding: true
          repeats_type: EXTERNAL
          max_repeats: 3
          service_call_schema:
            service: pyscript.rockrobo_start_predefined_zone_cleaning
            service_data:
              coordinates: '[[selection]]'
              repeats: '[[repeats]]'
              vacuum: vacuum.rockrobo
          predefined_selections: ${zones}
        - name: Idź do punktu
          icon: mdi:crosshairs-gps
          selection_type: MANUAL_POINT
          coordinates_rounding: true
          service_call_schema:
            service: pyscript.rockrobo_goto
            service_data:
              coordinates: '[[selection]]'
              vacuum: '[[entity_id]]'
        - template: vacuum_clean_zone
      append_icons: true
      icons:
        - icon: mdi:home
          tooltip: Sprzątanie całego mieszkania
          tap_action:
            service: input_select.select_option
            service_data:
              entity_id: input_select.vacuum_room
              option: Wszystkie
        - icon: mdi:delete-empty
          tooltip: Podjedź do kosza
          service: script.roborock_go_to_empty_bin
      append_tiles: true
      tiles:
        - entity: vacuum.rockrobo
          label: Filtr
          attribute: filter
          icon: mdi:air-filter
          unit: h
        - entity: vacuum.rockrobo
          label: Sensor
          attribute: sensor
          icon: mdi:eye
          unit: h
        - entity: vacuum.rockrobo
          label: Główna
          attribute: mainBrush
          icon: mdi:brush-variant
          unit: h
        - entity: vacuum.rockrobo
          label: Boczna
          attribute: mainBrush
          icon: mdi:brush
          unit: h
        - entity: sensor.vacuum_hours_from_last_bin_out_time
          label: Opróżnianie
          icon: mdi:delete-empty
          unit: h
        - entity: sensor.vacuum_cleaned_area
          label: Powierzchnia
          unit: m²
        - entity: sensor.vacuum_cleaning_time
          label: Trwało
          unit: m
        - entity: sensor.vacuum_time_from_last_cleanup
          label: Minęło
        - entity: sensor.vacuum_time_to_next_automatic_cleanup
          label: Następne
        - entity: sensor.vacuum_area_cleaned_since_last_bin_emptying
          label: Opróżniano
          unit: m²
        - entity: vacuum.rockrobo
          label: Liczba sprzątań
          attribute: cleanCount
          icon: mdi:counter
PiotrMachowski commented 2 years ago

@jacekpaszkowski I want to add Valetudo to supported platforms, can you show me what services does it use?

PiotrMachowski commented 2 years ago

This issue should be fixed in v2.0.3 @geezer54 @Heisenberg2980 @jacekpaszkowski can you confirm it's working?

jacekpaszkowski commented 2 years ago

It works good for me now. Thank You!

I use ValetudoRE not original Valetudo. In HA it works as Mqtt Vacuum, here (https://github.com/rand256/valetudo/blob/testing/lib/MqttClient.js) you can find list of services, and custom send_comand commands. Unfortuantelly Mqtt it doesn't support "goto" and "zoned_cleanup" to given coordintes, only to named zones and spots defined in Valetudo settings.

So for "goto" and "zoned_cleanup" with coordinates from your map i have to use xiaomi_miio entity with "translated" coordinates

jacekpaszkowski commented 2 years ago

These are attributes of my mqtt vacuum:

fan_speed_list: min, medium, high, max, mop
battery_level: 94
battery_icon: mdi:battery-90
fan_speed: high
mainBrush: 102.0
sideBrush: 73.7
filter: 94.0
sensor: 0.7
currentCleanTime: 5.5
currentCleanArea: 4.0
cleanTime: 198.0
cleanArea: 10696.2
cleanCount: 384
last_run_stats: 
startTime: 1637578888000
endTime: 1637579010000
duration: 121
area: '0.3'
errorCode: 0
errorDescription: No error
finishedFlag: true

bin_in_time: 124
last_bin_out: 1637247060620
last_bin_full: -1
last_loaded_map: null
valetudo_state: 
id: 17
name: Zoned cleaning

friendly_name: Rosie
supported_features: 10236
wowgamr commented 2 years ago

Hello! Is it the same problem? My map rotated by 180 degrees and i can't select zone. image

heisenberg2980 commented 2 years ago

This issue should be fixed in v2.0.3 @geezer54 @Heisenberg2980 @jacekpaszkowski can you confirm it's working?

Updated to v2.0.3 and it is working now, thanks!!

PiotrMachowski commented 2 years ago

@wowgamr I am pretty sure you have an old version of the card, update to v2.0.3 should fix it

wowgamr commented 2 years ago

Same issue on v2.0.3 :( There is an error in console: image

NikiHard commented 2 years ago

I have no calibration points

camera:
  - platform: xiaomi_cloud_map_extractor
    host: host
    token: token
    username: username
    password: password
    country: "ru"
    draw: ['all']
    attributes:
      - calibration_points 
    map_transformation:
      rotate: 180
      trim:
        top: 25
        bottom: 20
        left: 15
        right: 20
    colors:
      color_map_inside: [28, 28, 28, 0]
      color_map_outside: [28, 28, 28, 0]
      color_path: [28, 28, 28]
      color_robo: [28, 28, 28]
          - type: custom:xiaomi-vacuum-map-card
            entity: vacuum.roborock_s6_maxv
            map_source:
              camera: camera.xiaomi_cloud_map_extractor
            calibration_source:
              camera: true
            map_modes:
              - template: vacuum_clean_zone
              - template: vacuum_clean_zone_predefined
            tiles: []
PiotrMachowski commented 2 years ago

@NikiHard they are available in attributes of camera in devtools Open your Home Assistant instance and show your state developer tools.

NikiHard commented 2 years ago

@NikiHard they are available in attributes of camera in devtools Open your Home Assistant instance and show your state developer tools.

- vacuum:
    x: 25500
    'y': 25500
  map:
    x: 85
    'y': 111
- vacuum:
    x: 26500
    'y': 25500
  map:
    x: 65
    'y': 111
- vacuum:
    x: 25500
    'y': 26500
  map:
    x: 85
    'y': 131

image

PiotrMachowski commented 2 years ago

@NikiHard oh, you seem to have a problem with your resources (xiaomi-vacuum-map-card is added twice) + it says that you still use v2.0.2

NikiHard commented 2 years ago

@NikiHard ой, похоже, у вас проблема с вашими ресурсами ( xiaomi-vacuum-map-cardдобавляется дважды) + там написано, что вы все еще используете v2.0.2

OK, thanks! How to define the boundaries of rooms?

PiotrMachowski commented 2 years ago

@NikiHard Like that: documentation

geezer54 commented 2 years ago

Map rotate issues fixed for me!!! Thankyou!

I had the same version issue as NikiHard. After updating the cards in HACS, in configuration.yaml, I had to replace "- url: /local/community/lovelace-xiaomi-vacuum-map-card/xiaomi-vacuum-map-card.js" to "- url: /hacsfiles/lovelace-xiaomi-vacuum-map-card/xiaomi-vacuum-map-card.js"

PiotrMachowski commented 2 years ago

@NikiHard does everything work now?

NikiHard commented 2 years ago

@NikiHard does everything work now?

Yes, thanks a lot