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.47k stars 252 forks source link

I would love seeing Valetudo support in a Future release #375

Closed PalmTamino closed 2 years ago

PalmTamino commented 2 years ago

Description

Valetudo is a standalone binary, which runs on rooted Vacuums of the Xiaomi ecosystem and aims to enable the user to operate the robot vacuum without any Cloud Connection whatsoever.

https://valetudo.cloud/

Solution

https://valetudo.cloud/

Alternatives

No response

Context

No response

PiotrMachowski commented 2 years ago

Does it support to cleaning by coordinates? Can you provide attributes of vacuum entity?

PalmTamino commented 2 years ago

grafik Do you mean this?

PiotrMachowski commented 2 years ago

yup 👍

PiotrMachowski commented 2 years ago

Are these entities created by mqtt autodiscovery?

PalmTamino commented 2 years ago

Are these entities created by mqtt autodiscovery?

Yeah, i think so

davidrustingha commented 2 years ago

I second this! I initially rooted my vacuum with Valetudo RE so it wont be able to reach china, but a couple of days ago I reset it so I can make use of this awesome card you created!

If you need some information, I have two Xiaomi V1 vacuum robots which I can easily root with Valetudo RE again.

PiotrMachowski commented 2 years ago

@davidrustingha it's already possible to use it with Valetudo RE by manual configuration: #342

Original Valetudo should be doable as well

wwebers commented 2 years ago

Well, direct support for the original Valetudo firmware would be great. Simply as Valetudo RE doesn't seem to get actively mainained.

PiotrMachowski commented 2 years ago

@wwebers it would really help me if you could send me examples of service calls for Valetudo ;)

wwebers commented 2 years ago

@PiotrMachowski I'll look into it. For some reason the communication with the "camera" topic doesn't work, which works perfectly fine with the orginal Valetudo card.

PiotrMachowski commented 2 years ago

@wwebers any progress here? I would like to release v2.10.0 soon

wwebers commented 2 years ago

@PiotrMachowski Sorry for late response. I updated HA today and my issue is that it complains about the "camera" source. I already installed "Lovelace Valetudo Map Card" via HACS. Still, it complains with a "Invalid calibration" error message. Am using the Valetudo RE platform. Have not checked if the MQTT servcie API is different for "Valetudo" and "Valetudo RE". But I can however send commands.

PiotrMachowski commented 2 years ago

Camera source provided by Valetudo is practically useless for this card as it is not a real camera, but just a facade that is designed to work with "Lovelace Valetudo Map Card" - image is just a placeholder and map is rendered by the card from raw data. You have to install I can't believe it's not Valetudo to make it work with my card (calibration part will still be missing though).

Have not checked if the MQTT servcie API is different for "Valetudo" and "Valetudo RE". But I can however send commands.

Which commands?

wwebers commented 2 years ago

@PiotrMachowski Ah! That explains things! My mistake. Thank you. I mean those MQTT publish commands used by the "Valetudo RE" template: https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/blob/master/src/model/generators/platform_templates/rand256_valetudo_re.json

PiotrMachowski commented 2 years ago

Have you tried them from my card or directly?

Can you try if version from the latest dev build works for you? To install it you have to manually copy js file downloaded from the artifact.

wwebers commented 2 years ago

Am looking directly into the source code of "Valetudo": https://github.com/Hypfer/Valetudo/tree/master/backend/lib/mqtt

Doesn't look like the original "Valetudo" has support for the "custom_command" used by the "Valetude RE" template:

rand256_valetudo_re.json

PiotrMachowski commented 2 years ago

Well, in documentation it looks completely different: https://valetudo.cloud/pages/integrations/home-assistant-integration https://valetudo.cloud/pages/integrations/mqtt.html#gotolocationgo https://valetudo.cloud/pages/integrations/mqtt.html#segmentcleaningmapsegmentationcapability

wwebers commented 2 years ago

@PiotrMachowski What I meant was that the API is different in the original "Valetudo". "Valetudo RE" uses a specific "custom_command", while the original doesn't. The functionality as such exists. So, what's needed is a different template with support for the original "Valetudo" API. Will see if I find some time to create one and send you a PR.

PiotrMachowski commented 2 years ago

You don't have to create a whole template, just example service calls would be enough

wwebers commented 2 years ago

:ok_hand:

PiotrMachowski commented 2 years ago

Just one more question: do you have the same entities as @PalmTamino here, created by MQTT autodiscovery?

