Xiaomi_miio.vacuum_clean_zone and switches for each zone

I have a first generation Xiaomi vacuum which valiantly still works. But it doesn’t support room cleaning and only takes zone coordinates. Not a problem I thought and started looking at this script but it turns out that my idea to concatenate them into a list similar to the documentation isn’t working and fails with:

not a valid value for dictionary value @ data['entity_id']

What’s the best way to debug this?

alias: vacuum zones
sequence:
  - service: vacuum.send_command
    data_template:
      command: xiaomi_miio.vacuum_clean_zone
      entity_id: imagisuck
      params:
        act: start
        content: >
          {% set rooms = [ ['catarea', '[24150,24707,25221,26479]'],
                           ['bedroom1', '[23950,25336,26264,23121]'] ] %}
          {% set ns = namespace(x = '') %} {% for room in rooms if
          is_state('input_boolean.clean_' ~ room[0] ~ '_boolean', 'on') %}
              {% set ns.x = ns.x ~ room[1] ~ (',' if not loop.last else '') %}
          {% endfor %} {{ ns.x }}
        count: 1
  - service: input_boolean.turn_off
    data:
      entity_id: input_boolean.clean_catarea
  - service: input_boolean.turn_off
    data:
      entity_id: input_boolean.clean_bedroom1


# Bedroom1=23950,25336,26264,23121,1	
# Bedroom2=27261,32594,23350,36928,1		
# Bedroom3=30972,32594,27294,36783,1	
# Study=33306,32483,30983,36828,1	
# MainHallway=38217,30706,23483,32594,1	
# SmallHallway=25050,24950,24021,32579,1
# CatToiletArea=24150,24707,25221,26479,1
# MainBathroom=25193,28850,28207,26364,1
# GuestBathroom=26493,28850,28264,30936,1
# Kitchen=32007,30936,34679,27321,1
# Dining=33321,32564,38293,27221,1

The error message is complaining about this line which clearly fails to contain a proper entity_id.

      entity_id: imagisuck

If it’s a vacuum entity then it’s entity_id should be:

      entity_id: vacuum.imagisuck
1 Like

Thanks @123 that was indeed it. I also see you wrote up a nice similar answer and like the structure and will migrate to it.

1 Like

Hi all,

For some reason I’m not able to get my zone cleaning to work.
I have a toggle (button) for every room with designated room ID (through helpers)
For each button I click, I enable the helper with the room.

Code for buttons to toggle room to clean:

- type: custom:button-card
                                        entity: input_boolean.roborock_room_bureau
                                        name: Bureau
                                        icon: mdi:desk
                                        tap_action:
                                          action: call-service
                                          service: input_boolean.toggle
                                          target:
                                            entity_id: input_boolean.roborock_room_bureau
                                        state_color: true

Then, by pressing the PLAY button, I start my script room cleaning:

Button:

                                  - type: custom:button-card
                                    entity: script.roborock_room_cleaning2
                                    name: Start Schoonmaak
                                    icon: mdi:play-circle-outline
                                    tap_action:
                                      action: call-service
                                      service: script.roborock_room_cleaning2
                                    state_color: true

And the script.roborock_room_cleaning2 script:

roborock_room_cleaning2:
  mode: queued
  alias: Jarvis Room Cleaner
  max: 30
  sequence:
    - choose:
        - conditions:
            - condition: or
              conditions:
                - condition: state
                  entity_id: vacuum.jarvis
                  state: cleaning
                - condition: state
                  entity_id: vacuum.jarvis
                  state: error
          sequence:
            - wait_for_trigger:
                - platform: state
                  entity_id: vacuum.jarvis
                  to: returning
                - platform: state
                  entity_id: vacuum.jarvis
                  to: docked
              continue_on_timeout: false
              timeout: 01:30:00
            - service: vacuum.send_command
              target:
                device_id: a2c0a9115f9a20bdc3442610ffff8690
              data:
                command: app_segment_clean
                params: >
                  {% set selected_rooms = [] %}
                  {% for room in ['badkamer', 'master', 'gang', 'keuken', 'living_room', 'joosarne', 'bentjesse', 'berging', 'bureau', 'toilet'] %}
                    {% if is_state('input_boolean.roborock_room_' + room, 'on') %}
                      {% set selected_rooms = selected_rooms + [states('input_number.roborock_room_enum_' + room) | int] %}
                    {% endif %}
                  {% endfor %}
                  {{ selected_rooms }}
            - service: persistent_notification.create
              data:
                message: "variabele is : {{ selected_rooms }}"
            - wait_for_trigger:
                - platform: state
                  entity_id: vacuum.jarvis
                  to: returning
                - platform: state
                  entity_id: vacuum.jarvis
                  to: docked
              continue_on_timeout: false
              timeout: 01:30:00
        - conditions:
            - condition: or
              conditions:
                - condition: state
                  entity_id: vacuum.jarvis
                  state: returning
                - condition: state
                  entity_id: vacuum.jarvis
                  state: docked
                - condition: state
                  entity_id: vacuum.jarvis
                  state: idle
          sequence:
            - service: vacuum.send_command
              target:
                device_id: a2c0a9115f9a20bdc3442610ffff8690
              data:
                command: app_segment_clean
                params: >
                  {% set selected_rooms = [] %}
                  {% for room in ['badkamer', 'master', 'gang', 'keuken', 'living_room', 'joosarne', 'bentjesse', 'berging', 'bureau', 'toilet'] %}
                    {% if is_state('input_boolean.roborock_room_' + room, 'on') %}
                      {% set selected_rooms = selected_rooms + [states('input_number.roborock_room_enum_' + room) | int] %}
                    {% endif %}
                  {% endfor %}
                  {{ selected_rooms }}
            - wait_for_trigger:
                - platform: state
                  entity_id: vacuum.jarvis
                  to: returning
                - platform: state
                  entity_id: vacuum.jarvis
                  to: docked
              continue_on_timeout: false
              timeout: 01:30:00
      default: []

I got following error when pressing the play button:

Unable to send command to the vacuum: {‘code’: -10005, ‘message’: ‘Param size error’}

Does anyone have an idea ? Been struggling for ages now :slight_smile:

Thanks a lot !

Kr,

Bart