I recently integrated my robot vacuum, which runs on Valetudo, with openHAB and wanted to share my setup in case it’s helpful for others. Valetudo provides a great way to locally control your vacuum without relying on cloud services.
Valetudo offers an official guide for integrating with openHAB: Valetudo openHAB Integration. The integration mainly involves sending commands via MQTT.
While there’s a widget for MainUI I prefer using Sitemaps. Also I want a faster way than “Look at a map” => “Select a room” => “Click on Start”, so I created two Items and a corresponding rule:
- String Item
Robot
with mappings for basic commands (Start, Stop, Home) and for each room. - Number Item
Robot_Wiederholungen
for repeated cleans, e.g. two times.
// This rule is triggered, when Robot receives a command.
var roomId = 0
switch (String(event.itemCommand)) {
case "Stop":
items.getItem("Robot_Operation").sendCommand("STOP")
break;
case "Start":
items.getItem("Robot_Operation").sendCommand("START")
break;
case "Pause":
items.getItem("Robot_Operation").sendCommand("PAUSE")
break;
case "Aufladen":
items.getItem("Robot_Operation").sendCommand("HOME")
break;
case "Wohnzimmer":
roomId = 2 // To get the ID, select the room in Valetudo, then long-press "CLEAN 1 SEGMENTS" button.
break;
case "Schlafzimmer":
roomId = 8
break;
}
if (roomId != 0) {
val iterations = items.getItem("Robot_Wiederholungen").state
val roomPayload = {
"action": "start_segment_action",
"segment_ids": [
"${roomId}"
],
"iterations": iterations,
"customOrder": true
}
items.getItem("Robot_Clean_segments").sendCommand(JSON.stringify(roomPayload))
}
Sitemap which also contains the map in case I need it:
Selection item=Robot
Default icon=none item=Robot_Mode label="[]"
Setpoint item=Robot_Wiederholungen
Text icon=none label="Karte" {
Webview height=20 url="http://<local ip>/#/"
}