wwebers commented 2 years ago

Pretty much. Have some more as I'm using a Roborock S5 max with a watertank. So, some different capabilities...

PiotrMachowski commented 2 years ago

@wwebers One more thing that would massively help me in development. Could you provide me data about entities created by Valetudo? Steps to follow:

  1. Open your main dashboard
  2. Open browser's dev tools (with F12 button)
  3. Open console
  4. Paste following code in the console:
    getDeviceData = async (entity) => {
        const hass = document.querySelector("home-assistant").hass;
        const vacuumDeviceId = (
            await hass.callWS({
                type: "config/entity_registry/get",
                entity_id: entity,
            })
        )["device_id"];
        const vacuumSensors = (
            await hass.callWS({
                type: "config/entity_registry/list",
            })
        ).filter(e => e.device_id === vacuumDeviceId);
        Promise.all(
            vacuumSensors.map(vs =>
                hass.callWS({
                    type: "config/entity_registry/get",
                    entity_id: vs.entity_id,
                }),
            ),
        ).then(v => console.log(v));
    }
  5. Retrieve entities related to the vacuum entity using following comand:
    getDeviceData("vacuum.example_valetudo_vacuum");
  6. Two entries should be printed, please copy content of the second one (click with right mouse button on it and choose "Copy object" option)
  7. Send me copied values to piotr.machowski.dev [at] gmail.com
PiotrMachowski commented 2 years ago

@wwebers Can you check if version from this build works with your vacuum?

wwebers commented 2 years ago

@PiotrMachowski I tried, but I cannot configure "Hypfer/Valetudo" as the new vacuum platform. Get an "Invalid vacuum platform" error.

PiotrMachowski commented 2 years ago

@wwebers you probably have caching problem. I assume you have installed it using HACS. In this case you have to remove gzip file and add ?v=2.10.0-beta to URL in resources.

wwebers commented 2 years ago

@PiotrMachowski Thanks, that did the job. Will test it today.

wwebers commented 2 years ago

@PiotrMachowski Tried to test your latest dev-build, but am struggling with ICantBelieveItsNotValetudo to make it working within my docker-compose env running on my RPi4. Problem is that ICBINV is not up to date when it comes to its dependencies (mainly the switch to napi-rs/canvas 0.1.21 and its dependency to ld-linux-armhf.so.3). Not to mentioned its use of NPM 8 exposing several security holes.... Will have to find a way to update this thing first (or even get rid of it...).

PiotrMachowski commented 2 years ago

@wwebers you can check if it works without actual image from ICantBelieveItsNotValetudo, as it doesn't change anything in card's functionality :)

PiotrMachowski commented 2 years ago

@wwebers any progress on this topic?

mihsu81 commented 2 years ago

@PiotrMachowski The basic functionality seems to work with the "dev" version of the card and selecting the platform Hypfer/Valetudo. For more functionality we'd need to find a way to collect calibration data from the map. Getting the map coordinates is very easy since Valetudo 2022.05.1, but I couldn't find a way to get the vacuum coordinates. Thank you for your great work.

wwebers commented 2 years ago

Same here. Tested without ICBINV and the basic function seem to work. But as far as I understand so have you opened only one service in your template? But maybe I misunderstood something.

PiotrMachowski commented 2 years ago

@mihsu81

For more functionality we'd need to find a way to collect calibration data from the map.

If you want to use just room cleaning you might be able to get away with "fake" calibration:

calibration_source:
  identity: true

@wwebers yes, I have added just room cleaning. Are there any other services that I can add?

documentation of Valetudo platform on dev branch

mihsu81 commented 2 years ago

@PiotrMachowski Based on https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/blob/dev/docs/templates/hypferValetudo.md I added a predefined selection (for the yellow room marked with a red ouline where the charger is located in the below screenshot) but it doesn't seem to work. The coordinates are taken from Valetudo itself by making a selection and long-pressing on the Clean button (second screenshot).

I was expecting to see an outline of the map which I could select and start cleaning.

I've also attached the json file with the map definition from Valetudo's Swagger UI. response_1661532827644.zip

type: custom:xiaomi-vacuum-map-card
entity: vacuum.valetudo_roborock_vacuum
vacuum_platform: Hypfer/Valetudo
map_source:
  camera: camera.roborock_vacuum_rendered_map
two_finger_pan: true
calibration_source:
  identity: true
