Hypfer / Valetudo

Cloud replacement for vacuum robots enabling local-only operation
https://valetudo.cloud
Apache License 2.0
6.39k stars 388 forks source link

Clean segments by name. #1635

Closed deafloo closed 1 year ago

deafloo commented 1 year ago

Type of change

Type A:

Type B:

Description (Type A)

Over time, some segment borders blur into each other and I have to slice and combine those segments for crisp room separation. When I do this, the segment name gets deleted and the IDs change. I can rename the segment without a problem, but the IDs get messed up and my MQTT broker needs them. It would be nice to send commands by room name instead of room ID.

deafloo commented 1 year ago

I have not tested or even compiled that code. Can someone with an expendable vacuum test and confirm it? Mine is kind of 'systemically relevant'

Hypfer commented 1 year ago

It would be nice to send commands by room name instead of room ID.

The way it works now is not like that by accident but on purpose.

Only IDs are unique and thus only IDs can serve as an identifier in an API. Names could be anything. There could be duplicates or just no names at all.

As the Name to ID mapping is published to MQTT, whatever calls the segment cleanup via MQTT should use that information to fetch the correct ID by name and provide proper feedback to the user if there is no such segment.

Over time, some segment borders blur into each other and I have to slice and combine those segments for crisp room separation.

Is it a dreame? If yes then consider updating it to the latest firmware as dreame fixed that degrading segment issue a while ago.

deafloo commented 1 year ago

Okay I solved it that way. Just in case someone is interested how to do it, here is my home assistant template based on the Advanced Services section from the Valetudo homepage:

service: mqtt.publish
data:
  topic: valetudo/robot/MapSegmentationCapability/clean/set
  payload_template: '{"action": "start_segment_action", "segment_ids": [{% for attr in states.sensor.valetudo_vacuumName_map_segments.attributes if is_number(attr)%}{% if state_attr("sensor.valetudo_vacuumName_map_segments", attr) == "segmentName" %}{{ attr }}{% endif %}{% endfor %}], "iterations": 1, "customOrder": true}'

Just replace vacuumName and segmentName accordingly. Please be aware that it can only trigger one room at a time and that there are no fallback routines if the room does not exist.

@Hypfer Yes, it's a D9 but I am already on the latest FW