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
*/
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;
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 {
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;
}
}
}
String[] params = cmds[1].split(";");
String mapId = params[0];
- String[] regionIds = params[1].split(",");
-
- MQTTProtocol.Request request = new MQTTProtocol.CleanRoomsRequest("start", mapId, regionIds);
+ String userPmapvId;
+ if (params.length >= 3) {
+ userPmapvId = params[2];
+ } else {
+ userPmapvId = null;
+ }
+
+ 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);