Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hypfer/Valetudo and vacuum_clean_zone_predefined are completelly broken #662

Open
3 tasks done
erkexzcx opened this issue Sep 29, 2023 · 5 comments
Open
3 tasks done
Assignees
Labels
bug Something isn't working

Comments

@erkexzcx
Copy link

erkexzcx commented Sep 29, 2023

Checklist

  • I have updated the card to the latest version available
  • I have cleared the cache of my browser
  • I have checked if the problem is already reported

The problem

Basically this is what example says (source):

      - zones: [[ 27782, 27563, 29678, 29369 ]]
        label:
          text: "Kitchen"
          x: 28760
          y: 28403
          offset_y: 35
        icon:
          name: "mdi:pot-mix"
          x: 28760
          y: 28403

Here is what I am getting:

image

Okey, ID is missing, let's add it:

      - id: "helloworld"
        zones: [[ 27782, 27563, 29678, 29369 ]]
        label:
          text: "Kitchen"
          x: 28760
          y: 28403
          offset_y: 35
        icon:
          name: "mdi:pot-mix"
          x: 28760
          y: 28403

Now it looks OK. Let's run it - nothing happens. Let's look at MQTT logs in Valetudo:

MQTT: Error while handling valetudo/rockrobo/ZoneCleaningCapability/start/set {
  payload: '{"zones": [{ "points": {"pA": { "x": h, "y": e }, "pB": { "x": l, "y": e }, "pC": { "x": l, "y": l }, "pD": { "x": h, "y": l } }, "iterations": 1}]}',

hmmm, h... e.. these are not coordinates! Let's see if we can convert template to manual configuration:

map_modes:
  - name: Zones list
    icon: mdi:floor-plan
    run_immediately: false
    coordinates_rounding: true
    coordinates_to_meters_divider: 1000
    selection_type: ROOM
    max_selections: 999
    repeats_type: EXTERNAL
    max_repeats: 3
    service_call_schema:
      service: mqtt.publish
      evaluate_data_as_template: true
      service_data:
        topic: '[[topic]]/ZoneCleaningCapability/start/set'
        payload: >-
          {"zones": [{%for s in ('[[selection]]')|from_json %}{ "points": {"pA":
          { "x": {{s[0]}}, "y": {{s[1]}} }, "pB": { "x": {{s[2]}}, "y": {{s[1]}}
          }, "pC": { "x": {{s[2]}}, "y": {{s[3]}} }, "pD": { "x": {{s[0]}}, "y":
          {{s[3]}} } }, "iterations": [[repeats]]}{%if not
          loop.last%},{%endif%}{%endfor%}]}
    predefined_selections:
    ....
    ....
    ....

But wait! Let's look into {%for s in ('[[selection]]')|from_json %} part. It uses '[[selection]]' and generates coordinates accordingly. Let's simply update payload to this:

        payload: >-
          '[[selection]]'

Let's run again and this time it's quite interesting result in MQTT logs in Valetudo 😄

MQTT: Error while handling valetudo/rockrobo/ZoneCleaningCapability/start/set {
  payload: `'["helloworld"]'`,

How is this even supposed to work? Looks like this card is iterating ID string rather than coordinates.

I am not certainly sure, but it worked a week ago or something. I did not update this card, no idea how it ended up working like this.

What version of a card has described problem?

v2.2.2

What was the last working version card?

No response

What vacuum model do you have problems with?

roborock.vacuum.s5

Which integration do you use to control your vacuum (link)?

hypferValetudo over MQTT (standard configuration)

What browser (browsers/apps) does have this problem?

Firefox

What version of Home Assistant do you use?

Home Assistant 2023.9.3; Frontend 20230911.0 - latest

What type of installation are you running?

Home Assistant Container

Card's configuration

type: custom:xiaomi-vacuum-map-card
map_source:
  camera: camera.rockrobo_rendered_map
calibration_source:
  entity: sensor.rockrobo_calibration_data
entity: vacuum.valetudo_rockrobo
vacuum_platform: Hypfer/Valetudo
internal_variables:
  topic: valetudo/rockrobo
map_modes:
  - template: vacuum_clean_zone_predefined
    predefined_selections:
      - id: Entrance
        outline: [[2185,2975],[2310,2975],[2310,3090],[2185,3090]]
        label:
          text: Entrance
          x: 2247.5
          y: 3032.5
          offset_y: 28
        icon:
          name: mdi:door
          x: 2247.5
          y: 3032.5
  - template: vacuum_goto
  - template: vacuum_clean_zone
map_locked: true
two_finger_pan: false

Javascript errors shown in the browser's console (if applicable)

No errors

Additional information

I've developed a new mapper application for Valetudo: https://github.com/erkexzcx/valetudopng

I am currently using it. Considering that Ping & Go works like a charm, I believe my application has no impact on this and issue lies somewhere else...

@erkexzcx erkexzcx added the bug Something isn't working label Sep 29, 2023
@PiotrMachowski
Copy link
Owner

PiotrMachowski commented Sep 29, 2023

Yup, you are correct. It seems that I have not fully finished this section of configuration.

Check if this config works:

type: custom:xiaomi-vacuum-map-card
map_source:
  camera: camera.rockrobo_rendered_map
calibration_source:
  entity: sensor.rockrobo_calibration_data
entity: vacuum.valetudo_rockrobo
vacuum_platform: Hypfer/Valetudo
internal_variables:
  topic: valetudo/rockrobo
map_modes:
  - template: vacuum_clean_zone_predefined
    selection_type: PREDEFINED_RECTANGLE
    coordinates_rounding: true
    coordinates_to_meters_divider: 100
    max_selections: 5
    predefined_selections:
      - zones: [[2185,2975,2310,3090]]
        label:
          text: Entrance
          x: 2247.5
          y: 3032.5
          offset_y: 28
        icon:
          name: mdi:door
          x: 2247.5
          y: 3032.5
  - template: vacuum_goto
  - template: vacuum_clean_zone
map_locked: true
two_finger_pan: false

@erkexzcx
Copy link
Author

erkexzcx commented Sep 30, 2023

Yes, this one does work:

map_modes:
  - template: vacuum_clean_zone_predefined
    selection_type: PREDEFINED_RECTANGLE
    predefined_selections:
      - zones:
          - - 2185
            - 2975
            - 2310
            - 3090
        label:
          text: Entrance
          x: 2247.5
          'y': 3032.5
          offset_y: 28
        icon:
          name: mdi:door
          x: 2247.5
          'y': 3032.5

Thanks a lot!

@PiotrMachowski
Copy link
Owner

Great 👍 I'll adjust it

@erkexzcx
Copy link
Author

erkexzcx commented Sep 30, 2023

@PiotrMachowski
Copy link
Owner

I've seen this thread, good job 👍 I'll adjust docs - Valetudo Map Camera has already been added there, I'll add your project as well and remove ICBINV.

By the way, you might consider creating HA addon as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants