PiotrMachowski / lovelace-xiaomi-vacuum-map-card

This card provides a user-friendly way to fully control map-based vacuums in Home Assistant. Supported brands include Xiaomi (Roborock/Viomi/Dreame/Roidmi/Valetudo/Valetudo RE), Neato, Wyze, Roomba, Ecovacs (and probably more).
MIT License
1.37k stars 244 forks source link

Add Roborock Core as a platform #691

Open Lash-L opened 7 months ago

Lash-L commented 7 months ago

Integration repository

https://www.home-assistant.io/integrations/roborock/

Supported features

Checklist

Vacuum entity/entities

n/a

Service calls

n/a

Other info

Creating this issue here to keep track of my work and ask questions. I plan to do the incorporation myself so I have left service calls and entities blank.

Roborock core holds the map in a image entity instead of a camera entity, so I got the calibration points from the map parser .calibration() and set up the following:

type: custom:xiaomi-vacuum-map-card
entity: vacuum.s7_roborock
map_source:
  image: image.s7_roborock_downstairs
calibration_source:
  calibration_points:
    - vacuum:
        x: 25500
        'y': 25500
      map:
        x: 240
        'y': 184
    - vacuum:
        x: 35500
        'y': 25500
      map:
        x: 440
        'y': 184
    - vacuum:
        x: 25500
        'y': 35500
      map:
        x: 240
        'y': -16

vacuum_platform: humbertogontijo/homeassistant-roborock

However, the image does not show up

Screenshot 2023-12-08 at 5 54 49 PM

Before I went any further I wanted to check with you that images are supported by the card.

PiotrMachowski commented 7 months ago

Before I went any further I wanted to check with you that images are supported by the card.

It should work, but you have to set it up using camera key:

map_source:
  camera: image.s7_roborock_downstairs

I suppose calibration points won't be added to the core, right?

Lash-L commented 7 months ago

Ah that did it - Guess I should have read the docs better.

I do plan to try to get calibration points added to core as an extra state attribute on the image entity, I think I'll be able to get that approved

PiotrMachowski commented 7 months ago

I think I'll be able to get that approved

In case of failure I think it won't be hard to inject appropriate code using a custom integration. Please include me in a potential PR regarding this feature

Lash-L commented 7 months ago

Please include me in a potential PR regarding this feature

Can do. Anything else that would be helpful for me to expose?

I have just started diving into your code, but one thing that is important with Roborock vacuums is that commands are map specific and room ids are not. So if I want to clean room id 12 on the downstairs map, if I click on that room to clean it, but I have the upstairs map selected as my current map, it will attempt to clean room id 12 upstairs.

Is there a means on the card to set the map you are interacting with as the current map?

PiotrMachowski commented 7 months ago

Anything else that would be helpful for me to expose?

roomssection would also be useful - it is used to automatically generate rooms config.

Is there a means on the card to set the map you are interacting with as the current map?

It is possible to add configs for multiple maps using additional_presets and make card automatically choose appropriate one using matching condition

More info e.g. here: https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/issues/248

dkirby-ms commented 6 months ago

Roborock core holds the map in a image entity instead of a camera entity, so I got the calibration points from the map parser .calibration() and set up the following:

Could you perhaps give more detail on how you are getting the map coordinates? I am using the new native Roborock integration. I have the image showing up but the calibration is off because I am not sure how to map the dock location to the image map.

PiotrMachowski commented 6 months ago

@dkirby-ms he modified the code of Roborock integration

mistergyle commented 3 months ago

is there any ongoing development on this issue? i would appreciate it!

Lash-L commented 3 months ago

is there any ongoing development on this issue? i would appreciate it!

I am unfortunately a bit blocked. Not much I can do at the moment and core devs have to make decisions.

jason-curtis commented 2 months ago

Is there a recommended workaround for generating calibration points at the moment? Docs point me towards https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor but I don't have a Xiaomi account as I've been using the Roborock app.

PiotrMachowski commented 2 months ago

You can use this integration instead: https://github.com/humbertogontijo/homeassistant-roborock

jason-curtis commented 2 months ago

I did just switch to the official integration because I was having issues with that one and was hoping this would be more stable. Is the humbertogontijo version preferred for the vacuum map card?

PiotrMachowski commented 2 months ago

@jason-curtis at this moment the official integration doesn't provide data that is necessary to use the map functionality in this card

Maximus97 commented 1 month ago

I as well very much look forward to this card supporting the official Roborock integration

Lash-L commented 1 month ago

@PiotrMachowski since our original plan failed. Would a service call work?

I.e you could call vacuum: send command with a service that is like get_map_card_info and we get all of the initial info you need like calibration points, room dimensions, etc? Then we could still use the image entity to update what the map looks like?

PiotrMachowski commented 1 month ago

@Lash-L I think service call should be ok, but I also thought about implementing a dedicated WS API method. The downside of this approach is that it probably won't be possible for users to use it manually.

It would also be nice to make it possible for the card to be notified that something has changed in the calibration (I think this happens quite often during map building). Can it be solved by generating an event when it happens?

carlos-48 commented 1 month ago

I got the calibration points from the map parser .calibration() and set up the following:

type: custom:xiaomi-vacuum-map-card
entity: vacuum.s7_roborock
map_source:
  image: image.s7_roborock_downstairs
calibration_source:
  calibration_points:
    - vacuum:
        x: 25500
        'y': 25500
      map:
        x: 240
        'y': 184
    - vacuum:
        x: 35500
        'y': 25500
      map:
        x: 440
        'y': 184
    - vacuum:
        x: 25500
        'y': 35500
      map:
        x: 240
        'y': -16

vacuum_platform: humbertogontijo/homeassistant-roborock

Hi! First of all, thanks for the integrations!

@Lash-L Could you better explain how to get the calibration points so users can do it in the mean time? I just moved from HACS integration to Core integration, and I can't find any documentation or tutorial about getting the calibration points from Core integration.

Lash-L commented 1 month ago

@Lash-L I think service call should be ok, but I also thought about implementing a dedicated WS API method. The downside of this approach is that it probably won't be possible for users to use it manually.

It would also be nice to make it possible for the card to be notified that something has changed in the calibration (I think this happens quite often during map building). Can it be solved by generating an event when it happens?

I think conceptually that's okay - i don't know if i really have time for it right now, whereas a service might be easier.

I could also cache the latest mapdata and the service could get the latest mapdata if you think that would be better?

@Lash-L Could you better explain how to get the calibration points so users can do it in the mean time? I just moved from HACS integration to Core integration, and I can't find any documentation or tutorial about getting the calibration points from Core integration.

@carlos-48 You can't. I modified things inside the actual code base in my development environment

PiotrMachowski commented 1 month ago

i don't know if i really have time for it right now, whereas a service might be easier.

Don't worry about it, at this moment I'm rewriting Map Extractor, then I'll have to adjust the card, so you have plenty of time.

I think service call should be enough for my purposes