Custom Component: Dreame Vacuum

Hi :slight_smile:
Sorry if this might have been answered alreadyā€¦ havenā€™t found the information yetā€¦

The Xiaomi App does provide a ā€œbasicā€ Remote control for moving the robot.
It can move it forward and rotate left / right.

Is there by any chance an option to recreate such a remote controll with buttons?

Maybe with the following actions:

  • forward
  • backward
  • rotate left
  • rotate right
  • start sucction
  • start wet cleaning
  • start (fast) mapping

I mean, a fully automated robot does not really require thisā€¦ most of the times.
But sometimes, itā€™s just easier and faster to navigate the robot directly to the specific place :slight_smile:

Also, I just ask myself at that moment:
Is there any way to appyl a specific route the robot should follow in the map?

I think, I had seen a similar option somewhere, but not in the xiaomi map for HAā€¦ / not as a service (or I just donā€™t recall it right now)

Integration supports remote control feature but lovelace does not.
App uses touch start and touch end events on buttons to move and stop the robot. Since there are no available button on the lovelace that supports touch end event, it is not possible to send the stop command to the robot.
Dreame Vacuum Card will support remote control feature then it is available.

2 Likes

HA core in termux, python 3.11
error when try to add device

ValueError: mutable default <class ā€˜custom_components.dreame_vacuum.dreame.types.Lineā€™> for field p0 is not allowed: use default_factory

Is it ok to fix like this?

before:

@dataclass
class ALine():
    p0: Line = Line()
    p1: Line = Line()

after:

class ALine():
    p0: Line = field(default_factory=Line(List[0], List[0], False, 0))
    p1: Line = field(default_factory=Line(List[0], List[0], False, 0))

I will fix the issue like you suggested and release a new version.

is it possible to get info about empty water tank?

I am planning to add persistent notifications/events when there is an error about the water tank on a later release.

1 Like

Hi
I have same problem.

{"message":"Invalid handler specified"}

Log

2023-01-02 20:55:43.682 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration dreame_vacuum: Exception importing custom_components.dreame_vacuum.config_flow
2023-01-02 20:59:15.669 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.dreame_vacuum.config_flow
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/loader.py", line 728, in get_platform
cache[full_name] = self._import_platform(platform_name)
File "/usr/src/homeassistant/homeassistant/loader.py", line 745, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/config/custom_components/dreame_vacuum/__init__.py", line 7, in <module>
from .coordinator import DreameVacuumDataUpdateCoordinator
File "/config/custom_components/dreame_vacuum/coordinator.py", line 19, in <module>
from .dreame import DreameVacuumDevice, DreameVacuumProperty
File "/config/custom_components/dreame_vacuum/dreame/__init__.py", line 29, in <module>
from .device import DreameVacuumDevice
File "/config/custom_components/dreame_vacuum/dreame/device.py", line 108, in <module>
from .map import DreameMapVacuumMapManager
File "/config/custom_components/dreame_vacuum/dreame/map.py", line 14, in <module>
from py_mini_racer import MiniRacer
File "/usr/local/lib/python3.10/site-packages/py_mini_racer/__init__.py", line 3, in <module>
MiniRacer = py_mini_racer.MiniRacer
AttributeError: module 'py_mini_racer.py_mini_racer' has no attribute 'MiniRacer'
2023-01-02 20:59:15.690 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration dreame_vacuum: Exception importing custom_components.dreame_vacuum.config_flow

Vacum model - p2029

Anyone can help?

First, great work and big thanks for this integration. Is there any chance to implement the order first suck all rooms and after wipe them? This option i saw only in the app for scheduled cleaning, but could find it in any other place. My problem is, that if the vacuum suck and wipe at same time, some things get wet and the vacuum seem not to be able to suck it later.

Great work @tasshack ! Looks cool. I have just one question. Is it possible to use this integration together with vacuum running Valetudo ? I know that I can use Valetudo Map for better performance, but would it work with other things in your component ? I want to decloud my vacuum and keep all the functionality (I do not care about multi map). Beside this, good work :smiley: and keep :construction_worker_man:

Can you expand on this please? If the map can be read via the cloud API, can it not be read once and stored and then taken offline?

Are you installing a separate integration to get the xiaomi_miio services? I just set my bot up, and there are no serial numbers on the dustbin and it wants me to update. Iā€™m guessing that means I canā€™t install valetudo, but Iā€™m wondering if this integration can supply go-to-point functionality? [I want it to go to my trash can after itā€™s done cleaning a room via automation]. After installation, I see the dreame_* services, but not the miio ones.

Your post is really intriguing, but slightly confusing in finding my answer. Thanks for any input!

Hi sorry if my post caused some confusion.

The Services are dependent of the integration you are using.
I am using the Dreame Vacuum integration, but in combination with the Xiaomi Vacuum Map Card.
By default, the card configuration is using ā€œxiaomi_miio.ā€ service callsā€¦ that is what Iā€™ve changed in order to get the dreame bot working with the xiaomi map card.

both integrations, the Xiaomi Vacuum and the Dreame Vacuum map should provide at least some kind of ā€œclean spotā€ / ā€œgotoā€ action - but honestly, I havenā€™t used it by myself until now - so I canā€™t really give any advice on this.

But a good place to have a look is the github page of the dreame integrations.
The Discussion- or Wiki Section will provide many information related to those things.

Hey thanks for the reply! So it looks like the dreame_* services donā€™t exactly expost a go-to-point-esque service, but thereā€™s enough info to use room location to start / stop the vac in node red.

edit: updated the flow

when vac changes to ā€˜returningā€™, checks if clean time is > 5m. If so, calls clean service on the kitchen, where my trash can is. it waits for the vac current room to change to ā€˜Kitchenā€™, stops the vacuum, and then notifies me to empty dustbin

