Xiaomi Vacuum cleaner Card

I plan to root my vacuum and then create card with live map view. Hopefully it will also remove the need for manual map calibration. When it all will be done Mi Home will be almost fully recreatable in HA :wink:

4 Likes

i am reletiv new to HA and custom cards,
can some help me to get this? i have inte vacuum “installd” in config, i can see it in my HA.
but i dont have lovelace.ymal bescus i cant use the gui card. i think:S

Thanks! I adapted it to english, and valetudo mqtt vac!

1 Like

cleaned my sensors of the vacuum today and want to reset the sensor_dirty_left, but I can’t get it reseted

service: vacuum.send_command

{
  "entity_id": "vacuum.xiaomi_vacuum_cleaner",
"command": "reset_consumable",
"params": { "ensor_dirty_left": "0" }
}

anyone can help out?!

  vacuum_reset_main_brush:
    alias: "Reset Spazzola Principale"
    sequence:
      - service: vacuum.send_command
        data_template:
          entity_id: >
            {{states('input_text.vacuum')}}
          command: reset_consumable
          params: main_brush_work_time

  vacuum_reset_side_brush:
    alias: "Reset Spazzola Laterale"
    sequence:
      - service: vacuum.send_command
        data_template:
          entity_id: >
            {{states('input_text.vacuum')}}
          command: reset_consumable
          params: side_brush_work_time

  vacuum_reset_filter:
    alias: "Reset Filtro"
    sequence:
      - service: vacuum.send_command
        data_template:
          entity_id: >
            {{states('input_text.vacuum')}}
          command: reset_consumable
          params: filter_work_time

  vacuum_reset_sensor:
    alias: "Reset Sensori"
    sequence:
      - service: vacuum.send_command
        data_template:
          entity_id: >
            {{states('input_text.vacuum')}}
          command: reset_consumable
          params: sensor_dirty_time

*entity_id :vacuum.xiaomi_vacuum_cleaner (your entity_id)
** For DND and ZONE the template does not work. But with a few lines in python_script it is possible.

For example vacuum_dnd.py

start = (hass.states.get('input_datetime.dnd_start').state).split(":")
end = (hass.states.get('input_datetime.dnd_end').state).split(":")
startH = int(start[0])
startM = int(start[1])
endH =  int(end[0])
endM =  int(end[1])
dnd = ([startH,startM,endH,endM])
hass.services.call('vacuum', 'send_command', {'entity_id': 'vacuum.xxxx', 'command': 'set_dnd_timer', 'params': dnd})
2 Likes

I’m not a programmer, but I’d say it works.
I take the coordinates from the FloleVac app and paste them directly into an input_text.

script:

  vacuum_clean_zone_test:
    alias: "Pulizia a Zone Test"
    sequence:
      - service: python_script.vacuum_zones_template
        data_template:
          entity_id: >
            {{states('input_text.vacuum')}}
          repeats: >
            {{states('input_number.vacuum_passes')|int}}
          zone: >
            {{ states('input_text.vacuum_zone_1') }}

python_script.vacuum_zones_template

def convert(zones): 
        for i in range(0, len(zones)):
                zones[i] = int(zones[i]) 

def split_into_sublists(list_, size):
        return [list_[x:x+size] for x in range(0, len(list_), size)]

entity_id = data.get('entity_id')
## OR ## entity_id = hass.states.entity_ids('vacuum')[0] #
if not entity_id:
        logger.error('Error entity_id')
repeats = data.get('repeats')
zone = data.get('zone').replace(',1','').replace('[','').replace(']','').split(',')
zones = []

