Essential Scripts for Shark Clean HA Integration Workaround

If you’re looking to get the most out of your Shark Clean robot vacuum and Home Assistant integration, you’ll want to take advantage of these custom YAML scripts. In this post, we’ll go over the details of the scripts for cleaning individual rooms, managing multiple rooms, and the essential control scripts for pausing, stopping, or returning your vacuum to the dock. These scripts help you automate and manage your vacuuming routine, allowing for seamless control through Google Assistant and Home Assistant.

Prerequisites

Before implementing the custom YAML scripts, complete the following prerequisites to ensure a seamless integration of your Shark robot vacuum with Home Assistant:

  1. Integrate Your Shark Robot Vacuum with the Google Home App:
    • Open the Google Home app on your smartphone.
    • Tap the ‘+’ symbol at the top of the screen.
    • Select ‘Set up device’ and then choose ‘Works with Google’.
    • Search for ‘Shark’ and follow the prompts to link your SharkClean account.
  2. Set Up Google Console Credentials:
    To integrate the Google Assistant SDK with Home Assistant, you’ll need Google Console credentials:
    • If you already have credentials, follow Scenario 1 outlined in this guide.
    • If you don’t have credentials, follow Scenario 2 in the same guide to create and configure them.
  3. Integrate the Google Assistant SDK Custom Integration in Home Assistant:
    • Ensure you have the Home Assistant Community Store (HACS) installed.
    • In HACS, add the following repository: https://github.com/tronikos/google_assistant_sdk_custom.
    • Download and install the ‘Google Assistant SDK Custom’ integration.
    • Restart Home Assistant to apply the changes.
    • Navigate to Settings > Devices & Services > Integrations, click ‘+ ADD INTEGRATION’, search for ‘Google Assistant SDK Custom’, and follow the configuration prompts.
  4. Test the Integration within Home Assistant:
    • After completing the setup, test the integration by sending a command through Home Assistant to Google Assistant.
    • For example, use the ‘google_assistant_sdk_custom.send_text_command’ service to send a command like “Hey Google, start cleaning.”
    • Verify that your Shark robot vacuum responds appropriately to the commands issued through Home Assistant.

By completing these steps, your Shark Clean robot vacuum will be effectively integrated with Home Assistant, enabling you to utilize the custom YAML scripts for enhanced control and automation.

With the prerequisites complete, your Shark Clean robot vacuum is now fully integrated with Home Assistant and ready to accept custom scripts. Below are essential YAML scripts designed to enhance your control over cleaning operations. Let’s start with the script for managing Individual Rooms.

Individual Room Script

The individual room script is designed to target specific rooms within your house using the Shark Clean app’s room names. For example, this script focuses on a room called the “Foyer” and a robot vacuum named “Tony Shark.” The script sends a command to Google Assistant to begin cleaning the designated room, monitors the vacuum’s progress, and updates the status accordingly.

alias: Clean Foyer with Tony Shark
description: >
  Send command to Google Assistant to clean the foyer and monitor until Tony
  Shark is done
