question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FR multi-room select

See original GitHub issue

viomi.vacuum.v7 and maybe viomi.vacuum.v6 support multi-room cleaning by define rooms count and rooms ids like: miiocli -d vacuum --ip <ip> --token <toke> raw_command set_mode_withroom [0,1,3,9,10,11] 3rd pram of set_mode_withroom is room_array_len and next are room ids.

It would be great to have feature to select(by longpress) rooms(action icons) and than fire event by start button.

For now alternative is using original Mi Home or have multi input_boolean and some logic to generate set_mode_withroom params

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kongo09commented, Jan 13, 2021

@noorbertt The map color is set in the configuration.yaml which I have added to my post above. I’m using the built-in dark theme of Home Assistant.

1reaction
kongo09commented, Jan 13, 2021

You can easily create your own multi-room setup with a bit of configuration and use the vacuum-card only for monitoring or finer control. This is how it looks for me:

View without ony room selected View with three rooms selected View once cleaning has started
2021-01-10 20 59 16 2021-01-10 20 59 46 2021-01-10 21 05 07

You can select or deselect each configured room individually. The button state changes to indicate selection. Once ready, you can hit the start button in the top left. The vacuum then starts to clean only those rooms. The map helps you to follow progress. The start button changes state to a stop button. If you click that, cleaning stops and the vacuum returns to the dock. The state of the room buttons is returned to unselected automatically, once the vacuum has docked.

To do this, I have defined toggle helpers for each room and put those into a group:

groups.yaml:

cleaning_rooms:
  name: Räume zum reinigen
  entities:
      - input_boolean.clean_bedroom
      - input_boolean.clean_corridor
      - input_boolean.clean_dining_area
      - input_boolean.clean_guest_toilet
      - input_boolean.clean_kids_room
      - input_boolean.clean_living_room
      - input_boolean.clean_master_bath
      - input_boolean.clean_study

The input_boolean themselves are defined in the HA interface under helpers: image

To render the buttons in Lovelace, I use custom:button-card with a bit of templating:

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: 'custom:button-card'
        template: buttons
        entity: vacuum.xiaomi_vacuum_cleaner
        show_name: false
        show_state: true
        icon: 'mdi:play'
        tap_action:
          action: call-service
          service: script.start_vacuum_room_cleaning
        state:
          - value: cleaning
            id: activated_state
            icon: 'mdi:stop'
            styles:
              state:
                - color: 'var(--mmp-accent-color, var(--accent-color))'
                - font-weight: bold
      - type: 'custom:button-card'
        template: buttons
        entity: input_boolean.clean_bedroom
        name: Schlafzimmer
      - type: 'custom:button-card'
        template: buttons
        entity: input_boolean.clean_master_bath
        name: Elternbad
  - type: horizontal-stack
    cards:
      - type: 'custom:button-card'
        template: buttons
        entity: input_boolean.clean_living_room
        name: Wohnzimmer
      - type: 'custom:button-card'
        template: buttons
        entity: input_boolean.clean_dining_area
        name: Essbereich
      - type: 'custom:button-card'
        template: buttons
        entity: input_boolean.clean_corridor
        name: Flur
  - type: horizontal-stack
    cards:
      - type: 'custom:button-card'
        template: buttons
        entity: input_boolean.clean_kids_room
        name: Leo's Zimmer
      - type: 'custom:button-card'
        template: buttons
        entity: input_boolean.clean_study
        name: Arbeitszimmer
      - type: 'custom:button-card'
        template: buttons
        entity: input_boolean.clean_guest_toilet
        name: Gästebad

The templates go into the Lovelace configuration and look like this:

button_card_templates:
  activated_state:
    state:
      - id: activated_state
        styles:
          card:
            - background-color: var(--primary-text-color)
            - color: var(--card-background-color)
          name:
            - color: 'var(--mmp-accent-color, var(--accent-color))'
            - font-weight: bold
          icon:
            - color: 'var(--mmp-accent-color, var(--accent-color))'
  buttons:
    template: activated_state
    aspect_ratio: 1/1
    color: var(--paper-item-icon-color)
    tap_action:
      action: toggle
      haptic: medium
    state:
      - value: 'on'
        id: activated_state
    styles:
      card:
        - '--mdc-ripple-color': black
        - '--mdc-press-opacity': 0.5
        - font-size: var(--paper-font-body1_-_font-size)
        - padding-bottom: 10px

