mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
iRobot zone support added (#11783)
Signed-off-by: Nuesel <nuesel@gruenbaer.net>
This commit is contained in:
parent
956f6e722e
commit
e54dec524b
@ -150,10 +150,13 @@ Error codes. Data type is string in order to be able to utilize mapping to human
|
||||
You can clean one or many specific regions of a given map by sending the following String to the command channel:
|
||||
|
||||
```
|
||||
cleanRegions:<pmapId>;<region_id1>,<region_id2>,..
|
||||
cleanRegions:<pmapId>;[r=]<region_id1>,[r=]<region_id2>,z=<zone_id1>,...;[<user_pmapv_id>]
|
||||
```
|
||||
|
||||
The easiest way to determine the pmapId and region_ids is to monitor the last_command channel while starting a new mission for the specific region with the iRobot-App.
|
||||
Some devices support cleaning rooms (aka regions). Additionally, support for cleaning rectangle areas previously defined in the iRobot-App (aka zones) may be available.
|
||||
If the type string such as `r=` (region) or `z=` (zone) is omnitted, the type defaults to region.
|
||||
|
||||
The easiest way to determine the pmapId, region_ids/zoneids and userPmapvId is to monitor the last_command channel while starting a new mission for the specific region or zone with the iRobot-App.
|
||||
|
||||
## Known Problems / Caveats
|
||||
|
||||
|
@ -12,9 +12,8 @@
|
||||
*/
|
||||
package org.openhab.binding.irobot.internal.dto;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@ -35,13 +34,20 @@ public class MQTTProtocol {
|
||||
public int ordered;
|
||||
@SerializedName("pmap_id")
|
||||
public String pmapId;
|
||||
@SerializedName("user_pmapv_id")
|
||||
public String userPmapvId;
|
||||
public List<Region> regions;
|
||||
|
||||
public CleanRoomsRequest(String cmd, String mapId, String[] regions) {
|
||||
public CleanRoomsRequest(String cmd, String mapId, String[] pregions, String[] types, String userPmapvId) {
|
||||
super(cmd);
|
||||
ordered = 1;
|
||||
pmapId = mapId;
|
||||
this.regions = Arrays.stream(regions).map(i -> new Region(i)).collect(Collectors.toList());
|
||||
this.userPmapvId = userPmapvId;
|
||||
|
||||
regions = new ArrayList<Region>();
|
||||
for (int i = 0; (i < pregions.length) && (i < types.length); i++) {
|
||||
regions.add(new Region(pregions[i], types[i]));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Region {
|
||||
@ -49,9 +55,9 @@ public class MQTTProtocol {
|
||||
public String regionId;
|
||||
public String type;
|
||||
|
||||
public Region(String id) {
|
||||
public Region(String id, String type) {
|
||||
this.regionId = id;
|
||||
this.type = "rid";
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,9 +189,38 @@ public class RoombaHandler extends BaseThingHandler {
|
||||
String[] params = cmds[1].split(";");
|
||||
|
||||
String mapId = params[0];
|
||||
String[] regionIds = params[1].split(",");
|
||||
String userPmapvId;
|
||||
if (params.length >= 3) {
|
||||
userPmapvId = params[2];
|
||||
} else {
|
||||
userPmapvId = null;
|
||||
}
|
||||
|
||||
MQTTProtocol.Request request = new MQTTProtocol.CleanRoomsRequest("start", mapId, regionIds);
|
||||
String[] regions = params[1].split(",");
|
||||
String regionIds[] = new String[regions.length];
|
||||
String regionTypes[] = new String[regions.length];
|
||||
|
||||
for (int i = 0; i < regions.length; i++) {
|
||||
String[] regionDetails = regions[i].split("=");
|
||||
|
||||
if (regionDetails.length >= 2) {
|
||||
if (regionDetails[0].equals("r")) {
|
||||
regionIds[i] = regionDetails[1];
|
||||
regionTypes[i] = "rid";
|
||||
} else if (regionDetails[0].equals("z")) {
|
||||
regionIds[i] = regionDetails[1];
|
||||
regionTypes[i] = "zid";
|
||||
} else {
|
||||
regionIds[i] = regionDetails[0];
|
||||
regionTypes[i] = "rid";
|
||||
}
|
||||
} else {
|
||||
regionIds[i] = regionDetails[0];
|
||||
regionTypes[i] = "rid";
|
||||
}
|
||||
}
|
||||
MQTTProtocol.Request request = new MQTTProtocol.CleanRoomsRequest("start", mapId, regionIds,
|
||||
regionTypes, userPmapvId);
|
||||
connection.send(request.getTopic(), gson.toJson(request));
|
||||
} else {
|
||||
logger.warn("Invalid request: {}", cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user