hereā€™s the flow without the inject or announce to alexa:

[{"id":"a472ce81445049f2","type":"server-state-changed","z":"967675d9b8bbd1be","name":"return","server":"7cb2eeb7.3b621","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"vacuum.dreame_robot_vacuum_d9","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"returning","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":90,"y":60,"wires":[["4bb7bb534022e5ec"],[]]},{"id":"719ddfcf52876c26","type":"api-call-service","z":"967675d9b8bbd1be","name":"kitchen","server":"7cb2eeb7.3b621","version":5,"debugenabled":false,"domain":"dreame_vacuum","service":"vacuum_clean_segment","areaId":[],"deviceId":[],"entityId":["vacuum.dreame_robot_vacuum_d9"],"data":"{ \"segments\": 1 }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":380,"y":60,"wires":[["874c776491c69730"]]},{"id":"874c776491c69730","type":"ha-wait-until","z":"967675d9b8bbd1be","name":"in k","server":"7cb2eeb7.3b621","version":2,"outputs":1,"entityId":"sensor.dreame_robot_vacuum_d9_current_room","entityIdFilterType":"exact","property":"state","comparator":"is","value":"Kitchen","valueType":"str","timeout":"0","timeoutType":"num","timeoutUnits":"seconds","checkCurrentState":true,"blockInputOverrides":true,"outputProperties":[],"entityLocation":"data","entityLocationType":"none","x":530,"y":60,"wires":[["fd065cca3ab67606","e48a055547579519"]]},{"id":"fd065cca3ab67606","type":"api-call-service","z":"967675d9b8bbd1be","name":"stop","server":"7cb2eeb7.3b621","version":5,"debugenabled":false,"domain":"vacuum","service":"stop","areaId":[],"deviceId":[],"entityId":["vacuum.dreame_robot_vacuum_d9"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":670,"y":60,"wires":[["ab1e8e875902e167"]]},{"id":"ab1e8e875902e167","type":"api-call-service","z":"967675d9b8bbd1be","name":"notify","server":"7cb2eeb7.3b621","version":5,"debugenabled":false,"domain":"notify","service":"notify","areaId":[],"deviceId":[],"entityId":[],"data":"{ \"message\": \"Time to empty the vacuum\" }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":810,"y":60,"wires":[[]]},{"id":"4bb7bb534022e5ec","type":"api-current-state","z":"967675d9b8bbd1be","name":">5m","server":"7cb2eeb7.3b621","version":3,"outputs":2,"halt_if":"5","halt_if_type":"num","halt_if_compare":"gt","entity_id":"sensor.dreame_robot_vacuum_d9_cleaning_time","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":230,"y":60,"wires":[["719ddfcf52876c26"],[]]},{"id":"7cb2eeb7.3b621","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]
1 Like

Thanks for the integration. Set it up yesterday with my new D9 Max and working well!

But is someone able to assist with the predefined selections for rooms as set out in the github?

I get a ā€œmissed comma between flow collection entriesā€ error in my yaml for this bit:

    predefined_selections:
{%- for room_id in attributes.rooms | default([]) %}
{%- set room = attributes.rooms[room_id] %}
      - id: {{room_id}}
        outline:
          - - {{room["x0"]}}
            - {{room["y0"]}}
          - - {{room["x0"]}}
            - {{room["y1"]}}
          - - {{room["x1"]}}
            - {{room["y1"]}}
          - - {{room["x1"]}}
            - {{room["y0"]}}
{%- endfor %}

If I just put:

    predefined_selections: []

Then the card works, but Iā€™m not able to manually select rooms for cleaning.
Do I need to replace something in that list with my specific details from the integration?

[Edit: Nevermind. I added the card via the UI in a managed dashboard and it populated the list for me.]

I tried to add Dreame X10 to this custom integration, however it shows the following message

I tried Miot Auto, it can show X10 but cannot control it

Hi I have the same issue with mi vacuum mop pro 2 / server DE. Did you resolve it ?

Hello all,

I have a Dreame Bot L10 Pro running since month. Everything works fine. Last week I bought a second one. Robot working with app. Everything perfect.
Today I wanted to add it also to HA. Same procedure. Adding new Device ā†’ Provide my credentials ā†’ 2 Robots found ā†’ I select the new one (which has a different name) ā†’ I select which entities and notofications ā†’ I press the ā€œSENDā€ button ā†’ On top I get message ā€œUnknown Errorā€ ā†’ HA crashes (seems like even the Raspberry crashes) ā†’ restart (robot not added)

I tried this several times with different selections but always end up in a crash. Everything else seems still to be working like a charm.

Any ideas or suggestions?

Thanks in advance

While further inspecting the issue, I saw that indeed the robot is added to the configuration after pressing the ā€˜sendā€™ button (u can see it in the background listed) but after 5 seconds the errors occurs. So I would assume the error occurs either when trying to discover entities or downloading the map.

I tried while robot is in sleep, cleaning and charging state. No success.
I forgot to mention I switched to HA 2023.3.1 some days ago. The 1st robot was successfully added while still on old Februar release.

Is there a way to maybe dive into this deeper? I could not locate a log file which contains useful information about the crash or what happened just before. But I might havenā€™t found the correct one so far.
Any help would be awesome.

I think your RPI does not have enough ram to run two devices at the same time. It is a known issue that the integration uses more than 1.5G of ram on ARM devices due to the python imaging library.

Ok. This sounds to be the correct answer.
But this happens when adding the new device, not when operating it. Iā€™m wondering if this is really the root cause. Is their a way to add the second robot without the camera/imaging option? Just for verification.
Or I could remove the first robot and try to add the second as the only device.

One more question. If I switch to an RPi 4 with more RAM, is it capable of running three robots? Anybody got experience with this?

Thank you