humbertogontijo / homeassistant-roborock

Roborock integration for Home Assistant. This integration uses your devices from the Roborock App
GNU General Public License v3.0
668 stars 70 forks source link

Current map sensor #231

Closed mylbeee closed 10 months ago

mylbeee commented 1 year ago

While the robot is cleaning, is there a possibility to find out which of the stored maps is currently in use? I have three maps in total, and I'd like to make some automations based on the map that is currently under cleaning.

I found a whole lot of data regarding for example the size of the current cleaning area, which I possibly could use as a basis for a template sensor, but I think it's the wrong way around the issue.

humbertogontijo commented 1 year ago

Can you check attribute map_present from your vacuum? See if it changes when you load another map

Dis90 commented 1 year ago

@humbertogontijo mapStatus is currently loaded map. Some attributes are explained here https://github.com/humbertogontijo/homeassistant-roborock/discussions/49

For me mapPresent is always 1 even when vacuum is in different floor.

humbertogontijo commented 1 year ago

Current main branch now have the map selected as a sensor

Dis90 commented 1 year ago

When I load different map, sensor current selected map changes to empty and when I select previous map back then it displays name of the map.

Is it because vacuum is not running? Current room also displayed room name from different floor when I switched map.

humbertogontijo commented 1 year ago

Oh, are your maps named? Maybe using the map id instead would be best

Dis90 commented 1 year ago

Yep those are named. Currently it as alakerta (downstairs) but when I load upstairs map it shows empty. It is named Yläkerta in Roborock app. Seems like it converts ä to a and ö to o. So room named as keittiö is keittio.

Sensor values

Current room
olohuone
Current selected map
alakerta

2023-04-25 18:50:16.386 DEBUG (MainThread) [roborock.cloud_api] id=27960 Response from get_multi_maps_list: {'max_multi_map': 4, 'max_bak_map': 0, 'multi_map_count': 2, 'map_info': [{'mapFlag': 0, 'add_time': 1682386344, 'length': 8, 'name': 'Alakerta', 'bak_maps': []}, {'mapFlag': 1, 'add_time': 1672848972, 'length': 9, 'name': 'Yläkerta', 'bak_maps': []}]}

humbertogontijo commented 1 year ago

What is your map status values for Yläkerta and keittiö ?

Dis90 commented 1 year ago

Keittiö is room name. Map status for alakerta is 3 and for yläkerta it is 7.

humbertogontijo commented 1 year ago

Give another try with new main

Dis90 commented 1 year ago

Working now. Still shows wrong room name for upstairs hallway. Room name is from downstairs (kitchen). When I change map back to downstairs it updates room name correctly to living room.

Room id's are same for both maps. Maybe that is reason why it picks wrong name?

Here's example config from map card. Keittiö (kitchen) id is 18 and also upstairs hallway (Käytävä) is 18.

Downstairs:

                          - id: 16
                            label:
                              text: Eteinen
                              x: 27325
                              'y': 20725
                              offset_y: 35
                            icon:
                              name: mdi:broom
                              x: 27325
                              'y': 20725
                          - id: 17
                            label:
                              text: Pikkuhuone
                              x: 26150
                              'y': 25075
                              offset_y: 35
                            icon:
                              name: mdi:bed
                              x: 26150
                              'y': 25075
                          - id: 18
                            label:
                              text: Keittiö
                              x: 29200
                              'y': 19850
                              offset_y: 35
                            icon:
                              name: mdi:fridge
                              x: 29200
                              'y': 19850
                          - id: 19
                            label:
                              text: Olohuone
                              x: 28875
                              'y': 24400
                              offset_y: 35
                            icon:
                              name: mdi:sofa
                              x: 28875
                              'y': 24400
                          - id: 20
                            label:
                              text: Tuulikaappi
                              x: 27150
                              'y': 18950
                              offset_y: 35
                            icon:
                              name: mdi:door
                              x: 27150
                              'y': 18950
                          - id: 21
                            label:
                              text: Kylpyhuone
                              x: 25950
                              'y': 19750
                              offset_y: 35
                            icon:
                              name: mdi:shower
                              x: 25950
                              'y': 19750

