Roomba integration - remember maps & zones, allow user to tag

I’ve been using the Roomba integration for a while now and would be interested in making an addition, I’d like to see whether it would be accepted upstream.

Proposal

Following on from the thread about room cleaning, I’d like to alter the integration to remember maps, regions and zones that it’s seen. Currently users have to discover this themselves and manually write service yaml.

Service yaml
service: vacuum.send_command
data:
    entity_id: vacuum.roomba0
    command: start
    params:
      pmap_id: ohG_V5NOTREALRnAvsF
      regions:
        - region_id: '27'
          type: rid
      user_pmapv_id: 1105NOTREAL07

I would like a user to be able to instead see the regions and zones that the integration has remembered, associate them with a name, such as “Living room” and be able to trigger a clean of this region/zone via the UI.

Implementation

We can watch the lastCommand and cleanSchedule properties on the Roomba’s state, decode the JSON and extract values. For example, after running a clean from the app, lastCommand is:

lastCommand
{
  "state": {
    "reported": {
      "lastCommand": {
        "command": "start",
        "time": 1710000000,
        "initiator": "rmtApp",
        "favorite_id": "<fav_id>",
        "ordered": 1,
        "pmap_id": "<pmap_id>",
        "regions": [
          {
            "params": { "noAutoPasses": true, "twoPass": false },
            "region_id": "4",
            "type": "rid"
          },
          {
            "params": { "noAutoPasses": true, "twoPass": false },
            "region_id": "1",
            "type": "rid"
          },
          {
            "params": { "noAutoPasses": true, "twoPass": false },
            "region_id": "5",
            "type": "rid"
          }
        ],
        "user_pmapv_id": "<user_pmapv_id>"
      }
    }
  }
}

Or if we look on the state at cleanSchedule2[0].cmdStr:

cleanSchedule
{
  "command": "start",
  "ordered": 1,
  "params": { "noAutoPasses": true, "twoPass": false },
  "pmap_id": "<pmap>",
  "regions": [
    {
      "params": { "noAutoPasses": true, "twoPass": false },
      "region_id": "6",
      "type": "rid"
    },
    {
      "params": { "noAutoPasses": true, "twoPass": false },
      "region_id": "4",
      "type": "rid"
    }
  ],
  "user_pmapv_id": "<user_pmapv_id>"
}

Unknowns

To do this, we would wait for state updates but I’d like to know the most relevant place to have this region/zone scanning code. We would then create an entity per region/zone and a way to queue up a job to clean one or more of these.

I’m not familiar enough with HA to know how to expose this in the UI. I’d like to make a control that allows each region/zone to be cleaned.

Future features

Do the same to favourites, i.e. allow the user to tag and trigger what we’ve detected.

In short, I’d like to bring this to parity with setups such as this, where custom cleaning can be triggered entirely through the UI (using existing API mentioned here)

1 Like