Skip to content

Instantly share code, notes, and snippets.

@thomasloven
Last active July 7, 2024 18:12
Show Gist options
  • Save thomasloven/bf85981fa3e570ec10dff4a2f288ffa5 to your computer and use it in GitHub Desktop.
Save thomasloven/bf85981fa3e570ec10dff4a2f288ffa5 to your computer and use it in GitHub Desktop.
Make Xiaomi vacuum cleaner vacuum certain rooms by input_boolean state. Requires Home Assistant 2021.2.0 or later.
blueprint:
name: Xiaomi vacuum- clean rooms
description: |
## Clean the specified rooms
This works for Xiaomi vacuum cleaners which have room recognition and cleaning.
Vacuum specific rooms based on the state of a number of [Toggle Helper entities](/config/helpers) (`input_boolean`).
**This automation does not have any own triggers, but must be triggered manually or by an
`automation.trigger` service call.**
### Room designations parameter
Room Designations needs to be a number of lines on the format `<entity_id>: <room number>` where `<entity_id>` is the entity id of your Toggle Helper and `<room number>` is the number your vacuum has assigned to the room.
Example:
```
input_boolean.clean_kitchen: 22
input_boolean.clean_livingroom: 23
inut_boolean.clean_bedroom: 1
```
To find your `<room number>`s I suggest using the following procedure:
- Open up the Xiaomi Home app on your phone and go to your vacuums map.
- In Home Assistant, Go to [Developer Tools - Services](/developer-tools/service)
- Select the service `vacuum.send_command` service.
- Select your vacuum cleaner.
- In the Service Data box, add the following lines:
`command: app_segment_clean`
`params: 1`
- Click the "Call Service" button.
- In 5-10 seconds, you should be able to see on the map in the app which room the vacuum is going for.
- Change the `params:` option and repeat.
Don't worry if there are large intervals that seem not to be assigned to any room.
In my house room `1` is the kitchen, and the next one is the living room at `16`.
domain: automation
input:
vacuum:
name: Vaccum cleaner
description: ""
default: vacuum.xiaomi
selector:
entity:
domain: vacuum
rooms:
name: Room designations
description: Which input_boolean relates to which room
selector:
object:
default:
input_boolean.clean_kitchen: 16
input_boolean.clean_livingroom: 23
inut_boolean.clean_bedroom: 1
trigger: []
condition: []
action:
- variables:
rooms: !input rooms
room_list: >-
[{% for k,v in rooms.items() -%}
{%- if is_state(k, 'on') -%}{{v | join (",") if v is iterable else v}},{%- endif -%}
{%- endfor %}]
- service: vacuum.send_command
data:
entity_id: !input vacuum
command: app_segment_clean
params: "{{room_list}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment