PiotrMachowski / Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor

This custom integration provides a way to present a live view of a map for Xiaomi (Roborock/Viomi/Roidmi/Dreame) vacuums without a need for rooting.
MIT License
1.17k stars 123 forks source link

Rotate the map by any angle #377

Open adrgumula opened 1 year ago

adrgumula commented 1 year ago

Description

I cannot set properly the cleaning zones, nor room when my the apparent. After the map extraction my apparent is rotated by around 45 deg. This complicates the possibility to setup the rooms and cleaning zones.

Solution

Add rotate by any angle in the camera configuration. Currently is: 90, 180, 270 etc Wanted to have: -45, 45, 61 etc (positive values rotate clockwise)

camera:
  - platform: xiaomi_cloud_map_extractor
    host: !secret xiaomi_host
    token: !secret xiaomi_token
    username: !secret xiaomi_username
    password: !secret xiaomi_password
    draw: ["all"]
    store_map_raw: true
    map_transformation:
      rotate: 46

Alternatives

Rotate the map via camera config file clockwise by: 45, 90, 135, 225, 270, 315

Context

This is how the auto extracted map looks like (it is exactly the same as in the Xiaomi Home Android app)

Left: current status Right: With this feature: 208298433-6b18a6a8-d84b-46b7-9b79-00ab8c7c529e

cataseven commented 9 months ago

Code

card_mod:
  style: |
    #map-image {
       transform: rotate(270deg);
     }

EXAMPLE (You have to edit x,y coordinates of label and icons)

                type: custom:xiaomi-vacuum-map-card
                entity: vacuum.viomi_se
                preset_name: Downstairs
                map_source:
                  camera: camera.xiaomi_cloud_map_extractor
                  crop:
                    top: 435
                    bottom: 280
                    left: 490
                    right: 160
                calibration_source:
                  camera: true
                clean_selection_on_start: true
                map_locked: true
                two_finger_pan: true
                icons: []
                tiles: []
                map_modes:
                  - selection_type: ROOM
                    name: Room Cleaning
                    icon: mdi:floor-plan
                    max_selections: 5
                    repeats_type: NONE
                    predefined_selections:
                      - id: 10
                        label:
                          text: Kitchen
                          x: 10.3
                          'y': -0.9
                        icon:
                          name: mdi:water-plus
                          x: 10.3
                          'y': -1.5
                      - id: 11
                        label:
                          text: Living Room
                          x: 3.7
                          'y': -2.1
                        icon:
                          name: mdi:water-plus
                          x: 3.7
                          'y': -2.7
                      - id: 12
                        label:
                          text: Hallway
                          x: 9.7
                          'y': -3.7
                        icon:
                          name: mdi:water-plus
                          x: 9.7
                          'y': -4.2
                      - id: 13
                        label:
                          text: Guest Room
                          x: 12.1
                          'y': -5.8
                        icon:
                          name: mdi:water-plus
                          x: 12.1
                          'y': -6.3
                      - id: 15
                        label:
                          text: Staircase
                          x: 8.3
                          'y': -5.2
                        icon:
                          name: mdi:water-plus
                          x: 8.3
                          'y': -5.7
                    service_call_schema:
                      service: xiaomi_miot.call_action
                      service_data:
                        entity_id: vacuum.viomi_v13
                        siid: 4
                        aiid: 15
                        params:
                          - piid: 21
                            value: 0
                          - piid: 22
                            value: 1
                          - piid: 20
                            value: '[[selection_unwrapped]]'
                        force_params: true
                  - template: vacuum_clean_zone
                    name: Zone Cleaning
                  - template: vacuum_clean_point
                    name: Point Cleaning
                vacuum_platform: marotoweb/viomise
                card_mod:
                  style: |
                    ha-card {
                      --map-card-room-label-color: rgb(255, 255, 255);
                      --map-card-room-label-color-selected: rgb(255, 255, 255);
                      --map-card-room-icon-wrapper-size: 18px;
                      --map-card-room-icon-size: 14px;
                    }

                    #map-image {
                      transform: rotate(270deg);
                    }
adrgumula commented 9 months ago

Hi @cataseven thanks for the replay. I've moved the vacuum to a different place. It turned out that docking station (the wall where I kept it plugged in) was at the angle (~45deg) to the rest of the apartment.