Lovelace: Simple Xiaomi Vacuum Card

I had the similar issues. I possibly tripped up on a way to make it work.
This is how I got it to work.

  1. You need a token, You must have the token for you login: Found a website to get the token for the Roborock:
    https://www.youtube.com/watch?v=HNgqfa-E5fA&feature=youtu.be

  2. Install xiaomi-vacuum-card.js: U can install from HACS, under frontend, look for (Simple vacuum card) xiaomi-vacuum-card.js - Ensure you look at the path it installs, if using HACS: go to Config/lovelace dashboards. At the top of page click on resources and will will see the location: /hacsfiles/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js. (This was my issue) I moved the file to: /local/xiaomi-vacuum-card.js. (Note: the actual location is /www/xiaomi-vacuum-card.js). The www file is considered local.
    Here are the configs used:

Lovelace Yaml / Raw Configurator

  • type: ‘custom:xiaomi-vacuum-card’
    entity: vacuum.xiaomi_vacuum_cleaner
    backgroud: /local/vacuum.png
    name: Xiaomi Vacuum

Configuration Yaml:

  • platform: xiaomi_miio
    host: 10.0.0.32
    token: 6d4950xxxxx6766c4b304636746e3162

lovelace:
resources:
- url: /local/xiaomi-vacuum-card.js
type: module

Sure I left out a few thing, it’s 4:30 am, holler if I can be of assistance, but once you get your token (if you don’t have it) and reference the location of js file, you should be on your way.

Hi
since my update to 0.116 I can’t see the details of the vacuum when I click on the name
is it normal? if not, any clue?

Hello,
Is it possible to add the translation for the status?
Actually, I have added this (personal code):

            var value = isValid
                ? computeFunc(this.stateObj.attributes[data.key]) + (data.unit || '')
                : this._hass.localize('state.default.unavailable');
            switch(value) {
                case 'Charging':
                    value = 'Charge';
                    break;
                case 'Cleaning':
                    value = 'Nettoyage';
                    break;
                case 'Returning home':
                    value = 'Retour station';
                    break;
                case 'Waiting':
                    value = 'En attente';
                    break;
                case 'Idle':
                    value = 'Au repos';
                    break;
                case 'Sleeping':
                    value = 'En veille';
                    break;
                case 'Paused':
                    value = 'En pause';
                    break;
                case 'Charger disconnected':
                    value = 'Chargeur déconnecté';
                    break;
                default:
                    value = value;
                    break;
            }
            const attribute = html`<div>${data.icon && this.renderIcon(data)}${(data.label || '') + value}</div>`;

I don’t know enough to make cleaner code, but I think it would be possible to do a mapping

Anyone know how to customize style with card-mod and this card?

Have a question; I hide some default attributes like clean_area, but I don’t like the formatting (too many decimals). That is why I converted these attributes via value templates to new sensors. How can I input these sensors into the card on the original spot or the clean_area attribute, so in the right attributes column?

These are my new template sensors:

- platform: template
  sensors:
    vacuum_state:
      value_template: "{{ states('vacuum.zuigertje') }}"
    vacuum_last_run:
      value_template: "{{ as_timestamp(state_attr('vacuum.zuigertje', 'clean_stop')) | timestamp_custom('%d-%m-%Y') }}"
    vacuum_last_qm:
      value_template: "{{ state_attr('vacuum.zuigertje', 'clean_area') | int }} m²"

Is someone running this card with Valetudo? I have a Roborock S5 with standard Valetudo on it. The card shows only battery and fan state + the button row. Status is unavailable. Also my brush and filter count isn’t represented as attributes of the vacuum.entitiy but as sensors themselfes. Can I still implement them?
I defined the vendor as ‘valetudo’.
It looks like that:
vacuum_card

yaml is quite simple atm.:

type: 'custom:xiaomi-vacuum-card'
entity: vacuum.robobert
vendor: valetudo

Help would be appreciated! Thanks!

Which version of Valetudo are you running?

The latest update completely changed how the vacuum’s attributes are made available to Home Assistant via MQTT. Until this card is updated, it will only work with Valetudo up to version 0.61

As an alternative, this card allows you display attributes from separate entities:

I’m currently running Valetudo 2021.02.0.
Would make Valetudo RE any difference?

Thank’s for the alternative card. I’m already using it. But for one of my Lovelace Uis the “simple Xiaomi Vacuum Card” would be a nicer fit.

No direct experience of Valetudo RE, so wouldn’t know really. You could downgrade the firmware on your vacuum to Valutudo 0.61, but that seems like a lot of hassle just for a Lovelace view.

If you are looking for a more compact view, you could mess around with card-mod on the alternative card I suggested, and set the image path to []. Here’s an example:

And the code (I’ve also changed the card border-radius to match my theme, and the background on the toolbar):

      - type: custom:vacuum-card
        card_mod:
          style:
            .: |
              ha-card {
                border-radius: var(--ha-card-border-radius) !important;
              }
              ha-card.type-custom-vacuum-card div.toolbar {
                background: rgba(0,0,0,1);
              }
              ha-card.type-custom-vacuum-card div.preview img.vacuum.docked {
                margin-top: 0px;
                margin-bottom: 0px;
              }
              ha-card.type-custom-vacuum-card div.preview img.vacuum.returning {
                margin-top: 0px;
                margin-bottom: 0px;
              }
              ha-card.type-custom-vacuum-card div.preview img.vacuum.cleaning {
                margin-top: 0px;
                margin-bottom: 0px;
              }
              ha-card.type-custom-vacuum-card div.preview img.vacuum.idle {
                margin-top: 0px;
                margin-bottom: 0px;
              }
        entity: vacuum.rockrobo_downstairs
        image: []
        stats:
          [AND SO ON]

Thomas Loven’s Card-mod:

Thanks for the tip, will play around with it a little bit.
I still hope that @benct is gonna release an update of his card for the current Valetudo version :slight_smile:

@benct Hello, I am allowed to reuse your card for another project. I have no knowledge of java and css but I managed to adapt the start of my map. Would you know how I could adapt the config.show (for my config config.show.body) button click on toogle. The ideal would be to simulate a click = true a click = false but at startup it is false that it remains on false without putting it in the config otherwise we can no longer modify the name for example

My card

The current rendering in 2.0.0

5e3ce73bc4b37937b9590b7bffddcb8ced6507ed_2_231x250

1 Like

I can’t seem to get this working anymore

I have it installed via hacs and I confirmed that hacs did indeed install the following files

\www\community\lovelace-xiaomi-vacuum-card\xiaomi-vacuum-card.js
\www\community\lovelace-xiaomi-vacuum-card\xiaomi-vacuum-card.js.gz

I verified that i can see the files in a web browser by visiting - http://www.my-home-assistant-url.com/community/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js

I confirmed that hacs did add the custom card in the lovelace resources, by checking in the GUI
URL: /hacsfiles/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js
Resource Type: Javascript Module

When I try to use the card I get the following error - Custom element doesn’t exist: xiaomi-vacuum-card.

I have tried restarting home assistant and deleting and uninstalling the plugin and then reinstalling. Is there a problem with the latest version of home assistant?

I have the same problem…

Hi!

This card stopped working now in " Home Assistant 2021.11.0" when they changed from attributes to sensors. Will there be a fix comming for this?

see https://github.com/benct/lovelace-xiaomi-vacuum-card/issues/84

1 Like

Can i get help, im trying to figure out how to convert my duration from seconds to hrs

type: vertical-stack
cards:
  - type: button
    tap_action:
      action: toggle
    entity: vacuum.s6_vacuum_cleaner
  - type: entities
    entities:
      - entity: binary_sensor.pure_mop_attached
      - entity: binary_sensor.pure_water_box_attached
      - entity: sensor.pure_last_clean_area
      - entity: sensor.pure_last_clean_duration
        type: custom:multiple-entity-row
        attributes:
          clean_area:
            key: last_clean_duration
            label: 'Last Cleaned Duration'
            unit_time: 'h'
            round: 'n'
      - entity: sensor.pure_last_clean_end
      - entity: sensor.pure_last_clean_start
      - entity: sensor.pure_filter_left
      - entity: sensor.pure_main_brush_left
      - entity: sensor.pure_sensor_dirty_left
      - entity: sensor.pure_side_brush_left
      - entity: sensor.pure_total_clean_count
      - entity: sensor.pure_total_duration
    state_color: true

You can create sensor and calculate it. This is my example, I calculated days, hours and minutes:

  - sensor:
      - name: Side brush remain time
        state: >-
          {% set days = (((states('sensor.roborock_qrevo_side_brush_time_left')|float) % (86400 * 30))|float) / 86400 |float %}
          {% set hours = (((states('sensor.roborock_qrevo_side_brush_time_left')|float) % 86400)|float) / 3600 |float %}
          {% set minutes = (((states('sensor.roborock_qrevo_side_brush_time_left')|float) % 3600)|float) / 60 |float %}
          {{ days | round(0, 'floor')}}d {{ hours | round(0, 'floor')}}h {{ minutes | round(0, 'floor') }}m```