Auto integrate all Xiaomi devices to HomeAssistant via miot-spec

Tried everything to add my D9 dremetech vacuum and was having no luck. This worked, thanks!

Hi!

Can I ask for help, I am trying to set the state of my vacuum sensors, I can see their values through the service: get_properties using developer tools.

service: xiaomi_miot.get_properties
data:
  entity_id: vacuum.roidmi_v60_robot_cleaner
  mapping:
    double_clean:
      siid: 8
      piid: 20
    volume:
      siid: 9
      piid: 1
  throw: true # throw result to HA notifications

This outputs to my notifications:

[{‘code’: 0, ‘did’: ‘prop.8.20’, ‘piid’: 20, ‘siid’: 8, ‘value’: 1}, {‘code’: 0, ‘did’: ‘prop.9.1’, ‘piid’: 1, ‘siid’: 9, ‘value’: 15}]

How do i forward the values to my sensors?

      vacuum_double_clean:
        value_template: (THIS NEEDS TO SHOW AS 1)

      vacuum_speaker_volume:
        value_template: (THIS NEEDS TO SHOW AS 15)

Hope this makes sense? Is this possible?

As per documentation and device specification, I would add the following to your HA yaml configuration:

xiaomi_miot:
  device_customizes:
    roidmi.vacuum.v60:
	  switch_properties: custom.double-clean
      number_properties: speaker.volume

Not sure about config above, but if that doesn’t work, try removing prefixes custom. and speaker.

After this, you should either reload the Xiaomi Miot Auto configuration or restart HA.

At the end, you should get 2 new entities in your integration:

  • A switch entity for turning on/off the double clean boolean (and changing the state should also change the vacuum property directly);
  • A number entity representing the volume level (and changing this number should also change the vacuum property directly).

If these entities do not appear in the integration, try removing it and adding it again.

If you really just want the value to appear in a template sensor, you can either:

  • use the attributes_template functionality (I never used it myself but it should work);
  • create template sensors in HA for the states of these 2 new entities.

I think this more than fits your purpose, but I have no way of testing it, but please do and provide feedback.

Hi!

Thanks for the suggestions, i tried

device_customizes:

This did not work for me, although it did point me in another direction. I saw from developer tools that the vacuum state had an entry exclude_miot_services: - custom so i copied the whole state into customize.yaml, here’s my customize now:

vacuum.roidmi_v60_robot_cleaner:
    miot_local : true          # Force reading and writing data on the local network
    miot_cloud : false         # Enable miot cloud for entity (read, write, action)
    miot_cloud_write: true # (Optional) Enable miot cloud (write only)
    miot_cloud_action : true   # (Optional) Enable miot cloud (action only)
    battery_icon: mdi:battery-charging-100
    model: roidmi.vacuum.v60
    lan_ip: 192.168.1.101
    mac_address: 
    entity_class: MiotVacuumEntity
    miot_type: urn:miot-spec-v2:device:vacuum:0000A006:roidmi-v60:2
    state_updater: lan
    exclude_miot_services:
    sub_entities:
      - filter-10.filter_life_level-1
      - filter-10.filter_left_time-2
      - battery-3.battery_level-1
      - battery-3.charging_state-2
      - brush_cleaner-11.brush_left_time-1
      - brush_cleaner-11.brush_life_level-2
      - brush_cleaner-12.brush_left_time-1
      - brush_cleaner-12.brush_life_level-2
      - brush_cleaner-15.brush_left_time-1
      - brush_cleaner-15.brush_life_level-2
      - custom.total_clean_time
      - custom.total_clean_areas
      - custom.clean_counts
      - custom.double_clean
      - custom.clean_time
      - custom.work_station_freq
      - custom.timing
      - custom.clean_area
      - custom-8.clean_area-7
      - custom.edge_sweep
      - custom.led_switch
      - custom.lidar_collision
      - custom.station_key
      - custom.station_led
      - custom.station_type
      - custom.water_level
      - custom.auto_boost
      - custom.mop
    friendly_name: ROIDMI EVE Robot Cleaner

Now, this is a bit of a hit and miss. Because there are some custom sensors that show up, but other don’t.

Clean times, counts and the areas don’t show up at all no matter what i try. It’s mostly the boolean sensors that do show, like custom.double_clean, custom.edge_sweep, custom.station_type. Although at the start, sometimes they don’t show in the state unless you execute a set_properties service.

