Xiaomi Vacuum cleaner Card

dum question maybe, did you change the entity names to your roborock?

Looking through the code i can at least see two different enitity names

vacuum.xiaomi_vacuum_cleaner
vacuum.chen

Where? I thought I’ve chaged them all to vacuum.chen?

cards:
  - elements:
      - entity: vacuum.chen
        icon: 'mdi:bell-ring'
        service: vacuum.locate
        style:
          color: '#3090C7'
          left: 80%
          top: 90%
        tap_action: call-service
        type: icon
      - entity: vacuum.chen
        icon: 'mdi:crosshairs'
        service: vacuum.clean_spot
        style:
          color: '#3090C7'
          left: 65%
          top: 90%
        tap_action: call-service
        type: icon
      - entity: vacuum.chen
        icon: 'mdi:home'
        service: vacuum.return_to_base
        style:
          color: '#3090C7'
          left: 50%
          top: 90%
        tap_action: call-service
        type: icon
      - entity: vacuum.chen
        icon: 'mdi:stop'
        service: vacuum.stop
        style:
          color: '#3090C7'
          left: 35%
          top: 90%
        tap_action: call-service
        type: icon
      - type: icon
        icon: 'mdi:play'
        tap_action: call-service
        entity: vacuum.chen
        service: vacuum.start
        style:
          color: '#3090C7'
          left: 20%
          top: 90%
      - entity: sensor.vacuum_operation
        style:
          background-color: '#3090C7'
          border-color: 'rgb(34, 154, 210)'
          border-radius: 6px
          color: 'rgb(255, 255, 255)'
          font-family: Trebuchet MS
          font-size: 90%
          font-weight: bold
          left: 1%
          pointer-events: none
          top: 10%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: sensor.vacuum_accessories
        style:
          background-color: '#3090C7'
          border-color: 'rgb(34, 154, 210)'
          border-radius: 6px
          color: 'rgb(255, 255, 255)'
          font-family: Trebuchet MS
          font-size: 90%
          font-weight: bold
          pointer-events: none
          right: 1%
          top: 10%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: vacuum.chen
        style:
          background-color: '#cccccc'
          border-color: 'rgb(34, 154, 210)'
          border-radius: 6px
          color: 'rgb(255, 255, 255)'
          font-family: Trebuchet MS
          font-size: 150%
          font-weight: bold
          right: 43%
          top: 14%
          transform: 'translate(0%,-50%)'
        tap_action: more-info
        type: state-label
      - entity: sensor.vacuum_cleanmainbrush
        style:
          border-color: 'rgb(34, 154, 210)'
          border-right-style: solid
          color: '#ffffff'
          font-family: Trebuchet MS
          font-size: 76%
          font-weight: bold
          pointer-events: none
          right: 1%
          top: 35%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: sensor.vacuum_cleansidebrush
        style:
          border-color: 'rgb(34, 154, 210)'
          border-right-style: solid
          color: '#ffffff'
          font-family: Trebuchet MS
          font-size: 76%
          font-weight: bold
          pointer-events: none
          right: 1%
          top: 45%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: sensor.vacuum_cleanfilter
        style:
          border-color: 'rgb(34, 154, 210)'
          border-right-style: solid
          color: '#ffffff'
          font-family: Trebuchet MS
          font-size: 76%
          font-weight: bold
          pointer-events: none
          right: 1%
          top: 55%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: sensor.vacuum_sensordirtyleft
        style:
          border-color: 'rgb(34, 154, 210)'
          border-right-style: solid
          color: '#ffffff'
          font-family: Trebuchet MS
          font-size: 76%
          font-weight: bold
          pointer-events: none
          right: 1%
          top: 65%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: sensor.vacuum_status
        style:
          border-color: '#3090C7'
          border-left-style: solid
          color: '#ffffff'
          font-family: Trebuchet MS
          font-size: 80%
          font-weight: bold
          left: 1%
          pointer-events: none
          top: 40%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: sensor.vacuum_battery
        style:
          border-color: 'rgb(34, 154, 210)'
          border-left-style: solid
          color: '#ffffff'
          font-family: Trebuchet MS
          font-size: 80%
          font-weight: bold
          left: 1%
          pointer-events: none
          top: 50%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: sensor.vacuum_fan_speed
        style:
          border-color: 'rgb(34, 154, 210)'
          border-left-style: solid
          color: '#ffffff'
          font-family: Trebuchet MS
          font-size: 80%
          font-weight: bold
          left: 1%
          pointer-events: none
          top: 60%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: sensor.vacuum_cleaned_area
        prefix: 'Area:'
        style:
          color: '#84a6ba'
          font-family: Trebuchet MS
          font-size: 80%
          font-weight: bold
          left: 31%
          pointer-events: none
          top: 79%
          transform: 'translate(0%,-50%)'
        type: state-label
      - entity: sensor.vacuum_cleaning_time
        prefix: 'Time:'
        style:
          color: '#84a6ba'
          font-family: Trebuchet MS
          font-size: 80%
          font-weight: bold
          left: 51%
          pointer-events: none
          top: 79%
          transform: 'translate(0%,-50%)'
        type: state-label
    image: /local/images/Roborock_Chen.jpg
    title: null
    type: picture-elements
  - entities:
      - entity: input_select.vacuum_room
    type: entities
  - columns: 2
    entities:
      - entity: input_boolean.disable_dustbin_notification
        name: Dustbin Notifikation
      - entity: input_boolean.disable_weekly_vacuum
        name: Annullér Ugentlig Støvsugning
    type: glance
