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.38k stars 247 forks source link

`undefined is not an object (evaluating 'i.id.toString')` when using `template: vacuum_goto_predefined` #724

Open wrobelda opened 4 months ago

wrobelda commented 4 months ago

Checklist

The problem

I am configuring a Valetudo Map Card and everything seems to work fine, including the imported segments. However, when adding a Predefined Goto, using the example from the manual, I am getting a undefined is not an object (evaluating 'i.id.toString') error. This is because of a missing id attribute, which the manual does not actually mention. However, after adding said attribute, I am getting no reaction from the robot itself. Again, the predefined rooms work just fine.

Relevant config piece:

  - template: vacuum_goto_predefined
    predefined_selections:
      - id: 1
        position:
          - 2638
          - 2533
        icon:
          name: mdi:delete-empty
          x: 2638
          'y': 2533
        label:
          text: Emptying
          x: 2638
          'y': 2533
          offset_y: 35

The service call for the Goto location defined as above is:

{
  "domain": "mqtt",
  "service": "publish",
  "serviceData": {
    "topic": "valetudo/BlindHarmlessChimpanzee/GoToLocationCapability/go/set",
    "payload": "{ \"coordinates\": { \"x\": \"\", \"y\": \"\" } }"
  }
}

As you can notice, the coordinates are empty. I am not sure if this is related to the id thing or is a different issue altogether. Also note that while I am passing the - position: [ 28006, 28036 ] in YAML editor, its format gets changed to what you see above upon saving.

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

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

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

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

Safari

What version of Home Assistant do you use?

2024.3.3

What type of installation are you running?

Home Assistant OS

Card's configuration

type: custom:xiaomi-vacuum-map-card
entity: vacuum.valetudo_blindharmlesschimpanzee
internal_variables:
  topic: valetudo/BlindHarmlessChimpanzee
vacuum_platform: Hypfer/Valetudo
map_source:
  camera: camera.valetudo_s5_blindharmlesschimpanzee_camera
calibration_source:
  camera: true
map_modes:
  - template: vacuum_clean_zone
  - template: vacuum_goto
  - template: vacuum_goto_predefined
    predefined_selections:
      - id: '1'
        position:
          - 2638
          - 2533
        icon:
          name: mdi:delete-empty
          x: 2638
          'y': 2533
        label:
          text: Emptying
          x: 2638
          'y': 2533
          offset_y: 35
  - template: vacuum_clean_segment
    predefined_selections:
      - id: '16'
        icon:
          name: mdi:broom
          x: 2675
          'y': 1752
        label:
          text: Kitechen
          x: 2675
          'y': 1752
          offset_y: 35
        outline:
          - - 2555
            - 1520
          - - 2795
            - 1520
          - - 2795
            - 1985
          - - 2555
            - 1985
      - id: '17'
        icon:
          name: mdi:broom
          x: 2967
          'y': 1697
        label:
          text: Bedroom
          x: 2967
          'y': 1697
          offset_y: 35
        outline:
          - - 2820
            - 1535
          - - 3115
            - 1535
          - - 3115
            - 1860
          - - 2820
            - 1860
      - id: '18'
        icon:
          name: mdi:broom
          x: 3067
          'y': 2007
        label:
          text: Entrance
          x: 3067
          'y': 2007
          offset_y: 35
        outline:
          - - 3025
            - 1880
          - - 3110
            - 1880
          - - 3110
            - 2135
          - - 3025
            - 2135
      - id: '19'
        icon:
          name: mdi:broom
          x: 2625
          'y': 2482
        label:
          text: Living room
          x: 2625
          'y': 2482
          offset_y: 35
        outline:
          - - 2190
            - 2260
          - - 3060
            - 2260
          - - 3060
            - 2705
          - - 2190
            - 2705
      - id: '20'
        icon:
          name: mdi:broom
          x: 2890
          'y': 2062
        label:
          text: Hallway
          x: 2890
          'y': 2062
          offset_y: 35
        outline:
          - - 2760
            - 1865
          - - 3020
            - 1865
          - - 3020
            - 2260
          - - 2760
            - 2260

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

No response

Additional information

No response

wrobelda commented 4 months ago

The Valetudo RE manual is equally confusing: there's id attribute, but the position one is missing: https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/blob/master/docs/templates/rand256ValetudoRe.md#going-to-a-predefined-point-vacuum_goto_predefined

PiotrMachowski commented 4 months ago

Use the following config:

  - template: vacuum_goto_predefined
    selection_type: PREDEFINED_POINT
    predefined_selections:
      - id: 1
        position:
          - 2638
          - 2533
        icon:
          name: mdi:delete-empty
          x: 2638
          'y': 2533
        label:
          text: Emptying
          x: 2638
          'y': 2533
          offset_y: 35
wrobelda commented 4 months ago

Still no go. The service call now is:

{
  "domain": "mqtt",
  "service": "publish",
  "serviceData": {
    "topic": "valetudo/BlindHarmlessChimpanzee/GoToLocationCapability/go/set",
    "payload": "{ \"coordinates\": { \"x\": \"2638\", \"y\": \"2533\" } }"
  }
}

Comparing it to a "Pin & Go" call, the only difference is that the coordinates are sent as strings vs integers in the latter.