No worries, this is not needed for the functionality here but I just show it for completeness. The room buttons toggle themselves, but the start button needs some logic with a script and more templating:

alias: Toggle vacuum room cleaning
sequence:
  - choose:
      - conditions:
          - condition: state
            entity_id: vacuum.xiaomi_vacuum_cleaner
            state: cleaning
        sequence:
          - service: vacuum.stop
            data:
              entity_id: vacuum.xiaomi_vacuum_cleaner
          - delay: '3'
          - service: vacuum.return_to_base
            data:
              entity_id: vacuum.xiaomi_vacuum_cleaner
      - conditions:
          - condition: state
            entity_id: group.cleaning_rooms
            state: 'off'
        sequence:
          - service: vacuum.start
            data: {}
            entity_id: vacuum.xiaomi_vacuum_cleaner
    default:
      - service: xiaomi_miio.vacuum_clean_segment
        data:
          entity_id: vacuum.xiaomi_vacuum_cleaner
          segments: >
            {% set rooms = expand('group.cleaning_rooms')
                | selectattr('state','eq','on')
                | map(attribute='object_id') | list %}
            {%  set mapper = {
              'clean_dining_area': 20,
              'clean_bedroom': 17,
              'clean_master_bath': 16,
              'clean_living_room': 18,
              'clean_kids_room': 21,
              'clean_study': 19,
              'clean_corridor': 22,
              'clean_guest_toilet': 4 } %}
            {% set ns = namespace(segments=[]) %}
            {% for room in rooms if room in mapper %}
              {% set ns.segments = ns.segments + [mapper[room]] %}
            {% endfor %} {{ ns.segments }}    
mode: single
icon: 'mdi:play'

Please note that if you hit the start button without any room selected, the whole house gets cleaned. Also note, that the vacuum.return_to_base service for me didn’t work during cleaning. It only stopped the vacuum but didn’t return it to base. I first had to stop it, wait a bit and then call the return service. Finally, please note that grouping the input_booleans is important here for the template to work when compiling the list of segments to clean. The mapper is needed to translate the input_boolean into the segment numbers.

Finally, I use an automation to reset the input_booleans once the vacuum has returned to its dock. Here, once more the group comes in handy:

alias: Reset cleaning rooms
description: Nach dem staubsaugen die zu reinigenden Räume zurücksetzen
trigger:
  - platform: state
    entity_id: vacuum.xiaomi_vacuum_cleaner
    to: docked
condition: []
action:
  - service: homeassistant.turn_off
    data: {}
    entity_id: group.cleaning_rooms
mode: single

I hope this helps you guys while we hope for native support by vacuum-card.

Edit:

For completeness, here is the relevant part from my configuration.yaml:

# Xiaomi Roborock
vacuum:
  - platform: xiaomi_miio
    host: !secret xiaomi_vacuum_host
    token: !secret xiaomi_vacuum_token

camera:
  - platform: xiaomi_cloud_map_extractor
    host: !secret xiaomi_vacuum_host
    token: !secret xiaomi_vacuum_token
    username: !secret xiaomi_cloud_username
    password: !secret xiaomi_cloud_password
    name: xiaomi
    draw: ["all"]
    colors:
      color_map_outside: [0x1c, 0x1c, 0x1c]
      color_path: [0xff, 0xff, 0xff]
    attributes:
      - calibration_points
      - room_numbers
      - rooms
      - charger
    map_transformation:
      scale: 2
      trim:
        right: 18
        left: 15
        top: 15
        bottom: 18

Read more comments on GitHub >

github_iconTop Results From Across the Web

Alexa Multi-Room Audio - Music and Entertainment
Select Combine Speakers and customize your speaker groups or home theater. Find additional setup instructions here for Multi-room music and Alexa Home Theater....
Read more >
How to group multiple Amazon Echo devices for music
Select Devices from the bottom bar; Tap the + in the top right corner; Tap on "Combine speakers" from the menu; For multi-room...
Read more >
When trying to set up multi room music, I select one device ...
When trying to set up multi room music, I select one device and the other one says Network Error. Both are on the...
Read more >
My Media for Alexa Multiroom Audio Support
Tap the room in which the Alexa you will instruct resides: · Find 'Speakers' and tap 'Change': · Select multiple Speakers you want...
Read more >
How to Set Up Multi-Room Music on Your Alexa Speakers
This built-in feature allows you to stereo pair your speakers for ... tap the plus sign icon and select Combine Speakers > Multi-room...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found