Upstairs:

                              - id: 16
                                label:
                                  text: Luka
                                  x: 26550
                                  'y': 22625
                                  offset_y: 35
                                icon:
                                  name: mdi:bed
                                  x: 26550
                                  'y': 22625
                              - id: 17
                                label:
                                  text: Master
                                  x: 23600
                                  'y': 22575
                                  offset_y: 35
                                icon:
                                  name: mdi:bed-king
                                  x: 23600
                                  'y': 22575
                              - id: 18
                                label:
                                  text: Käytävä
                                  x: 26075
                                  'y': 25325
                                  offset_y: 35
                                icon:
                                  name: mdi:broom
                                  x: 26075
                                  'y': 25325
                              - id: 19
                                label:
                                  text: Kylpyhuone
                                  x: 23150
                                  'y': 26925
                                  offset_y: 35
                                icon:
                                  name: mdi:shower
                                  x: 23150
                                  'y': 26925
                              - id: 20
                                label:
                                  text: Toimisto
                                  x: 26025
                                  'y': 27925
                                  offset_y: 35
                                icon:
                                  name: mdi:laptop
                                  x: 26025
                                  'y': 27925

Camera map shows null values for map_name and rooms

map_name: null

room_numbers: 
'16': null
'17': null
'18': null
'19': null
'20': null
'21': null

vacuum_room: 19
vacuum_room_name: null
humbertogontijo commented 1 year ago

Can you set map for downstairs, send command get_room_mapping and get response from logs?

Dis90 commented 1 year ago

2023-04-25 19:59:41.525 DEBUG (MainThread) [roborock.cloud_api] id=81856 Response from get_room_mapping: [[16, '7140420'], [17, '7132107'], [18, '7132112'], [19, '7132110'], [20, '9691218'], [21, '9691215']]

humbertogontijo commented 1 year ago

I made a small change to latest main. Not sure if that will do the trick, but could you give another try?

Dis90 commented 1 year ago

Working now :)

Is there some reason why vacuum map camera attributes doesn't have map or room names? Not big deal, I just want to know why :D Wait, _There's no longer map_name and vacuum_roomname Edit. those are displayed when debug logging is enabled but value is Null

access_token: xxxxxxx
entity_picture: /api/camera_proxy/camera.carlos_map?token=xxxx
icon: mdi:map
friendly_name: Carlos Map
supported_features: 1
calibration_points: 
- vacuum:
    x: 25500
    'y': 25500
  map:
    x: 123
    'y': 189
- vacuum:
    x: 26500
    'y': 25500
  map:
    x: 183
    'y': 189
- vacuum:
    x: 25500
    'y': 26500
  map:
    x: 123
    'y': 129

carpet_map: 
charger: 
x: 28893
'y': 22086
a: 92

image: 
size: 33072
offset_y: 362
offset_x: 469
height: 212
scale: 3
rotation: 0
width: 156

is_empty: false
no_go_areas: 
no_mopping_areas: 
path: 
point_length: 0
point_size: 4
angle: 0
path:
  - []

room_numbers: 
'16': null
'17': null
'18': null
'19': null
'20': null
'21': null

rooms: 
'16':
  x0: 26650
  y0: 18350
  x1: 28050
  y1: 21850
'17':
  x0: 25150
  y0: 23450
  x1: 27200
  y1: 26800
'18':
  x0: 28000
  y0: 18400
  x1: 30350
  y1: 21350
'19':
  x0: 26800
  y0: 21900
  x1: 30950
  y1: 26900
'20':
  x0: 26650
  y0: 18300
  x1: 27850
  y1: 19550
'21':
  x0: 25200
  y0: 18350
  x1: 26800
  y1: 21200

vacuum_position: 
x: 28889
'y': 22265
a: -88

vacuum_room: 19
walls: 
humbertogontijo commented 1 year ago

The camera entity was basically copy and paste from another repository. Any further fixes will be done when this is solved https://github.com/humbertogontijo/python-roborock/pull/9