Closed divanikus closed 2 years ago
The vacuum doesn't support local mode yet, maybe soon...
It works in local mode (I guess) with those third party integrations. At least I never provided a mi account for them, just local ip and token.
It use miio not miot.
Upgrade to master branch and try.
So, sensor do work now. But not all commands are working.
I've tried to click start, stop, home - nothing. Locate - yup, vacuum responds with "i'm here".
Other attributes from other integrations
Upgrade to latest commit of master branch.
Actions now work, though still not all sensor are showing anything
# configuration.yaml
logger:
default: warning
logs:
custom_components.xiaomi_miot.core.miio2miot: debug
And show me logs.
service: xiaomi_miot.send_command
data:
entity_id: vacuum.viomi_v8_xxxx_robot_cleaner
method: get_prop
params:
- side_brush_hours
- main_brush_hours
- hypa_hours
- mop_hours
- side_brush_life
- main_brush_life
- hypa_life
- mop_life
throw: true
And:
service: xiaomi_miot.send_command
data:
entity_id: vacuum.viomi_v8_xxxx_robot_cleaner
method: get_prop
params:
- run_state
- suction_grade
- battary_life
- main_brush_life
- side_brush_life
- hypa_life
- mop_life
throw: true
And show me the results in HA notifications.
Please try latest commit of master branch.
So I tried the master branch, and for some reason my vacuum completely dissapperead with it.
2022-03-07 01:36:42 ERROR (MainThread) [homeassistant.components.vacuum] xiaomi_miot: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 356, in ensure_valid
self._compiled_code = self._env.compile(self.template) # type: ignore[no-untyped-call]
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2062, in compile
cached = self.template_cache[source] = super().compile(source)
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 757, in compile
self.handle_exception(source=source_hint)
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<unknown>", line 1, in template
jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got ':'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 593, in template
template_value.ensure_valid()
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 358, in ensure_valid
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TemplateSyntaxError: expected token 'end of print statement', got ':'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 719, in async_device_update
await task
File "/config/custom_components/xiaomi_miot/vacuum.py", line 341, in async_update
await super().async_update()
File "/config/custom_components/xiaomi_miot/__init__.py", line 1190, in async_update
results = await self._miio2miot.async_get_miot_props(self.miot_device, local_mapping)
File "/config/custom_components/xiaomi_miot/core/miio2miot.py", line 87, in async_get_miot_props
return await self.hass.async_add_executor_job(
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/miio2miot.py", line 95, in get_miot_props
if dic := self.get_miio_props(device):
File "/config/custom_components/xiaomi_miot/core/miio2miot.py", line 74, in get_miio_props
tpl = cv.template(tpl)
File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 596, in template
raise vol.Invalid(f"invalid template ({ex})") from ex
voluptuous.error.Invalid: invalid template (TemplateSyntaxError: expected token 'end of print statement', got ':')
Try master branch again.
2022-03-07 12:37:39 INFO (SyncWorker_0) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 65, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:38:09 INFO (SyncWorker_1) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 66, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:38:39 INFO (SyncWorker_8) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 66, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:39:09 INFO (SyncWorker_4) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 66, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:39:39 INFO (SyncWorker_10) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 67, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:40:09 INFO (SyncWorker_6) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 67, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:40:39 INFO (SyncWorker_3) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 67, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:41:09 INFO (SyncWorker_8) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 68, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:41:39 INFO (SyncWorker_7) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 68, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:42:09 INFO (SyncWorker_7) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 68, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:42:39 INFO (SyncWorker_10) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 68, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:43:09 INFO (SyncWorker_5) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 69, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:43:39 INFO (SyncWorker_1) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 69, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
2022-03-07 12:44:09 INFO (SyncWorker_6) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'run_state': 5, 'suction_grade': 3, 'battary_life': 69, 'main_brush_life': 86, 'side_brush_life': 172, 'hypa_life': 172, 'mop_life': 0, 'mode': 43, 'err_state': 25.17, 'box_type': 12, 'mop_type': 1, 's_time': 1, 's_area': 0, 'water_grade': 0}]
As for commands, Start/Pause/Stop works. Location works. But Return to base doesn't.
Try master again and show me the entity state attributes.
2022-03-10 11:39:29 INFO (SyncWorker_12) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'sw_info': '3.5.3_0017', 'run_state': 3, 'mode': 0, 'err_state': 0, 'battary_life': 93, 'box_type': 1, 'mop_type': 0, 's_time': 9, 's_area': 9.59, 'suction_grade': 3, 'water_grade': 11, 'remember_map': 1, 'has_map': 1, 'is_mop': 0, 'has_newmap': 0, 'main_brush_life': 86, 'side_brush_life': 173, 'hypa_life': 173, 'mop_life': 0}]
2022-03-10 11:39:59 INFO (SyncWorker_6) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'sw_info': '3.5.3_0017', 'run_state': 3, 'mode': 0, 'err_state': 0, 'battary_life': 92, 'box_type': 1, 'mop_type': 0, 's_time': 9, 's_area': 9.6, 'suction_grade': 3, 'water_grade': 11, 'remember_map': 1, 'has_map': 1, 'is_mop': 0, 'has_newmap': 0, 'main_brush_life': 86, 'side_brush_life': 173, 'hypa_life': 173, 'mop_life': 0}]
2022-03-10 11:40:29 INFO (SyncWorker_1) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'sw_info': '3.5.3_0017', 'run_state': 3, 'mode': 0, 'err_state': 0, 'battary_life': 92, 'box_type': 1, 'mop_type': 0, 's_time': 10, 's_area': 9.6, 'suction_grade': 3, 'water_grade': 11, 'remember_map': 1, 'has_map': 1, 'is_mop': 0, 'has_newmap': 0, 'main_brush_life': 86, 'side_brush_life': 173, 'hypa_life': 173, 'mop_life': 0}]
2022-03-10 11:40:59 INFO (SyncWorker_9) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'sw_info': '3.5.3_0017', 'run_state': 3, 'mode': 0, 'err_state': 0, 'battary_life': 91, 'box_type': 1, 'mop_type': 0, 's_time': 10, 's_area': 9.65, 'suction_grade': 3, 'water_grade': 11, 'remember_map': 1, 'has_map': 1, 'is_mop': 0, 'has_newmap': 0, 'main_brush_life': 86, 'side_brush_life': 173, 'hypa_life': 173, 'mop_life': 0}]
"Return to base" now works btw
What is the actual life of consumables in Mihome APP ?
I can't find those values in MiApp. But I can believe they are true, because I'm using this robot for almost 2 years.
def __init__(self, data: List[int]) -> None:
# [17, 17, 17, 17]
self.data = {
"main_brush_work_time": data[0] * 60 * 60,
"side_brush_work_time": data[1] * 60 * 60,
"filter_work_time": data[2] * 60 * 60,
"mop_dirty_time": data[3] * 60 * 60,
}
self.side_brush_total = timedelta(hours=180)
self.main_brush_total = timedelta(hours=360)
self.filter_total = timedelta(hours=180)
self.mop_total = timedelta(hours=180)
self.sensor_dirty_total = timedelta(seconds=0)
I think it may be that your consumables are used past their lifespan.
service: xiaomi_miot.send_command
data:
entity_id: vacuum.viomi_v8_xxxx_robot_cleaner
method: get_consumables
params: []
throw: true
I guess you are right. At least the side brush is definetely looks worn out 😅
Miio command result:
[312, 312, 312, 0]
Try master branch again.
Service call result is
2022-03-11 00:06:32 INFO (SyncWorker_8) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'sw_info': '3.5.3_0017', 'run_state': 1, 'mode': 0, 'err_state': 0, 'battary_life': 30, 'box_type': 1, 'mop_type': 0, 's_time': 0, 's_area': 0, 'suction_grade': 3, 'water_grade': 12, 'remember_map': 1, 'has_map': 1, 'is_mop': 0, 'has_newmap': 0, 'main_brush_hours': 312, 'side_brush_hours': 312, 'hypa_hours': 312, 'mop_hours': 0, 'main_brush_life': 13, 'side_brush_life': 0, 'hypa_life': 0, 'mop_life': 100}]
2022-03-11 00:06:43 INFO (SyncWorker_2) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'sw_info': '3.5.3_0017', 'run_state': 1, 'mode': 0, 'err_state': 0, 'battary_life': 30, 'box_type': 1, 'mop_type': 0, 's_time': 0, 's_area': 0, 'suction_grade': 3, 'water_grade': 12, 'remember_map': 1, 'has_map': 1, 'is_mop': 0, 'has_newmap': 0, 'main_brush_hours': 312, 'side_brush_hours': 312, 'hypa_hours': 312, 'mop_hours': 0, 'main_brush_life': 13, 'side_brush_life': 0, 'hypa_life': 0, 'mop_life': 100}]
2022-03-11 00:06:57 INFO (SyncWorker_9) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'sw_info': '3.5.3_0017', 'run_state': 1, 'mode': 0, 'err_state': 0, 'battary_life': 30, 'box_type': 1, 'mop_type': 0, 's_time': 0, 's_area': 0, 'suction_grade': 3, 'water_grade': 12, 'remember_map': 1, 'has_map': 1, 'is_mop': 0, 'has_newmap': 0, 'main_brush_hours': 312, 'side_brush_hours': 312, 'hypa_hours': 312, 'mop_hours': 0, 'main_brush_life': 13, 'side_brush_life': 0, 'hypa_life': 0, 'mop_life': 100}]
2022-03-11 00:07:27 INFO (SyncWorker_13) [custom_components.xiaomi_miot.core.miio2miot] Got miio props for miot: ['192.168.0.230', {'sw_info': '3.5.3_0017', 'run_state': 1, 'mode': 0, 'err_state': 0, 'battary_life': 30, 'box_type': 1, 'mop_type': 0, 's_time': 0, 's_area': 0, 'suction_grade': 3, 'water_grade': 12, 'remember_map': 1, 'has_map': 1, 'is_mop': 0, 'has_newmap': 0, 'main_brush_hours': 312, 'side_brush_hours': 312, 'hypa_hours': 312, 'mop_hours': 0, 'main_brush_life': 13, 'side_brush_life': 0, 'hypa_life': 0, 'mop_life': 100}]
I think it's no problem now.
Last changes fixed also viomi.vacuum.v7. One thing to correct is modes: Silent, Standard, Medium, Turbo instead of Silent, Basic, Strong.
Coul confirm viomi.vacuum.v7 also works! could you please correct its modes to Silent, Standard, Medium, Turbo instead of Silent, Basic, Strong?
{
"iid":2,
"type":"urn:miot-spec-v2:property:mode:00000008:viomi-v8:1",
"description":"Mode",
"format":"uint8",
"access":[ "read", "write", "notify"],
"value-list":[
{"value":0, "description":"Silent"},
{"value":1, "description":"Basic"},
{"value":2, "description":"Medium"},
{"value":3, "description":"Strong"}
]
}
The description of the mode options for this device is from miot-spec, if you want to change it, you can change it by translations
:
# configuration.yaml
xiaomi_miot:
# https://github.com/al-one/hass-xiaomi-miot/blob/master/custom_components/xiaomi_miot/core/translation_languages.py
translations:
# Dictionary for specifying the vacuum modes
vacuum.mode:
basic: Standard
strong: Turbo
This quastion was here, but no answer have! viomi.vacuum.v7 must have 4 mode for Fan ( Silent, Standard, Medium, Turbo) but have only 3 ( Silent, Basic, Strong). Silent is Silent Standard is Basic Medium - not have!!! Turbo is Strong How can get Medium mode?
fan_speed_list: - Silent - Basic - Strong battery_level: 100 battery_icon: mdi:battery-charging-100 fan_speed: Basic model: viomi.vacuum.v7 lan_ip: 10.250.250.75 mac_address: 5C:E5:0C:7E:D5:8F entity_class: MiotViomiVacuumEntity miot_type: urn:miot-spec-v2:device:vacuum:0000A006:viomi-v7:2 vacuum.mode: 1
Hi. I have viomi.vacuum.v8 vaccum cleaner. It does work with several separate integrations like this one.
I can add it using local ip and token to your integration, but it is always in the unavailable state.
The only thing I can find in the logs is the following: