Xiaomi Vacuum cleaner Card


#85

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?


#86

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

#87

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


#88

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?


#89

@gurbina93 did you manage to sort out your code ?


#90

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


#91

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?


#92

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.


#93

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

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


#94

Hey!

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

thanks in advanced!


#95

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.


#96

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


#97

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.


#98

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


#99

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] }}

#100

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

#101

perfect… thank you


#102

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?


#103

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


#104

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