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