hass.services.call('vacuum', 'pause', {'entity_id': entity_id})
(convert(zone))
zones.extend(split_into_sublists(zone, 4))
hass.services.call('vacuum', 'xiaomi_clean_zone', {'entity_id': entity_id, 'repeats': repeats, 'zone': zone

I prefer to clean every area (max 5 zones x area) and start again.
In this way I always know where and what the vacuum does.
Here is my example … please do not laugh: 0)
vacuum_zones.py

def convert(zones): 
        for i in range(0, len(zones)):
                zones[i] = int(zones[i]) 

def split_into_sublists(list_, size):
        return [list_[x:x+size] for x in range(0, len(list_), size)]

vacuum = hass.states.entity_ids('vacuum')[0] ##(hass.states.get('input_text.vacuum').state)
if not vacuum:
        logger.error('error vacuum not found')
repeats = (hass.states.get('input_number.vacuum_passes').state).split(".")[0]
zones_on = []
name_zones_on = []
zones = []
my_dict = {}
area = []
hass.services.call('vacuum', 'pause', {'entity_id': vacuum})
for entity_id in hass.states.entity_ids('input_boolean'):
        state = hass.states.get(entity_id)
        if state.entity_id.startswith("input_boolean.vacuum_zone_") and state.state == "on" and len(zones) < 5:
                zones_on.append(state.entity_id)
                xy = (hass.states.get('input_text.'+str(state.object_id)).state).replace(',1','').replace('[','').replace(']','').split(',')
                (convert(xy))
                zones.extend(split_into_sublists(xy, 4))
                name_zones_on.append(state.name)
                my_dict[(state.name)] = (split_into_sublists(xy, 4)) #my_dict = dict(zip(name_zones_on, zones))

area = [ v for v in my_dict.values() ]
if len(name_zones_on) != 0:
        hass.services.call('input_select', 'set_options', {'entity_id': 'input_select.vacuum_zones', 'options': name_zones_on})
        hass.services.call('input_boolean', 'turn_off', {'entity_id': zones_on[0]})  
        hass.services.call('vacuum', 'xiaomi_clean_zone', {'entity_id': vacuum, 'repeats': repeats, 'zone': area[0]})
else:
        hass.services.call('input_select', 'set_options', {'entity_id': 'input_select.vacuum_zones', 'options': 'none'}) 
        hass.services.call('vacuum', 'return_to_base', {'entity_id': vacuum})

When the state of the vacuum changes from Zoned cleaning or the state changes to Returning home, I call the script again until everything is finished

    - condition: template
      value_template: >
        {{states('input_select.vacuum_zones') != 'none' }}
    - service: python_script.vacuum_zones

I hope it’s useful and that someone makes the code better than this: 0)

I just see this after adding your card through HACS and added the path/module to the lovelace configuration file.

Are you sure that path used in resources is correct? Does the map image exist?

Tried without the map_image as well but no difference and copied what was in the documentation:

You have to provide a map image, card will not run without it. Can you check if you have any errors in browser console?

How do you extract the image from Flolevac the easiest way?

Just a screenshot :wink:

LOL, I fell like… Well yeah!

Hmm, I started to use HACS and it seems that all my custom card seems to work except the ones where I use ‘custom:card-modder’.

I removed the “old”, found the one available within HACS and now I can’t get my lovelace card to work.
I use it for this Vacum Cleaner Card. Anyone else experience this?

Card:
image

HACS:
image

Lovelace:
image

Hi All,

I created this swipe card to switch between the simple vacuum card and the map card. This helps to keep my ui nice and tidy, and thought it may be of use to some of you:

cards:
  - background: img/vacuum.png
    buttons: true
    entity: vacuum.xiaomi_vacuum_cleaner
    name: Veronica
    type: 'custom:xiaomi-vacuum-card'
  - base_position:
      x: 1889
      'y': 1600
    entity: vacuum.xiaomi_vacuum
    map_image: /local/icons/floorplan.jpg
    reference_point:
      x: 1625
      'y': 1336
    type: 'custom:xiaomi-vacuum-map-card'
    zones:
      - - - 25500
          - 25500
          - 26500
          - 26500
      - - - 24215
          - 28125
          - 29465
          - 32175
id: 7a0fe21111bd440b987005a0d35dd340
parameters:
  scrollbar:
    draggable: true
    hide: false
    snapOnRelease: true
  spaceBetween: 8
type: 'custom:swipe-card'
2 Likes

Hi are you able to share your flow please thanks appreciated thanks again

Can you draw zones normally with the swipe-card? I found that the only way to draw zones with the swipe card is to start vertically and even then it would occasionally try to swipe to another page.

It is completely off-topic though. But your answer is: card-modder is deprecated, if you really want to use card-modder with HACS you will have to either import this into HACS (read their docs on how to do this) or manually install it.

I would suggest moving over to card-mod though as it removes the need for a special card (in this case card-modder) and css can just be applied to any lovelace card.

An example of that config would look like this:

- type: entity-button
  style: |
    ha-card {
      border-radius: 10px;
      background: blue;
      color: white;
      opacity: 0.8;
    }
  entity: light.yourentityhere

This style config can be applied to any lovelace card. For more examples visit my repo https://github.com/jimz011/homeassistant

I am sure that you can modify the card not to swipe and use a chevron instead? I am not sure,…Come to think about it, drawing zones is not something that you would do often, so possibly use the card in default mode to do the zones and then move to swipe once complete?

How did you manage to get the base posistion and reference point? I managed to get the Coordinates of the zones. But If i choose the go to dropdown It wont go to the right position.