type: 'custom:vertical-stack-in-card'

Ohh, ok i was looking in the wrong code snip. does the functions work if you just add them in a enitity card?

I will give it a shot. Do you have it working yourself?

In the code given above there is a syntax error on the service call. I‘m not at my PC so I can‘t check how I changed the code. But maybe the hint helps.

I just cant see it :frowning: I can wait until you are back at your machine!

1 Like
    - type: icon
      icon: 'mdi:crosshairs
      tap_action:
        action: call-service
        service: vacuum.clean_spot
        service_data:
          entity_id: vacuum.chen
      style: ...

Try this, I just typed this with my phone but I hope it works. There was some breaking change which broke the functionality some versions back.

Error while executing automation automation.vacuum_selection_of_the_area. Invalid data for call_service at pos 1: Service #מטבח script.vacuum_kitchen does not match format <domain>.<name>

I get this error when trying to do a zone cleanup with the crosshair button

Yes, code changed to call a service… Check the Lovelace page

That’s how I do the service call:

          tap_action:
            action: call-service
            entity: vacuum.robbi_kraemer
            service: vacuum.stop
1 Like

Thanks! That did the trick!

I get this error when trying to use this few lines of code:

- alias: '[Vacuum] Start Weekly Vacuum'
  trigger:
    platform: time
    minutes: '/45'
  condition:
    condition: and
    conditions:
    - condition: time
      weekday:
      - mon
      - wed
      - fri
    - condition: state
      entity_id: alarm_control_panel.house
      state: 'armed_away'
    - condition: state
      entity_id: input_boolean.weekly_vacuum_first_run
      state: 'off'
    - condition: state
      entity_id: input_boolean.disable_weekly_vacuum
      state: 'off'
  action:
  - delay: '00:00:15'
  - service: vacuum.start
    entity_id: vacuum.chen
  - service: homeassistant.turn_on
    entity_id: input_boolean.weekly_vacuum_first_run

Then I get this error:

Invalid config for [automation]: [minutes] is an invalid option for [automation]. Check: automation->trigger->0->minutes.

So I guess the ‘/45’ doesn’t work for me.
What am I doing wrong?

Side question: the trigger tries to fire every 45 minutes if the conditions are true right?

use time pattern. this was a breaking change a couple updates ago.

  trigger:
    platform: time_pattern
    # You can also match on interval. This will match every 5 minutes
    minutes: '/5'

Exactly - was so blind I only saw the time and misses the _pattern!

Thanks!

1 Like

Finally I decided to make a custom card for my vacuum.

Final result:

Below these are the images for the background and the mi logo on the corner.
Just place them on /config/www/img/





Code for lovelace:

type: picture-elements
image: /local/img/vacuum_blue.jpg
elements:
  - entity: vacuum.xiaomi_vacuum_cleaner
    style:
      '--paper-item-icon-color': '#FFF'
      left: 5%
      top: 5%
      z-index: 1
    tap_action:
      action: more-info
    type: state-icon
  - entity: script.vacuum_start
    style:
      '--paper-item-icon-color': '#FFF'
      left: 95%
      top: 5%
      z-index: 1
    tap_action:
      action: toggle
    type: state-icon
  - entity: script.vacuum_pause
    style:
      '--paper-item-icon-color': '#FFF'
      left: 95%
      top: 15%
      z-index: 1
    tap_action:
      action: toggle
    type: state-icon
  - entity: script.vacuum_stop
    style:
      '--paper-item-icon-color': '#FFF'
      left: 95%
      top: 25%
      z-index: 1
    tap_action:
      action: toggle
    type: state-icon
  - entity: script.vacuum_return_to_base
    style:
      '--paper-item-icon-color': '#FFF'
      left: 95%
      top: 35%
      z-index: 1
    tap_action:
      action: toggle
    type: state-icon
  - entity: script.vacuum_locate
    style:
      '--paper-item-icon-color': '#FFF'
      left: 95%
      top: 45%
      z-index: 1
    tap_action:
      action: toggle
    type: state-icon
  - entity: sensor.vacuum_battery
    style:
      background-color: '#278ef7'
      color: '#FFF'
      font-family: Trebuchet MS
      font-size: 90%
      font-weight: bold
      left: 0%
      pointer-events: none
      text-shadow: 1px 1px black
      top: 60%
      transform: none
      z-index: 1
    tap_action:
      action: none
    type: state-label
  - entity: sensor.vacuum_status
    style:
      background-color: '#278ef7'
      color: '#FFF'
      font-family: Trebuchet MS
      font-size: 90%
      font-weight: bold
      left: 0%
      pointer-events: none
      text-shadow: 1px 1px black
      top: 75%
      transform: none
      z-index: 1
    tap_action:
      action: none
    type: state-label
  - entity: sensor.vacuum_cleaned_area
    style:
      background-color: '#278ef7'
      color: '#FFF'
      font-family: Trebuchet MS
      font-size: 90%
      font-weight: bold
      left: 0%
      pointer-events: none
      text-shadow: 1px 1px black
      top: 90%
      transform: none
      z-index: 1
    tap_action:
      action: none
    type: state-label
  - image: /local/img/mi.png
    style:
      left: 93%
      top: 93%
      width: 7%
      z-index: 0
    tap_action:
      action: none
    type: image
  - camera_image: camera.vacuum_map
    entity: camera.vacuum_map
    style:
      height: 80%
      left: 10%
      top: 10%
      transform: none
      width: 80%
      z-index: 0
    tap_action:
      action: more-info
    type: image

