Home Assistant, Tips, Uncategorized

Start vacuum when I leave (automation example)

I got an iRobot Roomba 690 for Christmas, and it does a decent job of keeping the kid crumbs and animal hair at bay between “real” cleanings. The problem is, we never want to run it when we’re around, because it’s kind of noisy.

Ideally we would just let it run while we’re gone, but usually in the chaos of getting two young boys bundled up and strapped in, I don’t remember to start the vacuum. The iRobot app, while not bad, doesn’t offer any sort of advanced automation capability using presence detection.

Enter: Home Assistant.

Connecting your Roomba to Home Assistant

If we’re going to have Home Assistant be our new robot vacuum’s robot overlord, we first have to get the two talking. This isn’t quite as simple as some integrations, but it doesn’t take too long. Note that this is very much unofficial — iRobot doesn’t make their API publicly available, so this is reverse engineered.

To connect your iRobot device, you need its “BLID” and password. These are not values you can set; they’re values you have to retrieve from the robot itself. There are a couple libraries out there to help you do this. I found success with this one; it’s built for the Roomba 980 model but the BLID/password retrieval works for any Wifi-connected Roomba (so far).

The details at that link, but in summary here’s what I did:

  1. Figure out your robot’s IP address (check your router)
  2. Follow the instructions here to pull down the code and run it, using your robot’s IP address as a parameter. Note that you’ll need Git and Node installed on your system.
  3. Configure your robot in Home Assistant with the Roomba component, using the information you got from step #2.

If that was done correctly, after restarting Home Assistant you’ll see a new device within the vacuum namespace, named whatever you used when you setup your Roomba using the official iRobot app. Mine is just named roomba, so the new device showed up as vacuum.roomba and I had a new card in my UI like this:

My Roomba’s card in the Home Assistant UI.

From this point, I can see the Roomba’s info and manually control it from Home Assistant. Neat! But it’s not automated yet…

Ask us to clean when we leave

Since I’m forgetful about starting the robot, it would be great to trigger it when we leave. We’re going to take advantage of presence detection built into Home Assistant (which I already use to do things like turn off all the lights when we leave) to help set up this automation.

However, I don’t just want the Roomba to automatically fire up every time we’re not home. For one thing, we might just be running a 5 minute errand; for another, cleaning multiple times a day would just be unnecessary and would cause premature wear on the Roomba’s components.

So instead, I want to be asked when we leave if I would like to start the robot, and ideally be able to start it with one tap. Using Home Assistant’s actionable notifications feature for iOS, we can have it send a push alert and offer me an action to take at the same time.

Following the docs for actionable notifications, I wound up with this in my main configuration section:

ios:
  push:
    categories:
      - name: Vacuum
        identifier: 'vacuum'
        actions:
          - identifier: 'RUN_VACUUM'
            title: 'Start cleaning'
            activationMode: 'background'
            authenticationRequired: no

And my automation rules to send the push notification, and start the cleaning:

- alias: Request cleaning when not home
  trigger:
    platform: state
    entity_id: group.all_devices
    from: 'home'
    to: 'not_home'
  action:
    service: notify.iOSapp_matts_iphone
    data:
      message: "Would you like to start the vacuum?"
      data:
        push:
          category: "vacuum"

- alias: Start cleaning
  trigger:
    platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: RUN_VACUUM
  action:
    - service: vacuum.start_pause
      entity_id: vacuum.roomba

Now when I leave the house, I get this alert on my phone, which I can tap and start cleaning:

After tapping “Start cleaning”, the notification dismisses and a message is sent back through Home Assistant to kick off the Roomba.

And that’s it! Now I have easy access to kick off my Roomba based on when we leave the house, so I don’t have to remember to start it beforehand.

Leave a Reply

Theme by Anders Norén