Selective room cleaning with HA Assist and Xiaomi Roborock S6 using python script

Google Assistant + IFTTT → HA Assist

Many of you have surely noticed that IFTTT and Google Assistant isn’t as good as it used to be, no longer can you use sentences with variables for instance.

But fear not - the python script provided in the first post can still be used together with HA Assist! Simply change automations.yaml to this:

- id: '123456789'
  alias: Clean room
  description: Start Roborock room cleaning triggered from Assist
  trigger:
   - platform: conversation
     command:
      - "(clean|vacuum) (the) {rooms}"
  action:
  - service: python_script.vacuum_room
    entity_id: vacuum.roborock
    data_template:
      area: '{{ trigger.slots.rooms }}'  

selective-room-cleaning

I created my own “selective room cleaning” UI that uses the python script in the first post. If anyone else wants to do the same, here’s what I did :slight_smile:

  1. Set up some input booleans

    input_boolean:
      clean_hallway:
        name: Hallway
        icon: mdi:image-frame
    
      clean_bedroom:
        name: Bedroom
        icon: mdi:bed-empty
    
      clean_kitchen:
        name: Kitchen
        icon: mdi:silverware-fork-knife
    
      ...
    
  2. Go to Settings > Devices & Services > Helpers and add a label selective_room_cleaning to the input helpers created

  3. Add a script that calls the python script in the first post with the names of the input booleans that are currently on

    script:
      start_selective_room_cleaning:
        alias: Start selective room cleaning
        sequence:
        - service: python_script.vacuum_room
          entity_id: vacuum.robocop
          data_template:
            area: >
              {{ label_entities('selective_room_cleaning') 
                | select('is_state', 'on') 
                | map('state_attr', 'friendly_name') 
                | list 
                | join(', ')  
              }}
    
  4. Add the switches and the script to the UI:

    • I’m using the experimental sections layout with tiles for each input helper and the script
    • To make one tile card span the whole width I put it inside a Horizontal Stack Card
  5. I added an automation as well to reset the selection of rooms once the vacuum docks

    automation:
      - id: '12345'
        alias: Reset selected rooms when docked
        trigger:
          platform: state
          entity_id: vacuum.robocop
          to: 'docked'
        action:
        - service: input_boolean.turn_off
          target:
            label_id: selective_room_cleaning
    

Happy selective room cleaning! :broom: