Xiaomi Vacuum cleaner Card

hey @gurbina93

thanks for this.

quick question? are you still able to use the custom:vertical-stack-in-card in 0.86.1? I am trying your code out in the on screen lovelace editor i.e. not the ui-lovelace.yaml and I get this error :

YAML Error: TypeError: Cannot read property 'startsWith' of undefined

Any ideas?

Hello, I love this but I am struggling to get the actions to work. I have stripped everything out and just have the start button and I click and nothing happens. Any idea please? on the latest version of HA

elements:
  - type: icon
    icon: 'mdi:play'
    tap_action:
      action: call_service
      service: vacuum.start
      service_data:
        entity_id: vacuum.renvac
    style:
      color: '#000000'
      left: 20%
      top: 90%
image: /local/lovelace/xiaomi-roborock.png
title: Vacuum
type: picture-elements

Action should be call-service, a dash instead of the underscore you currently have.

1 Like

Hey, I took ur card and added it, but the operation or maintaince information wont show up in that card :confused:
Do you know why?

@gurbina93 did you manage to sort out your code ?

You need to setup the template sensors from this file: https://github.com/jardiamj/homeassistant/blob/master/sensors.yaml

Question to your automations; The “automatic start” and “daily cleaning”, you have set this as a condition " as_timestamp(utcnow()) + 1200 - as_timestamp(states.vacuum.xiaomi_vacuum_cleaner.last_updated) > 10080 " what does it mean?

1 Like

I trigger the vacuum as soon no one is at home. But I want to avoid that the vacuum is triggered every hour or so.
Therefore I trigger the vacuum as soon no one is at home and the last clean was done more then 4 hours before.

I’ve created a more theme-friendly transparant background picture. You can find it here

https://dsc.cloud/razzi/vacuum_gray.png

Hey!

How do i add this card with the latest update, the lovelace.yaml is not used anymore.

thanks in advanced!

Hello, thank you for the help to everybody, got my card working perfect.

Captura

There´s one thing i want to add but can´t find where. I want to the possibility to change the fan speed in the same buttonon Mode or in a new one. Can it be done???

Thank to you all.

in automation:

  - id: vacuum_fan_speed
    alias: Vacuum Potenza di aspirazione
    initial_state: true
    trigger:
      platform: state
      entity_id: input_select.vacuum_fan_speed_list
    action:
      - service_template: >
          {{ {
          'Silenzioso' : 'script.vacuum_set_quiet',
          'Bilanciato' : 'script.vacuum_set_balanced',
          'Turbo' : 'script.vacuum_set_turbo',
          'Massima potenza' : 'script.vacuum_set_max',
          'Mocio' : 'script.vacuum_set_mop'
          } [trigger.to_state.state] }}

In lovelace:

- type: state-label
  entity: sensor.vacuum_fan_speed
  prefix: 'Modo: '
  suffix: .
  tap_action: 
    action: call-service
    service: input_select.select_next
    service_data:
      entity_id: input_select.vacuum_fan_speed_list
  style:
    pointer-events: auto

*Edit pointer-events: auto

1 Like

Hi caiosweet, tried your config but i can´t get to tap on it and chage speed and modo y duplicated.
foti1

  • entity: sensor.vacuum_fan_speed
    prefix: 'Modo: ’
    style:
    color: ‘#FFFFF
    font-family: Trebuchet MS
    font-size: 90%
    font-weight: bold
    left: 30%
    pointer-events: none
    top: 40%
    transform: ‘translate(0%,-50%)’
    suffix: .
    tap_action:
    action: call-service
    service: input_select.select_next
    service_data:
    entity_id: input_select.vacuum_fan_speed_list
    type: state-label

Thank you.

Yes, you’re right, put this under style
pointer-events: auto

Thanks for this… I have set it up as described but when I click on it, it calls the script but nothing happens.

do I need some other scripts please?

     - service_template: >
         {{ {
         'Quiet' : 'script.vacuum_set_quiet',
         'Balanced' : 'script.vacuum_set_balanced',
         'Turbo' : 'script.vacuum_set_turbo',
         'Maximum' : 'script.vacuum_set_max',
         'Mop' : 'script.vacuum_set_mop'
         } [trigger.to_state.state] }}

You can see here. under script: pkg_vacuum_xiaomi.yaml

I modified the code for other needs, I use a ‘variable’ for the vacuum entity_id.
Simply tests to change names more easily … hopefully: 0)

script:
  ### Imposta Modalità Aspirazione
  vacuum_set_quiet:
    sequence:
      - service: vacuum.set_fan_speed
        data_template:
          entity_id: >
            {{states('input_text.vacuum')}}
        #data:
          fan_speed: Quiet

  vacuum_set_balanced:
    sequence:
      - service: vacuum.set_fan_speed
        data_template:
          entity_id: >
            {{states('input_text.vacuum')}}
        #data:
          fan_speed: Balanced

  vacuum_set_turbo:
    sequence:
      - service: vacuum.set_fan_speed
        data_template:
          entity_id: >
            {{states('input_text.vacuum')}}
        #data:
          fan_speed: Turbo
 
  vacuum_set_max:
    sequence:
      - service: vacuum.set_fan_speed
        data_template:
          entity_id: >
            {{states('input_text.vacuum')}}
        #data:
          fan_speed: Max

  vacuum_set_mop:
    sequence:
      service: vacuum.set_fan_speed
      data_template:
        entity_id: >
          {{states('input_text.vacuum')}}
      #data:
        fan_speed: 105
2 Likes

perfect… thank you

not working for me still… it now shows the mode as 103, 105, etc… I guess it needs to be rooted for this to work?

No, there are several ways to do it …
I have this…(but I do not know if the code is right, but it works)

sensor:
  - platform: template
    sensors:
      vacuum_fan_speed:
        entity_id: *vacuum
        value_template: >
          {% set vacuum = states('input_text.vacuum') %}
          {% if (state_attr(vacuum, 'fan_speed')) in (101, 'Quiet') -%}
            Silenzioso
          {% elif (state_attr(vacuum, 'fan_speed')) in (102, 'Balanced') -%}
            Bilanciato
          {% elif (state_attr(vacuum, 'fan_speed')) in (103,'Turbo') -%}
            Turbo
          {% elif (state_attr(vacuum, 'fan_speed')) in (104, 'Max') -%}
            Massima potenza
          {% elif (state_attr(vacuum, 'fan_speed')) in (105,) -%}
            Mocio
          {% else %}
            {{ state_attr(vacuum, 'fan_speed') }}
          {% endif %}

but you can also do it … or similar…

input_select:
  fan_mode:
    name: Fan Mode
    options:
      - "Quiet"
      - "Balanced"
      - "Turbo"
      - "Max"
      - "Mop"
      #initial:
    icon: mdi:fan

automation:
  - alias: Set Fan Mode
    initial_state: true
    trigger:
      platform: state
      entity_id: input_select.fan_mode
    action:
    - service: vacuum.set_fan_speed
      data_template:
        entity_id: vacuum.xiaomi_vacuum_cleaner
        #fan_speed: "{{ states('input_select.fan_mode') }}"
        fan_speed: >
          {% if (states('input_select.fan_mode')) == 'Mop' -%}
            105
          {% else %}
            {{ states('input_select.fan_mode') }}
          {% endif %}

  - alias: Update Input Select Fan Mode
    initial_state: true
    trigger:
    ##TODO
      - platform: state
        entity_id: sensor.vacuum_fan_speed
      - platform: homeassistant
        event: start
    condition:
      condition: template
      value_template: "{{ state_attr('vacuum.xiaomi_vacuum_cleaner', 'fan_speed') != states('input_select.fan_mode') }}"
    action:
      - service: input_select.select_option
        entity_id: input_select.fan_mode
        data_template:
          option: "{{ state_attr('vacuum.xiaomi_vacuum_cleaner', 'fan_speed') }}"

*TODO I have not tested

I dont get this card to work. Its only loading the background not the picture or stats and scripts.
What could be wrong?