Code for configuration.yaml:

homeassistant:
  customize:
    vacuum.xiaomi_vacuum_cleaner:
      friendly_name: "Roborock S50"
    script.vacuum_start:
      friendly_name: "Iniciar limpeza"
      icon: 'mdi:play'
    script.vacuum_pause:
      friendly_name: "Pausar"
      icon: 'mdi:pause'
    script.vacuum_stop:
      friendly_name: "Parar"
      icon: 'mdi:stop'
    script.vacuum_return_to_base:
      friendly_name: "Regressar à base"
      icon: 'mdi:vhs'
    script.vacuum_locate:
      friendly_name: "Localizar"
      icon: 'mdi:map-marker'

script:
  vacuum_start:
    sequence:
      - service: vacuum.start
        data: { "entity_id":"vacuum.xiaomi_vacuum_cleaner"}
  vacuum_pause:
    sequence:
      - service: vacuum.pause
        data: { "entity_id":"vacuum.xiaomi_vacuum_cleaner"}
  vacuum_stop:
    sequence:
      - service: vacuum.stop
        data: { "entity_id":"vacuum.xiaomi_vacuum_cleaner"}
  vacuum_return_to_base:
    sequence:
      - service: vacuum.return_to_base
        data: { "entity_id":"vacuum.xiaomi_vacuum_cleaner"}
  vacuum_locate:
    sequence:
      - service: vacuum.locate
        data: { "entity_id":"vacuum.xiaomi_vacuum_cleaner"}

sensor:
  - platform: template
    sensors:
      # Status
      vacuum_status:
        friendly_name: "Estado"
        entity_id:
          - vacuum.xiaomi_vacuum_cleaner
        value_template: >
          {% set val =  states.vacuum.xiaomi_vacuum_cleaner.attributes.status  %}
          {% if val == 'Charging' %}
            A Carregar
          {% elif val == 'Cleaning' %}
            A limpar
          {% elif val == 'Returning home' %}
            Regressar à base
          {% elif val == 'Idle' %}
            Parado
          {% elif val == 'Paused' %}
            Pausado
          {% else %}
            
          {% endif %}
        icon_template: >
          {% set val =  states.vacuum.xiaomi_vacuum_cleaner.attributes.status  %}
          {% if val == 'Charging' %}
            mdi:battery-charging
          {% elif val == 'Cleaning' %}
            mdi:move-resize
          {% elif val == 'Returning home' %}
            mdi:keyboard-return
          {% elif val == 'Idle' %}
            mdi:dots-horizontal
          {% elif val == 'Paused' %}
            mdi:pause-circle
          {% else %}
            mdi:help-circle
          {% endif %}
      # Battery
      vacuum_battery:
        friendly_name: "Bateria"
        entity_id:
          - vacuum.xiaomi_vacuum_cleaner
        value_template: '{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.battery_level }}'
        unit_of_measurement: '%'
        icon_template: '{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.battery_icon }}'
      # Cleaned area
      vacuum_cleaned_area:
        friendly_name: "Área da última limpeza"
        unit_of_measurement: 'm²'
        entity_id:
          - vacuum.xiaomi_vacuum_cleaner
        value_template: '{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.cleaned_area }}'
        icon_template: 'mdi:ruler'

For the map just search for valetudo firmware for the robot

4 Likes

Choose a room to clean (input_select.vacuum_room) not working for me (0.90.2 is my HA version), I just copy all your code, any ideas? It shows in the UI card without any error but it does nothing.

Also, can the backgroud image change when my HA theme changes?

Edit: choose a room to clean now working

i got it to work here is a picture :slight_smile:
billede

Now i only need to figure out how i define an area

Hi all,

Thanks for sharing your cards. I modified a picture a little. Mine looks like that:


I cant get the Input_select to work. How exactly should it work? It should start zoned cleanup right after you select the room or you need to select the room and press start? i dont quite get it. I have the zones defined and I ask Google Assistant throught IFTTT to do it.
EDIT: Disregard previous. My automation was switched off :see_no_evil:

1 Like

Hi @uk4pyc ! how are you?
can you share you config? i can run the script manually, but from the input_select nothing happens.
Regards,