My Home Assistant Vacuum Automation! Rescue Me Mode!

This weekend, I finished up a project giving my Neato D7 Robot vacuum a voice in the house to alert us when it gets stuck. (or needs some other help).

Using Home Assistant and the Neato integration, I wrote an automation that monitors the status of the Neato D7 and if it detects an error condition, proceeds to start alerting us.

Let’s break down the automation piece by piece. [Full Automation Here]

In this block, we name the automation with alias. We call it ‘Help Neato’. There are two triggers that can kick this automation off:
1) The state of vacuum.carlo_neato equal to error
2) an event called event_did_someone_help_neato

  - alias: 'Help Neato'
    trigger:
      - platform: state
        entity_id: vacuum.carlo_neato
        to: 'error'
      - platform: event
        event_type: event_did_someone_help_neato

Once the automation is kicked off, we use a condition to verify if the robot is still experiencing an error. This is necessary since this is a LOOPING automation with a delay and someone might have fixed the issue between loops.

    condition:
        - condition: state
          entity_id: vacuum.carlo_neato
          state: 'error'

Once all conditions are met, we start with our actions. Our first one is to verify and wait until someone is home. We don’t want to ask for help if no one is home to help. So we trigger the automation and then go into a holding pattern until someone gets home. You can learn more about how I do presence detection.

    action:
      - wait_template: >-
          {{ states.group.family.state == 'home' }}

How to set up Home Assistant Presence Detection using NMAP

Today,  I tackled Presence Detection with Home Assistant.  To get the most out of your home automation, you need good presence detection.  A way for the house to know if you are home or away and then react accordingly.  If no one is home, you would want the system to start shutting down unnecessary lights […]

Read more

Once someone arrives home or we determine that someone was home, we start our first announcement. This is done primarily via a Speech_engine script. The script uses templating to first set the error variable from the attribute status of the vacuum and then randomly choose a sentence to announce over the Text to Speech system of the house. Possible error conditions include brush stuck, bin full, rollers stuck, pathway obstructed.

      - service: script.speech_engine
        data_template:
          value1: >
            {% set error =  states.vacuum.carlo_neato.attributes['status'] %}
            {{ [
            "Neato is asking for help.  The error reported is " ~ error + " .  Please find him and help him.",
            "Please be nice and help Neato.  He is complaining about " ~ error + ".",
            "If you don't want to vacuum, you need to help Neato.  He is complaining about " ~ error +" and needs help.",
            "Something is wrong with Neato.  Please find him and help him.  I have detected a " ~ error + " error."
            ] | random }}

Now that we know there is an issue, the next action uses the locate function to make the robot start beeping. This makes the robot a lot easier to find in the house.

      - service: vacuum.locate
        entity_id: vacuum.carlo_neato

If that is not enough to track him down we also get notifications sent to our iPhones with an attached map of the house with Neato’s last known location.

      - service: script.notify_engine
        data_template:
          title: 'Help Neato'
          value1: "{{ states.vacuum.carlo_neato.attributes['status'] }}"
          who: 'family'
          ios_category: 'camera'
          camera_entity: 'camera.carlo_neato_cleaning_map'
          content_type: 'jpeg'
          apns_id: 'neato-carlo_neato_cleaning_map'
The red icon indicates Neato’s last known position in the house.
The colored in areas indicate where it has cleaned already.

We then have 20 minutes to track him down and correct the issue. If everyone ignores Neato’s pleas for help, we start the automation over again by generating the event ‘event_did_someone_help_neato‘ which is one of the initial triggers above. Without the 20 minute loop and the condition checking, you would have a continuous barrage of announcements over and over.

      - delay: 00:20:00
      - event: event_did_someone_help_neato

That’s the automation in pretty good detail so I hope that was useful to you. Check out the video below to see it broken down a little differently.

Happy Automating!
Carlo

TAGS