Skip to content

Commit 77a8edf

Browse files
committed
docs: Fix and update MQTT docs
1 parent 0a91b5b commit 77a8edf

4 files changed

Lines changed: 37 additions & 18 deletions

File tree

backend/lib/mqtt/capabilities/MapSegmentationCapabilityMqttHandle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class MapSegmentationCapabilityMqttHandle extends CapabilityMqttHandle {
5858
helpText: "This handle accepts a JSON object identical to the one used by the REST API.\n\n" +
5959
"Simply use the Map in the Valetudo UI, select the desired segments and iterations and then long-press the button that would start the action.<br/>\n" +
6060
"This will open a modal containing the copy-pasteable payload.\n\n" +
61+
"\n**Note:** Not all firmwares support customOrder.\n\n" +
6162
"Sample payload:\n\n" +
6263
"```json\n" +
6364
JSON.stringify({

backend/lib/robots/mock/capabilities/MockOperationModeControlCapability.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class MockOperationModeControlCapability extends OperationModeControlCapability
1515
let presets = [
1616
new ValetudoSelectionPreset({name: entities.state.attributes.PresetSelectionStateAttribute.MODE.MOP, value: 0}),
1717
new ValetudoSelectionPreset({name: entities.state.attributes.PresetSelectionStateAttribute.MODE.VACUUM, value: 1}),
18-
new ValetudoSelectionPreset({name: entities.state.attributes.PresetSelectionStateAttribute.MODE.VACUUM_AND_MOP, value: 2})
18+
new ValetudoSelectionPreset({name: entities.state.attributes.PresetSelectionStateAttribute.MODE.VACUUM_AND_MOP, value: 2}),
19+
new ValetudoSelectionPreset({name: entities.state.attributes.PresetSelectionStateAttribute.MODE.VACUUM_THEN_MOP, value: 3}),
1920
];
2021
super({
2122
robot: options.robot,

docs/_pages/integrations/mqtt.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ settings page.
144144
- [Obstacle Avoidance (`switch.mqtt`)](#obstacleavoidanceenabled)
145145
- [Pet Obstacle Avoidance (`switch.mqtt`)](#petobstacleavoidanceenabled)
146146
- [Play locate sound (`button.mqtt`)](#locatelocate)
147-
- [Reset <CONSUMABLE-MINUTES> Consumable (`button.mqtt`)](#resettheconsumableconsumable-minutesreset)
148-
- [Reset <CONSUMABLE-PERCENT> Consumable (`button.mqtt`)](#resettheconsumableconsumable-percentreset)
147+
- [Reset &lt;CONSUMABLE-MINUTES&gt; Consumable (`button.mqtt`)](#resettheconsumableconsumable-minutesreset)
148+
- [Reset &lt;CONSUMABLE-PERCENT&gt; Consumable (`button.mqtt`)](#resettheconsumableconsumable-percentreset)
149149
- [Speaker volume (`number.mqtt`)](#speakervolumevalue)
150150
- [Status Flag (`sensor.mqtt`)](#statusflagflag)
151151
- [Total Statistics Area (`sensor.mqtt`)](#totalstatisticsareaarea)
@@ -324,7 +324,7 @@ Home Assistant components controlled by this property:
324324

325325
Home Assistant components controlled by this property:
326326

327-
- Reset <CONSUMABLE-MINUTES> Consumable ([`button.mqtt`](https://www.home-assistant.io/integrations/button.mqtt/))
327+
- Reset &lt;CONSUMABLE-MINUTES&gt; Consumable ([`button.mqtt`](https://www.home-assistant.io/integrations/button.mqtt/))
328328

329329

330330

@@ -359,7 +359,7 @@ Home Assistant components controlled by this property:
359359

360360
Home Assistant components controlled by this property:
361361

362-
- Reset <CONSUMABLE-PERCENT> Consumable ([`button.mqtt`](https://www.home-assistant.io/integrations/button.mqtt/))
362+
- Reset &lt;CONSUMABLE-PERCENT&gt; Consumable ([`button.mqtt`](https://www.home-assistant.io/integrations/button.mqtt/))
363363

364364

365365

@@ -558,6 +558,9 @@ This handle accepts a JSON object identical to the one used by the REST API.
558558
Simply use the Map in the Valetudo UI, select the desired segments and iterations and then long-press the button that would start the action.<br/>
559559
This will open a modal containing the copy-pasteable payload.
560560

561+
562+
**Note:** Not all firmwares support customOrder.
563+
561564
Sample payload:
562565

563566
```json
@@ -624,7 +627,7 @@ This handle allows setting the mode. It accepts the preset payloads specified in
624627

625628
- Read topic: `<TOPIC PREFIX>/<IDENTIFIER>/OperationModeControlCapability/preset`
626629
- Set topic: `<TOPIC PREFIX>/<IDENTIFIER>/OperationModeControlCapability/preset/set`
627-
- Data type: [enum](https://homieiot.github.io/specification/#enum) (allowed payloads: `mop`, `vacuum`, `vacuum_and_mop`)
630+
- Data type: [enum](https://homieiot.github.io/specification/#enum) (allowed payloads: `mop`, `vacuum`, `vacuum_and_mop`, `vacuum_then_mop`)
628631

629632
{% include alert.html type="warning" content="Some information contained in this document may not be exactly what is sent or expected by actual robots, since different vendors have different implementations. Refer to the table below.
630633

util/generate_mqtt_docs.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -323,16 +323,24 @@ class FakeMqttController extends MqttController {
323323
this.addedConsumables.push(handle.friendlyName);
324324
}
325325

326-
let title = handle.friendlyName;
326+
const baseTitle = handle.friendlyName;
327+
let titleSuffix = "";
328+
327329
if (handle instanceof CapabilityMqttHandle) {
328-
title += ` (\`${handle.capability.getType()}\`)`;
330+
titleSuffix = ` (\`${handle.capability.getType()}\`)`;
329331
} else if (handle instanceof RobotStateNodeMqttHandle) {
330-
title += ` (\`${handle.getInterestingStatusAttributes()[0].attributeClass}\`)`;
332+
titleSuffix = ` (\`${handle.getInterestingStatusAttributes()[0].attributeClass}\`)`;
331333
} else if (handle instanceof PropertyMqttHandle) {
332-
title += ` (\`${handle.topicName}\`)`;
334+
titleSuffix = ` (\`${handle.topicName}\`)`;
333335
}
334-
const anchor = this.generateAnchor(title);
335-
markdown += `${"#".repeat(markdownLevel)} ${title} <a id="${anchor}" />` + "\n\n";
336+
337+
const unescapedFullTitle = baseTitle + titleSuffix;
338+
const anchor = this.generateAnchor(unescapedFullTitle);
339+
340+
const escapedBaseTitle = baseTitle.replace(/</g, "&lt;").replace(/>/g, "&gt;");
341+
const finalDisplayTitle = escapedBaseTitle + titleSuffix;
342+
343+
markdown += `${"#".repeat(markdownLevel)} ${finalDisplayTitle} <a id="${anchor}" />` + "\n\n";
336344

337345
let homieType = "Handle";
338346
const attributes = [];
@@ -361,7 +369,7 @@ class FakeMqttController extends MqttController {
361369
attributes.push(`capability: [${handle.capability.getType()}](/pages/usage/capabilities-overview.html#${this.generateAnchor(handle.capability.getType())})`);
362370
}
363371
markdown += `*${attributes.join(", ")}*` + "\n\n";
364-
372+
365373
if (handle.constructor.OPTIONAL === true) {
366374
markdown += `**Note:** This is an optional exposed capability handle and thus will only be available via MQTT if enabled in the Valetudo configuration.\n\n`;
367375
}
@@ -490,10 +498,16 @@ class FakeMqttController extends MqttController {
490498
if (component.componentType === "vacuum") {
491499
component.friendlyName = "Vacuum";
492500
}
493-
markdown += "- " + (component.friendlyName ?? component.name ?? component.componentId) +
494-
` ([\`${component.componentType}.mqtt\`](https://www.home-assistant.io/integrations/${component.componentType}.mqtt/))\n`;
495-
const compTitle = (component.friendlyName ?? component.name ?? component.componentId) + ` (\`${component.componentType}.mqtt\`)`;
496-
hassComponentAnchors[compTitle] = anchor;
501+
502+
const componentBaseName = (component.friendlyName ?? component.name ?? component.componentId);
503+
const componentSuffix = ` ([\`${component.componentType}.mqtt\`](https://www.home-assistant.io/integrations/${component.componentType}.mqtt/))`;
504+
const componentIndexSuffix = ` (\`${component.componentType}.mqtt\`)`;
505+
506+
const escapedComponentBaseName = componentBaseName.replace(/</g, "&lt;").replace(/>/g, "&gt;");
507+
markdown += "- " + escapedComponentBaseName + componentSuffix + "\n";
508+
509+
const hassComponentIndexKey = escapedComponentBaseName + componentIndexSuffix;
510+
hassComponentAnchors[hassComponentIndexKey] = anchor;
497511
}
498512
markdown += "\n";
499513
}
@@ -515,7 +529,7 @@ class FakeMqttController extends MqttController {
515529
return {
516530
markdown: markdown,
517531
anchors: {
518-
title: title,
532+
title: finalDisplayTitle,
519533
anchor: anchor,
520534
children: childAnchors
521535
},

0 commit comments

Comments
 (0)