Dynamic zones definition / template support for predefined_selections
jacekpaszkowski opened this issue · comments
Description
Now predefined_selections
have to be defined in card definition but it would be great to use data from sensor/template.
I use ValetudoRE + valetudo mapper.
ValetudoRE can publish zones, spots data over mqtt, eg.:
{"spots":[{"name":"Kosz na śmieci","coordinates":[29499,21345]},{"name":"a","coordinates":[25112,19060]},{"name":"b","coordinates":[25125,27736]},{"name":"c","coordinates":[35415,27761]}],"zones":[{"name":"Hol","coordinates":[[28081,22729,29793,27673,2],[29810,23798,32431,25043,2]]},{"name":"Kuchnia","coordinates":[[27795,19119,29778,22968,2]]},{"name":"Pokój","coordinates":[[32364,23363,35356,27069,2]]},{"name":"Salon","coordinates":[[25122,19089,28597,25817,2]]},{"name":"Sypialnia","coordinates":[[32241,19709,35344,23172,2],[30571,19716,32383,23837,2]]},{"name":"Wszystkie","coordinates":[[25101,19066,35379,27690,1]]},{"name":"Łazienka","coordinates":[[30752,24961,32383,27494,2]]}],"rooms":[{"name":"Hol","id":17},{"name":"Kuchnia","id":18},{"name":"Pokój","id":21},{"name":"Salon","id":16},{"name":"Sypialnia","id":19},{"name":"Łazienka","id":20}],"updated":1676552488277}
Then I use automation to transform zones data and append additional properties:
[
{
"zones": [
[
28081,
22729,
29793,
27673
],
[
29810,
23798,
32431,
25043
]
],
"label": {
"text": "Hol",
"x": 28937,
"y": 24631
},
"icon": {
"name": "mdi:hanger",
"x": 28937,
"y": 25231
}
},
{
"zones": [
[
27795,
19119,
29778,
22968
]
],
"label": {
"text": "Kuchnia",
"x": 28786,
"y": 20473
},
"icon": {
"name": "mdi:food-fork-drink",
"x": 28786,
"y": 21073
}
},
{
"zones": [
[
32364,
23363,
35356,
27069
]
],
"label": {
"text": "Pokój",
"x": 33860,
"y": 24646
},
"icon": {
"name": "mdi:bed-empty",
"x": 33860,
"y": 25246
}
},
{
"zones": [
[
25122,
19089,
28597,
25817
]
],
"label": {
"text": "Salon",
"x": 26859,
"y": 21883
},
"icon": {
"name": "mdi:sofa",
"x": 26859,
"y": 22483
}
},
{
"zones": [
[
32241,
19709,
35344,
23172
],
[
30571,
19716,
32383,
23837
]
],
"label": {
"text": "Sypialnia",
"x": 33792,
"y": 20870
},
"icon": {
"name": "mdi:bed-queen",
"x": 33792,
"y": 21470
}
},
{
"zones": [
[
30752,
24961,
32383,
27494
]
],
"label": {
"text": "Łazienka",
"x": 31567,
"y": 25657
},
"icon": {
"name": "mdi:shower-head",
"x": 31567,
"y": 26257
}
}
]
Then using custom:config-template-card
i am able to inject predefined_selections
from my sensor but it doesn't work perfectly. Biggest issue is card flickering/blinking.
Solution
Is it possible to add template support to predefined_selections. It would allow to use data from vaccum.
Thank you for you hard work :)
Alternatives
No response
Context
No response
It is possible to use entities for vacuum_clean_zone_predefined
and vacuum_goto_predefined
at this moment, but they won't get names and will use default icons. Example config:
map_modes:
- template: vacuum_clean_zone_predefined
predefined_selections:
- zones: sensor.all_vacuum_zones
- zones: vacuum.some_vacuum.attributes.zones
- template: vacuum_goto_predefined
predefined_selections:
- zones: sensor.all_vacuum_points
- zones: vacuum.some_vacuum.attributes.points
Supported format for vacuum_clean_zone_predefined
template:
[[ 21485, 28767, 24236, 32131 ], [ 23217, 27379, 24216, 28737 ]]
Supported format for vacuum_goto_predefined
template:
[[ 21478, 27237 ], [ 23048, 27250 ], [ 23061, 25655 ], [ 21478, 25680 ]]
(spaces are not required)
Thank you. I see but unfortunately this doesn't fit my needs. I hope that in the future it will be possible to specify templates in a wider form :)
Or maybe it would be possible to extend vacuum_clean_zone_predefined
, vacuum_goto_predefined
and be able to specyfy zone in JSON format, just like for PREDEFINED_RECTANGLE
eg:
{
"zones": [
[
28081,
22729,
29793,
27673
],
[
29810,
23798,
32431,
25043
]
],
"label": {
"text": "Hol",
"x": 28937,
"y": 24631
},
"icon": {
"name": "mdi:hanger",
"x": 28937,
"y": 25231
}
}
@PiotrMachowski i have a question because i have differen bahavior using arrays directly and entering sensor name.
If i specify:
- zones: [[28081,22729,29793,27673],[29810,23798,32431,25043]]
label:
text: Hol
x: 28937
'y': 24631
icon:
name: mdi:hanger
x: 28937
'y': 25231
I get one zone in map as desired:
But if i do:
- zones: sensor.rockrobo_valetudo_zones_processed_hall
label:
text: Hol
x: 28937
'y': 24631
icon:
name: mdi:hanger
x: 28937
'y': 25231
where sensor.rockrobo_valetudo_zones_processed_hall
is:
Is there any option to specyfy zones as sensor and get one zone with two segments? Add mayby add additional label and icon config?
Thank You!
No, unfortunately it's not possible at this moment.
Are these predefined zones working with neato?
@HabelStefan Neato supports only cleaning based on room ID (vacuum_clean_segment
) - docs
Thank you for your quick answer, but when i try to get the coordinate, i only get 4 numbers and not 4 pairs of numbers.
@HabelStefan you have to create an outline, as described here