Tried to change miot_cloud and miot_local but still the same either way. cloud is much harder since it frequently goes unavailable.

If anyone has a configuration where everything is working, hope you can post here.

I don’t think that putting ALL what you have in the entity attributes in customize will work, you should try to check the examples in the documentation and try to adapt accordingly. I suppose some may need cloud access.

You can also check this issue, it might help with disconnection issues.

As I don’t own the vacuum, it’s not easy to try to help more.

You can also try to raise an issue in Github asking for help there.

1 Like

My brute force method of just seeing what works.

I do already have all the basic functions available. It’s just that i wanted to have the vacuum settings available on home assistant as well. However, most important parts, especially buttons on cleaning specific partitions directly on home assistant are working.

If anyone else is interested or still hunting for solutions on their vacuums, here are the links for integrations and dashboard.

Very easy step by step on how to integrate your vacuum:

Here is a very easy copy and paste on all possible values you could have on your vacuum:

Finally, the dashboard reference i used for my view.

1 Like

this is awsome, thx for integration
i have miot-spec-v2:device:camera:0000A01C:chuangmi-ipc009, when i make card with stream streams for about 20 sec, then it freezes, or goes in circle for 10 sec periods

Any chances to get this working for Deam D9 ?

Thanks!

Do you guys know how to make viomi vacuum work? I added the intergarion and see the data from it
but cannot call it to make it work…

here is what i see :grin:
msg_id: 1514786224358965200
is_new: 1
type: 6
title: Cleaning completed
content: Vacuum
user_id: xxx
timestamp: ‘2022-04-15T02:02:33’
model: viomi.vacuum.v18
event: ‘4.4’
home_name: xxx 's home
room_name: Tilley
entity_picture: ‘’
icon: mdi:message
friendly_name: Xiaomi xxx message
prev_message: ‘Vacuum: Cleaning completed’

here is what i try to send

service: xiaomi_miot.call_action
data:
entity_id: vacuum.dreame_p2259_entity_id
siid: 4 # vacuum-extend
aiid: 1 # start-clean
params:
- 18 # piid: 1 - work-mode
- ‘{“selects”:[[7,1,0,2,1]]}’ # piid: 10 - clean-extend-data
throw: true # throw result to HA notifications

so far no luck

hi. i am trying out this custom component for my new Roidmi EVA vacuum robot. I have installed this component by copying the folder into custom_components and then added this to my configuration…

</s> <s>xiaomi_miot:</s> <s> username: !secret xiaomi_username</s> <s> password: !secret xiaomi_password</s> <s> server_country: cn</s> <s> http_timeout: 300</s> <s>

After I restart HA, it shows this error in the log…

```
This error originated from a custom integration.

Logger: homeassistant.setup
Source: custom_components/xiaomi_miot/core/xiaomi_cloud.py:563
Integration: Xiaomi Miot Auto (documentation, issues)
First occurred: 10:47:21 PM (1 occurrences)
Last logged: 10:47:21 PM

Error during setup of component xiaomi_miot
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 386, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 1040, in validate_conn
conn.connect()
File “/usr/local/lib/python3.9/site-packages/urllib3/connection.py”, line 414, in connect
self.sock = ssl_wrap_socket(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl
.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl
.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File “/usr/local/lib/python3.9/ssl.py”, line 500, in wrap_socket
return self.sslsocket_class._create(
File “/usr/local/lib/python3.9/ssl.py”, line 1040, in _create
self.do_handshake()
File “/usr/local/lib/python3.9/ssl.py”, line 1309, in do_handshake
self._sslobj.do_handshake()
socket.timeout: _ssl.c:1112: The handshake operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/requests/adapters.py”, line 440, in send
resp = conn.urlopen(
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 785, in urlopen
retries = retries.increment(
File “/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py”, line 550, in increment
raise six.reraise(type(error), error, _stacktrace)
File “/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py”, line 770, in reraise
raise value
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 703, in urlopen
httplib_response = self._make_request(
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 389, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 340, in _raise_timeout
raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘api.io.mi.com’, port=443): Read timed out. (read timeout=60)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/setup.py”, line 235, in _async_setup_component
result = await task
File “/config/custom_components/xiaomi_miot/init.py”, line 214, in async_setup
hass.data[DOMAIN][‘devices_by_mac’] = await mic.async_get_devices_by_key(‘mac’) or {}
File “/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py”, line 278, in async_get_devices_by_key
dvs = await self.async_get_devices(renew=renew) or []
File “/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py”, line 247, in async_get_devices
dvs = await self.hass.async_add_executor_job(self.get_device_list)
File “/usr/local/lib/python3.9/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py”, line 204, in get_device_list
rdt = self.request_miot_api(‘home/device_list’, {
File “/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py”, line 172, in request_miot_api
rsp = self.request_rc4_api(api, params, method, **kwargs)
File “/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py”, line 563, in request_rc4_api
response = self.session.post(url, data=params, timeout=timeout)
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 577, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 529, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 645, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/adapters.py”, line 532, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host=‘api.io.mi.com’, port=443): Read timed out. (read timeout=60)
```

