`undefined is not an object (evaluating 'i.id.toString')` when using `template: vacuum_goto_predefined`
wrobelda opened this issue · 4 comments
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
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
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
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
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.
Edit: Sorry, below comment seems duplicate of #662, see #662 (comment).
I can confirm a similar issue with vacuum_clean_zone_predefined
; it requires an id
while it's not mentioned in the documentation. Furthermore, it seems to try to interpret the value of id
as the zone coordinates.
Error: i.id is undefined
type: custom:xiaomi-vacuum-map-card
map_source:
camera: camera.valetudo_camera
calibration_source:
camera: true
entity: vacuum.valetudo_dreame
vacuum_platform: Hypfer/Valetudo
internal_variables:
topic: valetudo/dreame
map_modes:
- template: vacuum_clean_zone_predefined
predefined_selections:
- zones:
- - 3402
- 3009
- 3783
- 3172
icon:
name: mdi:silverware-fork-knife
x: 3580
'y': 3090
- template: vacuum_clean_zone
- template: vacuum_goto
map_locked: true
In the HA logs (when I add id: "1"
to the config to allow the widget to display):
Template variable warning: str object has no element 1 when rendering '{"topic":"valetudo/dreame/ZoneCleaningCapability/start/set","payload":"{\"zones\": [{%for s in ('[\"1\"]')|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\": 1}{%if not loop.last%},{%endif%}{%endfor%}]}"}'
Template variable warning: str object has no element 2 when rendering '{"topic":"valetudo/dreame/ZoneCleaningCapability/start/set","payload":"{\"zones\": [{%for s in ('[\"1\"]')|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\": 1}{%if not loop.last%},{%endif%}{%endfor%}]}"}'
Template variable warning: str object has no element 3 when rendering '{"topic":"valetudo/dreame/ZoneCleaningCapability/start/set","payload":"{\"zones\": [{%for s in ('[\"1\"]')|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\": 1}{%if not loop.last%},{%endif%}{%endfor%}]}"}'