Roborock S5 Max, Segments and Vacuum card - Failed to call service

Hi,

I have integrated my Roborock S5 Max with HA, I have also installed Custom Vaccum Card and got it working.

Now I´m trying to add buttons to vacuum different area/room in my apartment. After many gusses, I have found my segment number (see below in the code). If I call this nummer from the services, it works, Roborock starts to vacuum correct area/room.

But if I use the vacuum card to start the process the get the error message below.

Blockquote
Failed to call service xiaomi_miio/vacuum_clean_segment. required key not provided @ data[‘segments’]

type: 'custom:vacuum-card'
entity: vacuum.xiaomi_vacuum_cleaner
image: default
language: sv-SE
stats:
  default:
    - attribute: filter_left
      unit: hours
      subtitle: Filter
    - attribute: side_brush_left
      unit: hours
      subtitle: Side brush
    - attribute: main_brush_left
      unit: hours
      subtitle: Main brush
    - attribute: sensor_dirty_left
      unit: hours
      subtitle: Sensors
  cleaning:
    - attribute: cleaned_area
      unit: m2
      subtitle: Cleaning area
    - attribute: cleaning_time
      unit: minutes
      subtitle: Cleaning tim
compact_view: false
show_name: false
show_status: true
show_toolbar: true
actions:
  - service: xiaomi_miio.vacuum_clean_segment
    name: Livingroom
    entity_id: vacuum.xiaomi_vacuum_cleaner
    segments: 17
    icon: 'mdi:sofa'
  - name: Kitchen
    service: xiaomi_miio.vacuum_clean_segment
    entity_id: vacuum.xiaomi_vacuum_cleaner
    segments: 18
    icon: 'mdi:silverware-variant'
  - name: Bedroom
    service: xiaomi_miio.vacuum_clean_segment
    entity_id: vacuum.xiaomi_vacuum_cleaner
    segments: 19
    icon: 'mdi:bed'
  - name: Hallway
    service: xiaomi_miio.vacuum_clean_segment
    entity_id: vacuum.xiaomi_vacuum_cleaner
    segments: 16
    icon: 'mdi:shoe-print'

2021-01-02 00_21_25-Home - Home Assistant

I’m just guessing here but it looks like a syntax error. The segments and entity_id should be inside data and indented accordingly:

- service: xiaomi_miio.vacuum_clean_segment
  data:
    entity_id: vacuum.xiaomi_vacuum_cleaner
    segments: 16

You may specify multiple segments in one call:

segments: [16,17,18]

Hi,

I changed to the code below and restarted HA but still getting same error.

actions:
  - service: xiaomi_miio.vacuum_clean_segment
    name: Livingroom
    data:
      entity_id: vacuum.xiaomi_vacuum_cleaner
      segments: 17
    icon: 'mdi:sofa'
  - name: Kitchen
    service: xiaomi_miio.vacuum_clean_segment
    data:
      entity_id: vacuum.xiaomi_vacuum_cleaner
      segments: 18
    icon: 'mdi:silverware-variant'

Found the solution. Insted of “data” i added “service_data:”

actions:
  - service: xiaomi_miio.vacuum_clean_segment
    name: Livingroom
    service_data:
      entity_id: vacuum.xiaomi_vacuum_cleaner
      segments: 17
    icon: 'mdi:sofa'