map_modes:
  - template: vacuum_clean_segment
    variables:
      topic: valetudo/ROBOROCK-VACUUM
    predefined_selections:
      - id: '17'
        outline:
          - - 2515
            - 2529
          - - 3005
            - 2529
          - - 3005
            - 2909
          - - 2515
            - 2909
        label:
          text: Living Room
          x: 2745
          'y': 2663
          offset_y: 0
        icon:
          name: mdi:sofa-outline
          x: 2745
          'y': 2663

image

image

PiotrMachowski commented 2 years ago

@mihsu81 vacuum_clean_segment sends only a service call with id. You can check out service call using button in UI editor.

When you use identity calibration you have to use coordinates from the image, not vacuum. Here you have a guide to retrieve them: https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/blob/dev/docs/templates/setup.md

dimmuboy commented 2 years ago

Just for info, Valetudo RE have new version with some useable features for us I think. https://github.com/rand256/valetudo/releases/tag/0.10.8

PiotrMachowski commented 2 years ago

@dimmuboy thanks for info, I will definitely add it. Related issue: #434

PiotrMachowski commented 2 years ago

Update: I have added support for cleaning free-drawn zones and going to point.

wwebers commented 2 years ago

Awesome. Thanks for your work. Will test it as soon as I can.


From: Piotr Machowski @.> Sent: Sunday, August 28, 2022 2:47:40 AM To: PiotrMachowski/lovelace-xiaomi-vacuum-map-card @.> Cc: wwebers @.>; Mention @.> Subject: Re: [PiotrMachowski/lovelace-xiaomi-vacuum-map-card] I would love seeing Valetudo support in a Future release (Issue #375)

Update: I have added support for cleaning free-drawn zones and going to point.

— Reply to this email directly, view it on GitHubhttps://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/issues/375#issuecomment-1229348290, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABO2BHA7JUDNRCHXO2MGCF3V3KZKZANCNFSM5RZDEDKA. You are receiving this because you were mentioned.Message ID: @.***>

PiotrMachowski commented 2 years ago

@wwebers do you think you will be able to test it today? I'd like to finally release a new version 😃

Keep in mind that you will have to calibrate the card manually to make it work. Does Valetudo map change during cleaning?

Calibration guide

PiotrMachowski commented 2 years ago

I have created a feature request in I can't believe it's not Valetudo to include calibration points in its MQTT API.

PiotrMachowski commented 2 years ago

I think I will create a release today/tomorrow and fix possible problems in the future.

PiotrMachowski commented 2 years ago

Feature added in v2.1.0

PiotrMachowski commented 2 years ago

Unfortunately I can't believe it's not Valetudo seems to be a deprecated solution, so calibration points won't be added. More info here

wwebers commented 2 years ago

Unfortunately I can't believe it's not Valetudo seems to be a deprecated solution, so calibration points won't be added. More info here

Yes, I saw this as well. It because of that didn't test so deeply. We need a better solution than ICBINV. More integrated in the Valetudo firmware.

PiotrMachowski commented 2 years ago

At this moment Valetudo RE with Valetudo mapper should work better with my card, maybe something will change in the future.

Hypfer commented 2 years ago

I'd like to once again note that this card and Valetudo - while both dealing with vacuum robots - fill very different niches. While not being completely incompatible, they aren't and also won't be 100% compatible either.

You can use one with the other the same way you can use a flat-head screwdriver to drive triangular screws. It sorta works but it's definitely not the way the manufacturer intended nor won't there be any unexpected obstacles, side-effects etc.

We need a better solution than ICBINV. More integrated in the Valetudo firmware.

The better solution than ICBINV that is more integrated into Valetudo (which is NOT a firmware) is to use the official Valetudo lovelace card that is specifically made for Valetudo.

wwebers commented 2 years ago

@Hypfer No offense. Even though Valetudo is not part of the manufacturer's firmware. It's still part of the software we flash onto the robots controller board. From the consumers perspektiv this would make it a part of the firmware.

To the outside world Valetudo abstracts from the OEM specific parts, which is cool. However, I would love better support in HA for it as well. I'm using the official card and miss several features there. Maybe one should spent some effort in that instead?

Hypfer commented 2 years ago

I'm using the official card and miss several features there.

Yeah it's not feature-complete yet that is true and I'm aware of that.

PiotrMachowski commented 2 years ago

@Hypfer I don't want to argue, but actually I don't see any reason why my card would not be compatible with Valetudo (leaving aside retrieving map image), as it just utilizes a part of exposed MQTT API. Isn't this the whole point of having an API?