I can see MIOT services such as xiaomi_miot.call_action in Developer Tools. However, when I go to Configuration > Devices & Services > Add Integration, I cannot find Xiaomi Miot Auto.

2022-06-01_225021

I have upgraded my HA to Home Assistant Core 2022.5.5. Please help. What did I do wrong?

Edit: Never mind. I managed to find the “Xiaomi Miot Auto” in the integration after I cleared my browser cache.

you need to use the correct codes from the spec for your vacuum.
Viomi S9 - 产品规格 - Xiaomi Miot Spec (miot-spec.com)
you need to use SIID 4, but the AIID doesn’t have a 1 in the spec, so check for the correct one.
Also the parameters 18 is water grade for your vacuum. so that wont work.
this {“selects”:[[7,1,0,2,1]]} is referring to Room 7. To get your room details, you will need to work that out. I used the Card and Map extractor here, which got me going.
PiotrMachowski/lovelace-xiaomi-vacuum-map-card: This card provides a user-friendly way to fully control Xiaomi (Roborock/Viomi/Dreame/Roidmi) and Neato (+ possibly other) vacuums in Home Assistant. (github.com)

Once you have the map, you can get your room numbers, coordinates, and that helps understand what the miot spec is doing. Its a lot of trial and error, and reading everything in the various posts to figure out your particular model.

Hello! Please tell me what the problem may be. After the update on 2023.06, errors appeared:

Logger: homeassistant.setup
Source: setup.py:377
First occurred: 12:34:53 (3 occurrences)
Last logged: 12:34:53

Unable to prepare setup for platform xiaomi_miot_raw.switch: Platform not found (Exception importing custom_components.xiaomi_miot_raw.switch).
Unable to prepare setup for platform xiaomi_miot_raw.number: Platform not found (Exception importing custom_components.xiaomi_miot_raw.number).
Unable to prepare setup for platform xiaomi_miot_raw.select: Platform not found (Exception importing custom_components.xiaomi_miot_raw.select).

xiaomi_miot_raw is not this project, its author has not updated it for a long time. Maybe you can try Xiaomi Miot Auto.

1 Like

Thanks. )))

Hi,
How can I get the value from miot_action_result in automation after call service and throw result ?
I can use the attribute entity of the parent but if some automations are called at the same time, it give me some false results when read the attribute.
Tk a lot!

все работает кроме Алисы не хочет убирать, Yandex Intents появился в Яндекс умный дом как плеер в вкладке Сценарии не чего нет и пылесос добавлял отдельно. пылесос Roidmi EVE Plus
подскажите куда копать

подскажите куда копать где что исправить что бы от алисы работал

I have a similar problem. It seems that on homeassistant portal the log of the motion sensor would only update every hour despite I set the interval_secound in customize.yaml. I tried to change the cutom_no_motion time to 0.5 but it doesn’t work and it changed it back automatically.

Hello! I’ve had the integration working pretty well for a while now!
I’m just going to be very clumsy, but I can’t differentiate the areas that are named in the Xiaomi app.
But what I would like to solve is a language problem that I have only in the fan speed. I don’t know why, but it’s the only thing that appears in ¿Chino?.
All options appear in my language, Spanish. But the speed I have not been able to change the language.
Anyone who knows how to help me and tell me where to look?
Thank you

Captura de pantalla 2023-10-30 a las 13.32.23

IMILAB EC2 cameras don’t work with this Integration :frowning: