rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.81k stars 564 forks source link

get_room_mapping returns empty list #1272

Open ulope opened 2 years ago

ulope commented 2 years ago

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):

Device information:

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}
[]
qweluke commented 2 years ago

I'm having the same issue

-> % miiocli roborockvacuum --ip 192.168.0.143 --token ABC321 get_room_mapping
Running command get_room_mapping
[]
rytilahti commented 2 years ago

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.

Schlunze commented 2 years ago

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

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

maikvitesse commented 2 years ago

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 👍

cgmartin commented 2 years ago

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).
ulope commented 2 years ago

@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...

Olen commented 2 years ago

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

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

jakobrosenberg commented 2 years ago

First add this to your camera config:

@maikvitesse, what does this mean?

maikvitesse commented 2 years ago

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

simposiummm commented 2 years ago

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 commented 2 years ago

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 :(

Morcains commented 2 years ago

@Olen, worked like a charm! Thanks!

bgou commented 2 years ago

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!!!

blarrkan commented 1 year ago

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.

ulope commented 1 year ago

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

tommyMX commented 1 year ago

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

ceej23 commented 1 year ago

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.

stalniy commented 1 year ago

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

phoehnel commented 2 months ago

I don't find an option to name the rooms in my anymore, did they remove it?

I can confirm the get_room_mapping command always worked when my rooms were named, but now I had to re-cut some room borders, the rooms lost their names, and I am unable to assign them anymore.

stalniy commented 2 months ago

Go to app, edit room -> and click on Name.

I have this option in Roborock app

phoehnel commented 2 months ago

Go to app, edit room -> and click on Name.

I have this option in Roborock app

It used to work the same way in the Xiaomi Home App, but seems like, the option is now gone.

image

dabstractor commented 1 week ago

It used to work the same way in the Xiaomi Home App, but seems like, the option is now gone.

On iphone I have an Edit Room option under the All panel's bottom left floating menu. But it only lets you Merge and Divide, I can't find anywhere that will let me name the room.