How to Automate a Vacuum Robot in Home Assistant


Are you looking into taking your smart robot vacuum to the next level ? In this blog post I’ll share with you how I automated a WiFi robot vacuum (Eufy Robovac 30c) within Home Assistant.

 

Home assistant provides standard integrations for various brands like Xiaomi Miio and the iRobot Roomba but also enables other WiFi robot vacuum to connect to home assistant. This will enable you to do several automations such as a reminder to empty the bin or notification of cleaning routines.

 

What is Home Assistant ?

Home assistant is a cloud based open software home automation software, which can be installed on your own hardware that you supply and install. For more information check out my other blog posts where I explain in detail.

Vacuum Category

Home assistant has various integration categories and in this post we will explore the Vacuum category.

The vacuum category enables the ability to control home cleaning robots within home assistant.

You will need to add your own robot vacuum in: configuration.yaml

 

This is an example of how this might look:

vacuum:
  - platform: xiaomi_miio
    name: Living room
    host: 192.168.1.2

Out of the box home assistant works with the following vacuum brands:

  • Dyson
  • Ecovacs
  • IRobot
  • Any MQTT enabled vacuum
  • Neato Botvac
  • Xiaomi Miio

 

Once configured, each brand has a slightly different configuration you will have the same services that you can use in your dashboard or in your automations.

To use the robot vacuum you can call the service vacuum.turn_on or vacuum.start (depending on your brand).

You will need to specify the entity id in all cases.

 

To stop cleaning and return to the dock you can use vacuum.stop or vacuum.turn_off

 

Other useful services are vacuum.return_to_base in case your vacuum is stuck and didn’t manage to return to base or perhaps you stopped it.

Worst case if you really can’t find your robot you can send a vacuum.locate to allow the vacuum to emit a sound.

 

Eufy Robovac Use case

It seems pretty easy to just pick up a Dyson or a IRoobot that out of the box are compatible and integrate with home assistant so easily. However I had a Eufy Robovac the 30c model check current price from Amazon US or UK I would consider it a budget option compared to the other vacuums.

 

This is how my configuration.yaml looks like:

eufy_vacuum:
devices:
- name: Robovac
address: 192.168.X.XX
access_token: XXXXXXXXXX
id: XXXXXXXXXXXXXXXXXXXX
type: T2118

 

If you do decide to buy a Eufy Robovac 30c which I have been using for years with no issues I’ll show you how I setup my version.

Please note that these instructions will only work for the 30c.

 

Step 1

Go to your config/ folder in home assistant, I use the File editor add-on to do this in the UI.

Create a folder called custom_components unless you already have it.

Go into the folder

Upload the following folder eufy_robovac from this github repo into a folder called eufy_vacuum (note the different names).

 

Step 2

Add the code mentioned above in your own configuration.yaml file.

Now we need to find these three components:

  • Address
  • Access Token
  • id

 

Address will be your network IP address that your router has assigned to it via your DNS server. I recommend you assign a static IP address. If you need any help get in touch and I can support you.

Access Token and Id can be obtain with the following:

First of all kudos to Josh Strange he has built a series of steps in order to “sniff” the data necessary. https://github.com/joshstrange/eufy-robovac

In order to achieve this you will need either an Android Device or a simulator like BlueStacks.

  1. Close the app on your mobile device
  2. Connect the device to your laptop and enable USB debugging
  3. Run adb logcat -e ‘tuya.m.my.group.device.list’ (assumes you have already installed the Android debug tools)
  4. Launch the Eufy Home app
  5. The output lines contain JSON, you’re looking for the values of localKey (16 character hex string) and devId (20 character hex string).

Automations

This is the interesting part where the limit is whatever you can image, you can create them as simple as you want and as complex as you wish!

Each robot vacuum app will have its own features and automations but with home assistant you can use your other sensors and gadgets to interact with each other and create unique combinations.

In this blog post we will explore three automations:

  • Voice notifications when the robot vacuum starts
  • Empty Bin notifications
  • Return to base automation

 

Voice notification when the robot vacuum starts

In this first automation we are going to start to get familiar with creating automations in home assistant. This Automation will send trigger a google mini to send play a message that tells us that the robot has started cleaning.

 

Our entity id for our robot vacuum is vacuum.robovac and we are looking for a state change from ‘off’ to ‘on’, this will trigger the text to speech (tts) service to play a message.

This is the code:

- id: robovac_bin 
  alias: Robovac Bin
  trigger:
    platform: state 
    entity_id: vacuum.robovac 
    from: 'off'
    to: 'on'
  action:
  - service: tts.google_say
    data:
      entity_id: media_player.kitchen_speaker 
      message: Robovac has started cleaning the kitchen.

You can use any message you wish, your entity_id might be different then mine, for the rest you should be able to copy & paste.

Empty Bin notifications

In this automation we are going to get a notification when the vacuum’s bin needs emptying. Now we don’t have a precise scientific way of doing this. Everyone’s situation might be different, but I’ll explain mine.

 

I estimate that after 3 cleaning cycles I’d need to empty the bin, I want google to notify me when this needs doing.

 

First step, we need to create a counter, a counter will store the number of times the vacuum has been triggered since we last emptied the bin.

 

In the configuration.yaml file add the following code:

# Create a Vacuum Bin Counter
counter:
  vacuum_bin_counter:
    initial: 0
    step: 1

Now feel free to call your counter in anyway, mine is called vacuum_bin_counter.

 

After restarting HASS we need to add a step to the previous automation, each time the robot starts we want to be notified and increase the counter, add this code in:

  - entity_id: counter.vacuum_bin_counter
    service: counter.increment

Reload automations.

Now each time you start the vacuum, with home assistant or not, the counter value will increase. You can reset the counter from the dashboard.

 

Second step, we need to get notified when the counter value goes above 3 (again change this value to what works for you!)

#Robovac is full Notification 

- id: robovac_full_notification
  alias: Robovac is full
  trigger:
    - platform: numeric_state 
      above: '3'
      entity_id: counter.vacuum_bin_counter
  action:
  - service: tts.google_say
    data:
        entity_id: media_player.kitchen_speaker
        message: Robovac is full, please empty the bin.

Notice that I have used a numeric state as the platform trigger and the entity id is the name you specified in the previous step.

The action is similar just a different message, you can add more than one notifications for a full house experience.

 

This completes this automation!

Return to base automation

Last automation I want to cover in this blog post is the return to base, now my robot vacuum automatically returns to base after each cleaning cycle.

But most of the times it gets stopped manually or paused or stuck.

The following automation will check if it isn’t cleaning nor docked then it will trigger an automation, this is the code:

 

#Return to charging base

- id: robovac_return_to_base
  alias: Robovac go back to base when Idle
  trigger:
    - platform: template
      value_template: "{{ is_state_attr('vacuum.robovac', 'status', 'idle') }}"
  action:
  - service: vacuum.return_to_base
    data: 
      entity_id: vacuum.robovac

Platform template allows you to check a status (attribute) of an entity and check for a value. In my case I’m checking the attribute status of the vacuum.robovac is idle, then I trigger the service return to base.

 

 

Please subscribe to my blog and YouTube channel to get notified when new content is released.

Disclaimer:

This posts contains affiliate links to Amazon UK and Amazon US, I’ll get a small commission for each sell, but it will not cost you anything. This allows to keep this blog sustainable.

Keep it digital!

 

giordano

Gio

Gio loves rabbits, smart home tech, WWII, travelling to Thailand & my favourite pizza is margherita with parma ham!

Recent Posts