Xiaomi Cloud Vacuum Map Extractor

Hi, I tried to read everything but I didn’t find anything (or I didn’t read the post :joy:)
I would like to know how I can extract the coordinates of a specific point on the map?
I need the coordinates to create a script so that the robot goes to a specific point, that is, in front of the garbage can. The script will then be called via voice assistant.

Do you use map card? It can show coordinates of selection in card editor

1 Like

Yes. Now I managed to find the coordinates. I created this script but it doesn’t work.
I’ve tried some but I can’t. Between the heat and the tiredness, I raise the white flag!:joy:

alias: Giovanni Pulizia
sequence:
  - service: vacuum.vacuum_goto
    data:
     params:
      X: -1.1199999999999974
      Y: 0.7499999999999964
    target:
      entity_id: vacuum.giovanni
mode: single
icon: hass:robot-vacuum

Would you give me a hand? Thank you very much.

I’m definitely wrong. This is the error I receive:

Giovanni Pulizia: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data['ATTR_X_COORD']
Giovanni Pulizia: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data['X_COORD']
Giovanni Pulizia: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data['x_coordinate']

Which vacuum and integration do you use?

Viomi v8

Hacky support for STYJ02YM/STYTJ02YM

Before I had another intention but it was not compatible with the map ext

alias: Giovanni Pulizia
sequence:
  - service: vacuum.vacuum_goto
    data:
     params:
      x: -1.1199999999999974
      y: 0.7499999999999964
    target:
      entity_id: vacuum.giovanni
mode: single
icon: hass:robot-vacuum

This one should work

No… It doesn’t work.

Logger: homeassistant.components.script.giovannipulizia
Source: helpers/script.py:420
Integration: Script (documentation, issues)
First occurred: 15:03:31 (1 occurrences)
Last logged: 15:03:31

Giovanni Pulizia: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data['params']
alias: Giovanni Pulizia
sequence:
  - service: vacuum.vacuum_goto
    data:
      x_coord: -1.1199999999999974
      y_coord: 0.7499999999999964
      entity_id: vacuum.giovanni
mode: single
icon: hass:robot-vacuum

Ooo Yesss! It worked!
Now how can I make the vacuum cleaner, once it arrives at the coordinates, stops in front of the garbage can?
Now the vacuum cleaner arrives at the required point does a cleaning as if it were an area, Has started cleaning the floor stains.

You probably have to use vacuum.stop service at the right moment…

But can I integrate it into the same script? Or can I use a delay ?

Delay or check coordinates of the vacuum and stop of it’s close enough.

But now that I look at the register I find this error:

Logger: homeassistant.components.script.giovannipulizia
Source: custom_components/miio2/vacuum.py:231
Integration: Script (documentation, issues)
First occurred: 15:52:22 (1 occurrences)
Last logged: 15:52:22

Giovanni Pulizia: Error executing script. Unexpected error for call_service at pos 1: Passing coroutines is forbidden, use tasks explicitly.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 1965, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2005, in _execute_service
    return await cast(
           ^^^^^^^^^^^
  File "/config/custom_components/miio2/vacuum.py", line 231, in async_service_handler
    await asyncio.wait(update_tasks)
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 415, in wait
    raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.

I tried to do this:

alias: Giovanni Pulizia
sequence:
  - service: vacuum.vacuum_goto
    data:
      x_coord: -1.1199999999999974
      y_coord: 0.7499999999999964
      entity_id: vacuum.giovanni
  - service: vacuum.stop
mode: single
icon: hass:robot-vacuum

But this error similar to the other is generated:

Logger: homeassistant.components.script.giovannipulizia
Source: custom_components/miio2/vacuum.py:231
Integration: Script (documentation, issues)
First occurred: 15:52:22 (2 occurrences)
Last logged: 15:55:31

Giovanni Pulizia: Error executing script. Unexpected error for call_service at pos 1: Passing coroutines is forbidden, use tasks explicitly.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 1965, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2005, in _execute_service
    return await cast(
           ^^^^^^^^^^^
  File "/config/custom_components/miio2/vacuum.py", line 231, in async_service_handler
    await asyncio.wait(update_tasks)
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 415, in wait
    raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.

The vacuum cleaner starts and does what it did before, arrives at the coordinates and then cleans the area.

Okay, maybe it may seem stupid. I tried to put the copy paste of the error on "Bard.google.com"And that’s how I told me:

The error you are getting is due to a change in the Home Assistant core in version 2023.6.0. In this version, the `asyncio.wait` function no longer accepts coroutines as arguments. Instead, you need to explicitly convert the coroutines to tasks before passing them to `asyncio.wait`.

In your case, the `async_service_handler` function in the `miio2` custom component is passing a coroutine to the `asyncio.wait` function. This is causing the error you are seeing.

To fix this error, you need to convert the coroutine in the `async_service_handler` function to a task before passing it to `asyncio.wait`. You can do this by using the `asyncio.create_task` function.

Here is the updated code for the `async_service_handler` function:

python
async def async_service_handler(self, service_call):
    update_tasks = [
        asyncio.create_task(self.miio.async_set_fan_speed(service_call.data["fan_speed"])),
        asyncio.create_task(self.miio.async_set_power(service_call.data["power"])),
    ]
    await asyncio.wait(update_tasks)

This code converts the two coroutines in the `update_tasks` list to tasks before passing them to the `asyncio.wait` function. This will fix the error you are seeing.

Once you have made this change, you should be able to execute the script without any errors.

Could this be the problem?

Mmm :thinking:
This vacuum.py It is very different from mine.
Mine is miio2 this if I read that right is viomi_vacuum_v8

Ok… I take stock of the situation:
By installing this integration:

Everything works without errors. Also the map. The problem now is that there is no service: vacuum_goto.
How can I add it? Or is there another service that replaces it?

I have added the fix to the main repo, you can download the version from master branch or wait for a release.


it might be viomi_vacuum_v8.vacuum_goto instead.

No. There isn’t.
I found this: viomi_vacuum_v8.clean_point
But I haven’t tried it yet.