Skip to content

Instantly share code, notes, and snippets.

@machinekoder
Last active June 14, 2023 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save machinekoder/cd05f8865399e7dda7e44c78aebe89a3 to your computer and use it in GitHub Desktop.
Save machinekoder/cd05f8865399e7dda7e44c78aebe89a3 to your computer and use it in GitHub Desktop.
Valetudo MQTT Map Segment issue

Issue

According to https://valetudo.cloud/pages/integrations/mqtt.html#mapsegmentssegments map segment ids should be reported on the topic <TOPIC PREFIX>/<IDENTIFIER>/MapData/segments.

This works well if "Provide map data" is checked in the Valetudo settings and this in line with the description in the docs.

However, when "Provide map data" is unchecked an empty JSON object is published to that topic. This undefined or at least undocumented behavior. Citing from the documentation This handle groups access to map data. It is only enabled if provideMapData is enabled in the MQTT config.

Note that <TOPIC PREFIX>/<IDENTIFIER>/MapData/map-data is still retained in this case if it was previously published.

UPDATE: When pressing "Save Configuration" in the UI switching "Provide map data" to "On" there is a ~30s delay until the segments are published on the topic. When switching from "On" to "Off" state, the message is received almost instantly. This can lead to perception of an intermittend issue if the user doesn't wait long enough for the message to be received before switching the setting back.

Excpected behavior

Nothing is published on <TOPIC PREFIX>/<IDENTIFIER>/MapData/segments if "Provide map data" is unchecked.

Suggested Fix

Keep segment ids topic published with content even if "Provide map data" is unchecked and update the documentation accordingly. This is useful for using the MapSegmentationCapability https://valetudo.cloud/pages/integrations/mqtt.html#segmentcleaningmapsegmentationcapability.

Additional Ideas for Discussion

  1. To keep consistency with the HTTP API it would be logical to publish the topic also in the <TOPIC PREFIX>/<IDENTIFIER>/MapSegmentationCapability/segments topic.
  2. Some MQTT clients allow splitting JSON objects into subtopics, e.g. {"foo": 2, "bar": 3} on topic bla/bli top bla/bli/foo and bla/bli/bar. Therefore, reversing the map segment object key/value order could be useful e.g. {"office": 2, "kitchen": 3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment