python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

get_room_mapping returns empty list

Open ulope opened this issue 2 years ago • 18 comments

Describe the bug get_room_mapping returns empty list ([]) despite rooms being setup in the app.

Other commands (e.g. info, clean_history etc. work fine).

Version information (please complete the following information):

  • OS: macOS 11.6.1
  • python-miio: 0.5.9.2

Device information:

  • Model: roborock.vacuum.s5
  • Hardware version: Linux
  • Firmware version: 3.5.8_002034

To Reproduce Steps to reproduce the behavior:

  1. Run miiocli vacuum --ip XXX --token YYY get_room_mapping

Expected behavior A list of rooms / segments to be returned

Console output

INFO:miio.cli:Debug mode active
/Users/ulo/.local/pipx/venvs/python-miio/lib/python3.9/site-packages/miio/click_common.py:270: DeprecationWarning: Call to deprecated function __init__ (This class will become the base class for all vacuum implementations. Use RoborockVacuum to control roborock vacuums.).
  ctx.obj = self.device_class(*args, **kwargs)
Running command get_room_mapping
DEBUG:miio.click_common:Unknown model, trying autodetection. None None
DEBUG:miio.miioprotocol:Got a response: Container:
    data = Container:
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        data = b'!1\x00 \x00\x00\x00\x00\x05\xc2\xc4\xb0a\xc3;s' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('05c2c4b0')
            ts = 2021-12-22 14:51:31
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 05c2c4b0 with ts: 2021-12-22 14:51:31, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.0.2:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:Retrying with incremented id, retries left: 3
DEBUG:miio.miioprotocol:Got a response: Container:
    data = Container:
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        data = b'!1\x00 \x00\x00\x00\x00\x05\xc2\xc4\xb0a\xc3;x' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('05c2c4b0')
            ts = 2021-12-22 14:51:36
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 05c2c4b0 with ts: 2021-12-22 14:51:36, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.0.2:54321 >>: {'id': 102, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:192.168.0.2:54321 (ts: 2021-12-22 14:51:36, id: 102) << {'partner_id': '', 'id': 102, 'code': 0, 'message': 'ok', 'result': {'hw_ver': 'Linux', 'fw_ver': '3.5.8_002034', 'ap': {'ssid': 'XXXXXX', 'bssid': 'XXXXXXXX', 'rssi': -49}, 'netif': {'localIp': '192.168.0.2', 'mask': '255.255.255.0', 'gw': '192.168.0.1'}, 'miio_ver': 'miio-client 3.5.8', 'model': 'roborock.vacuum.s5', 'mac': 'XXXXXXXXX', 'token': 'XXXXXXXXXXXXXXXXXXXXXXX', 'life': 44109}}
DEBUG:miio.device:Detected model roborock.vacuum.s5
DEBUG:miio.miioprotocol:192.168.0.2:54321 >>: {'id': 103, 'method': 'get_room_mapping', 'params': []}
DEBUG:miio.miioprotocol:192.168.0.2:54321 (ts: 2021-12-22 14:51:36, id: 103) << {'result': [], 'id': 103}
[]

ulope avatar Dec 22 '21 14:12 ulope

I'm having the same issue

-> % miiocli roborockvacuum --ip 192.168.0.143 --token ABC321 get_room_mapping
Running command get_room_mapping
[]

qweluke avatar Jan 03 '22 14:01 qweluke

Maybe that command should be removed altogether, as I suppose it was never working at all..? The empty response is directly coming from the device, so there is nothing this library can do about it. My understanding is that the device doesn't unfortunately expose any mapping information over the method calls.

rytilahti avatar Jan 04 '22 19:01 rytilahti

same here with NAME: Roborock S7 MODEL: roborock.vacuum.a15

miiocli roborockvacuum --ip XXX --token XXX get_room_mapping Running command get_room_mapping []

Schlunze avatar Jan 06 '22 16:01 Schlunze

I have the same problem, but found a workaround for the time this doesn't work. Using Home Assistant and the Xiaomi Cloud Map Extractor.

First add this to your camera config:

attributes:
    - room_numbers

Then the room numbers will be displayed in Developer --> States

Next send your vacuum to a specific number of that list with:

service: xiaomi_miio.vacuum_clean_segment
target:
  device_id: 'YourDeviceID'
data:
  segments: 'YourRoomNumber'

Write down on a piece of paper to which room your robot goes 👍

maikvitesse avatar Jan 08 '22 12:01 maikvitesse

This is the brute force workaround I used for finding the segment IDs for a roborock.vacuum.s5.

It was slow, but I eventually got the IDs using miiocli commands.

Background:

$ miiocli vacuum --ip XXX --token YYY info
Model: roborock.vacuum.s5
Hardware version: Linux
Firmware version: 3.5.8_002034

I have 3 segments mapped within a single floor, using the Mi Home app and "Map saved mode (Beta)" enabled for the S5. I wanted the segment IDs for configuring rooms within https://github.com/homebridge-xiaomi-roborock-vacuum/homebridge-xiaomi-roborock-vacuum.

Process:

  1. Found token & IP information using https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor.
  2. Installed python-miio.
  3. Tried $ miiocli vacuum --ip XXX --token YYY get_room_mapping but got an empty list [] response.
  4. In Mi Home app I opened the map view for the S5 device to see where the vacuum will go. The segments have different colors (yellow = living room, red = kitchen, blue = dining room) and will be highlighted when the room is selected in the following steps.
  5. Starting with ID=0, I ran the segment_clean command:$ ID=0 miiocli vacuum --ip XXX --token YYY segment_clean [${ID}]
  6. That errored for me with a "Could not reach the specified room, going back to the dock." voice message from the vacuum, so I kept incrementing the ID number (ID=1, ID=2, ID=3, ...) and re-running step 5 until the vacuum did not report an error.
  7. On success, when the vacuum would eventually go to the correct room without error (ID=17), the segment color in the Mi Home app highlights the segment color in the floor map UI.
    • I would then pause the vacuum $ miiocli vacuum --ip XXX --token YYY pause.
    • And then go back through steps 5-7 and continue incrementing ID numbers until all segments were found (mine were IDs 17, 18, and 19).

cgmartin avatar Jan 17 '22 00:01 cgmartin

@cgmartin Yes, that's what I ended up doing as well, but even with just 5 rooms this is quite tedious. @rytilahti Since the official app obviously can display all the rooms there should be a way for the library to do the same...

ulope avatar Jan 17 '22 14:01 ulope

An easier way to get the room_ids is the following (at least for the S7):

  • Start with an empty map in the app without any room names
  • Name just one room in the app
  • Run a get_room_mapping You will receive a list with only one item - the room you just named
  • Give the next room a name in the app
  • Run get_room_mapping again This time the list contains two elements, so you have the ID of the second room.

Just add a name to one and one room until you have the full list.

Olen avatar Feb 16 '22 19:02 Olen

First add this to your camera config:

@maikvitesse, what does this mean?

jakobrosenberg avatar Mar 08 '22 14:03 jakobrosenberg

First add this to your camera config:

@maikvitesse, what does this mean?

When you use Home Assistant and have set up the xiaomi_cloud_map_extractor (as camera) you have to add the code i suggested in that config

maikvitesse avatar Mar 09 '22 07:03 maikvitesse

Hi

This situation become more and more difficult, the problem seem to be on the HomeBridge/HOOBS as the "Automatic Room Detection" not really shows any type of room id Starting checking all the forums i become to end here and this is the situation

Roborock S7 can not get the room_id, see the command below:

miiocli roborockvacuum --ip "MY IP" --token "MI TOKEN" get_room_mapping []

There is no result there so impossible to get data and take advantage to use by room :(

simposiummm avatar May 06 '22 11:05 simposiummm

An easier way to get the room_ids is the following (at least for the S7):

  • Start with an empty map in the app without any room names
  • Name just one room in the app
  • Run a get_room_mapping You will receive a list with only one item - the room you just named
  • Give the next room a name in the app
  • Run get_room_mapping again This time the list contains two elements, so you have the ID of the second room.

Just add a name to one and one room until you have the full list.

Hi Im interesting on your workaround but when try to add the roborcok to the xiaomy application i can not see the device on the APP so is nearly impossible create the map on this specific application

On the Roborock application the situation is fine but as you may know there is no possibility to get the token there :(

simposiummm avatar May 06 '22 11:05 simposiummm

@Olen, worked like a charm! Thanks!

Morcains avatar May 25 '22 15:05 Morcains

An easier way to get the room_ids is the following (at least for the S7):

  • Start with an empty map in the app without any room names
  • Name just one room in the app
  • Run a get_room_mapping You will receive a list with only one item - the room you just named
  • Give the next room a name in the app
  • Run get_room_mapping again This time the list contains two elements, so you have the ID of the second room.

Just add a name to one and one room until you have the full list.

Thanks for the tip! For me I have already divided the rooms in the Xiaomi app, but I didn't name them. As soon as I named one and saved, and run get_room_mapping again, the ID showed up!

TL;DR: make sure you name the room in the app!!!

bgou avatar Oct 06 '22 08:10 bgou

An easier way to get the room_ids is the following (at least for the S7):

  • Start with an empty map in the app without any room names
  • Name just one room in the app
  • Run a get_room_mapping You will receive a list with only one item - the room you just named
  • Give the next room a name in the app
  • Run get_room_mapping again This time the list contains two elements, so you have the ID of the second room.

Just add a name to one and one room until you have the full list.

Thanks for the tip! For me I have already divided the rooms in the Xiaomi app, but I didn't name them. As soon as I named one and saved, and run get_room_mapping again, the ID showed up!

TL;DR: make sure you name the room in the app!!!

Sadly I´m missing the option to name my rooms :( Using the Xiaomi app and have a S5.

blarrkan avatar Jan 05 '23 15:01 blarrkan

Yeah seems like with a S5 / S50 the get_room_mapping call is simply not supported and only the trial and error method works.

ulope avatar Jan 06 '23 13:01 ulope

@Olen Which command is it to get the rooms? When do you execute it?

tommyMX avatar Jan 18 '23 08:01 tommyMX

This is the brute force workaround I used for finding the segment IDs for a roborock.vacuum.s5.

It was slow, but I eventually got the IDs using miiocli commands.

Background:

$ miiocli vacuum --ip XXX --token YYY info
Model: roborock.vacuum.s5
Hardware version: Linux
Firmware version: 3.5.8_002034

I have 3 segments mapped within a single floor, using the Mi Home app and "Map saved mode (Beta)" enabled for the S5. I wanted the segment IDs for configuring rooms within https://github.com/homebridge-xiaomi-roborock-vacuum/homebridge-xiaomi-roborock-vacuum.

Process:

  1. Found token & IP information using https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor.

  2. Installed python-miio.

  3. Tried $ miiocli vacuum --ip XXX --token YYY get_room_mapping but got an empty list [] response.

  4. In Mi Home app I opened the map view for the S5 device to see where the vacuum will go. The segments have different colors (yellow = living room, red = kitchen, blue = dining room) and will be highlighted when the room is selected in the following steps.

  5. Starting with ID=0, I ran the segment_clean command:$ ID=0 miiocli vacuum --ip XXX --token YYY segment_clean [${ID}]

  6. That errored for me with a "Could not reach the specified room, going back to the dock." voice message from the vacuum, so I kept incrementing the ID number (ID=1, ID=2, ID=3, ...) and re-running step 5 until the vacuum did not report an error.

  7. On success, when the vacuum would eventually go to the correct room without error (ID=17), the segment color in the Mi Home app highlights the segment color in the floor map UI.

    • I would then pause the vacuum $ miiocli vacuum --ip XXX --token YYY pause.
    • And then go back through steps 5-7 and continue incrementing ID numbers until all segments were found (mine were IDs 17, 18, and 19).

Thanks, @cgmartin - incredibly helpful answer for anyone with an S5. Pretty sure that rooms defined in the app by users commence at 16 whilst 0 - 15 may be reserved for rooms identified by the vacuum - just a guess.

ceej23 avatar Jun 11 '23 05:06 ceej23

The command works if you give your rooms names. Just go to Mi Home -> Vacuum -> Edit map -> Edit room -> select every room and give it a name.

After that:

miiocli roborockvacuum --ip x.x.x.x --token xxx get_room_mapping
Running command get_room_mapping
[[26, '912001066784'], [27, '912001066783']]

UPD: don't forget to tap on checkmark icon in the app to save changes. they are batched and not applied until that button is tapped

stalniy avatar Sep 01 '23 12:09 stalniy