mirror of
https://github.com/Hypfer/Valetudo.git
synced 2025-10-26 11:27:27 +00:00
docs: Example for mqtt segments
This commit is contained in:
parent
a47f4785ae
commit
730e373ada
@ -675,7 +675,11 @@ This property contains a JSON mapping of segment IDs to segment names.
|
||||
Sample value:
|
||||
|
||||
```json
|
||||
{}
|
||||
{
|
||||
"16": "Hallway",
|
||||
"18": "Bathroom",
|
||||
"20": "Kitchen"
|
||||
}
|
||||
```
|
||||
|
||||
Home Assistant components controlled by this property:
|
||||
|
||||
@ -8,6 +8,7 @@ const RobotStateNodeMqttHandle = require("../backend/lib/mqtt/handles/RobotState
|
||||
const MapNodeMqttHandle = require("../backend/lib/mqtt/handles/MapNodeMqttHandle");
|
||||
const MockConsumableMonitoringCapability = require("../backend/lib/robots/mock/capabilities/MockConsumableMonitoringCapability");
|
||||
const ConsumableStateAttribute = require("../backend/lib/entities/state/attributes/ConsumableStateAttribute");
|
||||
const ValetudoMapSegment = require("../backend/lib/entities/core/ValetudoMapSegment");
|
||||
const PropertyMqttHandle = require("../backend/lib/mqtt/handles/PropertyMqttHandle");
|
||||
const DataType = require("../backend/lib/mqtt/homie/DataType");
|
||||
const HassController = require("../backend/lib/mqtt/homeassistant/HassController");
|
||||
@ -158,6 +159,23 @@ class FakeMqttController extends MqttController {
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
robot.state.map.getSegments = () => {
|
||||
return [
|
||||
new ValetudoMapSegment({
|
||||
id: "20",
|
||||
name: "Kitchen"
|
||||
}),
|
||||
new ValetudoMapSegment({
|
||||
id: "18",
|
||||
name: "Bathroom"
|
||||
}),
|
||||
new ValetudoMapSegment({
|
||||
id: "16",
|
||||
name: "Hallway"
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
super({
|
||||
robot: robot,
|
||||
@ -603,6 +621,18 @@ class FakeMqttController extends MqttController {
|
||||
|
||||
|
||||
isInitialized() {
|
||||
const stack = new Error().stack;
|
||||
|
||||
// Now this is some major jank engineering
|
||||
if (
|
||||
stack.split("\n").find(line => {
|
||||
return line.includes("MapNodeMqttHandle") && line.includes("PropertyMqttHandle.getter")
|
||||
}) &&
|
||||
!stack.includes("MapNodeMqttHandle.getMapData")
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.docsGenerated;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user