How to connect Samsung robot vacuum cleaner to Home Assistant

While there is a component in Home Assistant for Samsung SmartThings integration, the things with vacuum cleaners are not as obvious as they can be. While I’m not sure about older versions of Samsung robot cleaners, I can say that you can’t control newer versions (like VR9300 in my case) using only Home Assistant integration. Need some magic here.

I’m assuming that you already have your robot cleaner added to the SmartThings app.

Robot vacuum state

First, we need to enable SmartThings integration in Home Assistant. The instructions on home-assistant.io are quite detailed so I don’t see a reason to describe the process here. Just follow it carefully.

After SmartThings integration was created and some time passed after it (2-3 minutes in my case) you’ll be able to see new entities added inside integration. Go to Configuration -> Integrations in your Home Assistant web UI and find SmartThings there:

Open it and you’ll find switch and several sensors:

“Виталька” is the name of my vacuum cleaner. In my case switch.[name] do absolutely nothing but sensor.[name]_robot_cleaner_movement represents an almost real-time robot state. We will use it later as well as sensor.[name]_battery.

Robot vacuum controls

As the switch from SmartThings integration does nothing and there is no other way to control our robot, we will use IFTTT for that. To enable the IFTTT service in Home Assistant we need to configure this component in your configuration.yaml:

ifttt:
  key: YOUR_API_KEY

replacing YOUR_API_KEY with an actual key from your IFTTT Webhooks Settings. We need the last part of URL:

Restart your Home Assistant once IFTTT configuration added and after that you will be able to fire events to IFTTT using ifttt.trigger service. While we still on IFTTT website lets create a couple of applets. One for starting cleaning, and the other for bringing our robot back to charger.

Click on your account picture in the upper right corner and choose Create.

Click on +This on the next screen and search for “webhook”:

Click on “Webhooks” card, choose “Receive a web request” on the next screen, come up with your event name (for example start_powerbot) and hit Create trigger:

Now click on +Thant, search for “Samsung” and choose “Samsung Robot Vacuum”:

IFTTT will ask you now to connect your Samsung SmartThings account and after successful login, you will be able to choose an action to perform on your robot vacuum:

As our trigger is called start_powerbot let’s not create a mess and choose “Start vacuum cleaning”. Lastly, IFTTT will ask you to choose a device from your SmartThings account to trigger an action on.

In the same way, we need to create an applet for stopping our robot. Make the same steps just changing the event name for a trigger to stop_powerbot and choosing “End vacuum cleaning” for action.

To make it simple for future use let’s move to Home Assistant and create a couple of scripts for starting and stopping our device through IFTTT events. Here is an example from my scripts.yaml:

start_powerbot:
  alias: 'Powerbot: Start autoclean (IFTTT)'
  sequence:
  - data:
      event: start_powerbot
    service: ifttt.trigger
stop_powerbot:
  alias: 'Powerbot: Make it go home (IFTTT)'
  sequence:
  - data:
      event: stop_powerbot
    service: ifttt.trigger

Putting things togather

Now we have scripts and sensors enough to create a vacuum entity using a template platform. Here is my example. It converts SmartThings robot cleaner state to the state supported by template vacuum in Home Assistant. Also, it sets the battery level to “0” if the state of the robot battery sensor is unknown as template vacuum platform will throw an error if the battery state value will be not an integer:

vacuum:
  - platform: template
    vacuums:
      vitalka:
        friendly_name: Виталька
        value_template: "{% if is_state('sensor.vitalka_robot_cleaner_movement', 'cleaning') %}cleaning{% elif is_state('sensor.vitalka_robot_cleaner_movement', 'charging') %}docked{% elif is_state('sensor.vitalka_robot_cleaner_movement', 'homing') %}returning{% elif is_state('sensor.vitalka_robot_cleaner_movement', 'idle') %}idle{% elif is_state('sensor.vitalka_robot_cleaner_movement', 'alarm') %}error{% elif is_state('sensor.vitalka_robot_cleaner_movement', 'powerOff') %}error{% else %}unknown{% endif %}"
        battery_level_template: "{% if is_state('sensor.vitalka_battery','unknown') %}0{% else %}{{states('sensor.vitalka_battery')}}{% endif %}"
        start:
          service: script.start_powerbot
        return_to_base:
          service: script.stop_powerbot

That’s it! Now we just need to restart Home Assistant to make our new vacuum entity appear.


Posted

in

,

Follow the updates:

Comments