mode: single
sequence:
  - data:
      value: Cleaning
    target:
      entity_id: input_text.tony_shark_status
    action: input_text.set_value
  - data:
      command: "\"Hey Google, clean the Foyer with TONY_SHARK.\""
    action: google_assistant_sdk_custom.send_text_command
  - data:
      command: "\"Hey Google, is TONY_SHARK docked?\""
    response_variable: docked_status
    action: google_assistant_sdk_custom.send_text_command
  - delay: "00:00:10"
  - repeat:
      while:
        - condition: template
          value_template: "{{ docked_status.responses[0].text != 'Tony Shark is docked.' }}"
      sequence:
        - data:
            command: "\"Hey Google, is TONY_SHARK docked?\""
          response_variable: docked_status
          action: google_assistant_sdk_custom.send_text_command
        - delay: "00:01:00"
        - choose:
            - conditions:
                - condition: template
                  value_template: >-
                    {{ docked_status.responses[0].text == 'Tony Shark is
                    docked.' }}
              sequence:
                - data:
                    value: Docked
                  target:
                    entity_id: input_text.tony_shark_status
                  action: input_text.set_value
            - conditions:
                - condition: template
                  value_template: >-
                    {{ docked_status.responses[0].text == "Tony Shark isn't
                    docked." }}
              sequence:
                - data:
                    value: Cleaning
                  target:
                    entity_id: input_text.tony_shark_status
                  action: input_text.set_value
  - action: input_text.set_value
    data:
      value: Docked
    target:
      entity_id: input_text.tony_shark_status
  - action: notify.notify
    metadata: {}
    data:
      message: Tony Shark has finished cleaning the foyer.
      title: Vacuum Complete

This script ensures that the vacuum cleans the foyer and updates the status of Tony Shark’s progress, sending notifications when the task is complete.

Multiple Room (Location) Script

If you’re looking to clean several rooms in one go, this script allows you to target multiple rooms (a “location”) and send a command to Google Assistant to clean them all. The status monitoring follows the same structure as the individual room script, ensuring that Tony Shark’s docking status is checked and updated until cleaning is complete.

alias: Clean Main Living Area with Tony Shark
description: >
  Send command to Google Assistant to clean the Living Room, Kitchen, Nook
  Office, and Foyer and monitor until Tony Shark is done
mode: single
sequence:
  - data:
      value: Cleaning
    target:
      entity_id: input_text.tony_shark_status
    action: input_text.set_value
  - data:
      command: >-
        "Hey Google, clean the Living Room, Kitchen, Nook Office, and Foyer with
        TONY_SHARK."
    action: google_assistant_sdk_custom.send_text_command
  - data:
      command: "\"Hey Google, is TONY_SHARK docked?\""
    response_variable: docked_status
    action: google_assistant_sdk_custom.send_text_command
  - delay: "00:00:10"
  - repeat:
      while:
        - condition: template
          value_template: "{{ docked_status.responses[0].text != 'Tony Shark is docked.' }}"
      sequence:
        - data:
            command: "\"Hey Google, is TONY_SHARK docked?\""
          response_variable: docked_status
          action: google_assistant_sdk_custom.send_text_command
        - delay: "00:01:00"
        - choose:
            - conditions:
                - condition: template
                  value_template: >-
                    {{ docked_status.responses[0].text == 'Tony Shark is
                    docked.' }}
              sequence:
                - data:
                    value: Docked
                  target:
                    entity_id: input_text.tony_shark_status
                  action: input_text.set_value
            - conditions:
                - condition: template
                  value_template: >-
                    {{ docked_status.responses[0].text == "Tony Shark isn't
                    docked." }}
              sequence:
                - data:
                    value: Cleaning
                  target:
                    entity_id: input_text.tony_shark_status
                  action: input_text.set_value
  - action: input_text.set_value
    data:
      value: Docked
    target:
      entity_id: input_text.tony_shark_status
  - action: notify.notify
    metadata: {}
    data:
      message: Tony Shark has finished cleaning the Main Living Area.
      title: Vacuum Complete

This script is ideal for cleaning large areas with multiple rooms, streamlining the process with just one command.

Control Scripts: Pause, Stop, and Return to Dock

Control scripts give you the ability to manage and interrupt cleaning sessions. You can pause the vacuum, stop it, or send it back to the dock with ease.

Pause Cleaning

This script pauses the cleaning session and halts any other running cleaning scripts. It’s perfect if you accidentally started a cleaning session in the wrong room or just need a break.

alias: Pause Cleaning House with Tony Shark
description: >
  Send command to Google Assistant to pause cleaning the whole house and cancel
  any other related running scripts.
mode: single
sequence:
  - target:
      entity_id:
        - script.clean_foyer_with_tony_shark
        - script.clean_guest_bathroom_with_tony_shark
        - script.clean_guest_bedroom_with_tony_shark
        - script.clean_gym_with_tony_shark
        - script.clean_house_with_tony_shark
        - script.clean_kitchen_with_tony_shark
        - script.clean_living_room_with_tony_shark
        - script.clean_main_living_area_with_tony_shark
        - script.clean_master_bathroom_with_tony_shark
        - script.clean_master_bedroom_with_tony_shark
        - script.clean_master_closet_with_tony_shark
        - script.clean_nook_office_with_tony_shark
        - script.clean_office_with_tony_shark
        - script.return_tony_shark_to_dock
        - script.stop_cleaning_house_with_tony_shark
    action: script.turn_off
    data: {}
  - action: input_text.set_value
    data:
      value: Paused
    target:
      entity_id: input_text.tony_shark_status
  - data:
      command: Hey Google, pause TONY_SHARK.
    action: google_assistant_sdk_custom.send_text_command
  - delay: "00:00:10"
  - action: notify.notify
    data:
      message: Tony Shark has paused cleaning.
      title: Vacuum Status

Stop Cleaning

The stop cleaning script works similarly to the pause script, but instead of pausing, it stops the vacuuming session entirely.

alias: Stop Cleaning House with Tony Shark
description: >
  Send command to Google Assistant to stop cleaning the whole house and cancel
  any other related running scripts.
mode: single
sequence:
  - target:
      entity_id:
        - script.clean_foyer_with_tony_shark
        - script.clean_guest_bathroom_with_tony_shark
        - script.clean_guest_bedroom_with_tony_shark
        - script.clean_gym_with_tony_shark
        - script.clean_house_with_tony_shark
        - script.clean_kitchen_with_tony_shark
        - script.clean_living_room_with_tony_shark
        - script.clean_main_living_area_with_tony_shark
        - script.clean_master_bathroom_with_tony_shark
        - script.clean_master_bedroom_with_tony_shark
        - script.clean_master_closet_with_tony_shark
        - script.clean_nook_office_with_tony_shark
        - script.clean_office_with_tony_shark
        - script.pause_cleaning_house_with_tony_shark
        - script.return_tony_shark_to_dock
    action: script.turn_off
    data: {}
  - action: input_text.set_value
    data:
      value: Stopped
    target:
      entity_id: input_text.tony_shark_status
  - data:
      command: "\"Hey Google, stop cleaning TONY_SHARK.\""
    action: google_assistant_sdk_custom.send_text_command
  - delay: "00:00:10"
  - action: notify.notify
    data:
      message: Tony Shark has stopped cleaning.
      title: Vacuum Status

Return to Dock

This final control script sends Tony Shark back to its charging dock, ensuring the vacuum returns to its resting place after cleaning.

alias: Return Tony Shark to Dock
description: >
  Send command to Google Assistant to return Tony Shark to dock and cancel any
  other related running scripts.
mode: single
sequence:
  - target:
      entity_id:
        - script.clean_foyer_with_tony_shark
        - script.clean_guest_bathroom_with_tony_shark
        - script.clean_guest_bedroom_with_tony_shark
        - script.clean_gym_with_tony_shark
        - script.clean_house_with_tony_shark
        - script.clean_kitchen_with_tony_shark
        - script.clean_living_room_with_tony_shark
        - script.clean_main_living_area_with_tony_shark
        - script.clean_master_bathroom_with_tony_shark
        - script.clean_master_bedroom_with_tony_shark
        - script.clean_master_closet_with_tony_shark
        - script.clean_nook_office_with_tony_shark
        - script.clean_office_with_tony_shark
        - script.pause_cleaning_house_with_tony_shark
        - script.stop_cleaning_house_with_tony_shark
    action: script.turn_off
    data: {}
  - data:
      command: Hey Google, send TONY_SHARK back to the dock.
    action: google_assistant_sdk_custom.send_text_command
  - delay: "00:00:30"
  - action: input_text.set_value
    data:
      value: Docked
    target:
      entity_id: input_text.tony_shark_status
  - action: notify.notify
    data:
      message: Tony Shark has been sent back to dock.
      title: Vacuum Status

With these scripts, you’re in full control of your Shark Clean robot vacuum, allowing for seamless operation of both individual rooms and large areas. The pause, stop, and return-to-dock functions ensure that you can manage cleaning sessions without hassle.

Feel free to tweak these scripts to suit your own cleaning needs, and remember, the integration with Google Assistant makes it all incredibly easy to control with just your voice. Happy cleaning!

Get Started with the Integration

If you’re interested in seeing exactly how to get these scripts up and running, be sure to check out my detailed YouTube video on my channel. In the video, I walk you through the entire process of setting up the Shark Clean Home Assistant integration, including all the necessary steps, tools, and configurations.

Watch the video here!