Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYJ02YM Vacuum Integration #27268

Closed
HydrelioxGitHub opened this issue Oct 6, 2019 · 88 comments
Closed

STYJ02YM Vacuum Integration #27268

HydrelioxGitHub opened this issue Oct 6, 2019 · 88 comments

Comments

@HydrelioxGitHub
Copy link
Contributor

HydrelioxGitHub commented Oct 6, 2019

Home Assistant release with the issue:
0.99.3

Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io

Integration:
https://www.home-assistant.io/integrations/vacuum.xiaomi_miio/

Description of problem:
I've tried to add my Xiaomi Mijia STYJ02YM lauched in the middle of august. But it seems that the integration can't reach the robot.
I've retreived the token using MiToolKit. I've checked the ip directely on the router.

There are 3 messages in the log (provided in the traceback).

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

vacuum:
  - platform: xiaomi_miio
    host: 192.168.1.208
    token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Traceback (if applicable):

Update of vacuum.xiaomi_vacuum_cleaner is taking over 10 seconds
Got exception while fetching the state: No response from the device
Got error when receiving: timed out

Additional information:

@probot-home-assistant
Copy link

Hey there @rytilahti, @syssi, mind taking a look at this issue as its been labeled with a integration (xiaomi_miio) you are listed as a codeowner for? Thanks!

@oneweekstudio
Copy link

i have same issue

@rytilahti
Copy link
Member

First step would be to ensure if it is working with miiocli or mirobo command-lne tool. Timeouts happen when there is no response from the acuum, so there is not much we can do there until that is solved.

Is homeassistant in the same network as the vacuum? Do mirobo discover and mirobo discover --handshake 1 show the vacuum?

@HydrelioxGitHub
Copy link
Contributor Author

HydrelioxGitHub commented Oct 8, 2019

There is an issue open on the python-miio repository.
rytilahti/python-miio#550

@variousDom
Copy link

Same issue.
Token was retrieved by an extract of miio2.db and verified by using app 5.4.49 logs.

Here is a part of the result for miiocli -d device --ip 192.168.0.Y --token XXX info

INFO:miio.cli:Debug mode active
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
data = Container:
data = b'' (total 0)
value = b'' (total 0)
offset1 = 32
offset2 = 32
length = 0
header = Container:
data = b'!1\x00 \x00\x00\x00\x00\x10\x91\xf1\xbc]\x9d"N' (total 16)
value = Container:
length = 32
unknown = 0
device_id = b'\x10\x91\xf1\xbc' (total 4)
ts = 2019-10-08 23:57:02
offset1 = 0
offset2 = 16
length = 16
checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.device:Discovered 1091f1bc with ts: 2019-10-08 23:57:02, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.0.14:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.device:Retrying with incremented id, retries left: 3

Any retry leads to the same issue.
Hope it helps...

@rezmus
Copy link

rezmus commented Oct 11, 2019

reset the vacuum to factory state (wifi ap mode), connect to ap and try to discover or get token by sending hello packet to the vacuum

https://github.com/jghaanstra/com.xiaomi-miio/blob/master/docs/obtain_token.md (bottom)

and try to inspect. technically vacuum can drop local miio api AFTER provisioning, but it should work in factory state, because mi home is using generic method miIO.config_router to setup cloud connection.

@nguyenmnam
Copy link

I can't get correctly token like the way you show. It's show me another token if I reset the vacuum again and again.
Hope anyone can help me!!!!plz!

reset the vacuum to factory state (wifi ap mode), connect to ap and try to discover or get token by sending hello packet to the vacuum

https://github.com/jghaanstra/com.xiaomi-miio/blob/master/docs/obtain_token.md (bottom)

and try to inspect. technically vacuum can drop local miio api AFTER provisioning, but it should work in factory state, because mi home is using generic method miIO.config_router to setup cloud connection.

@rezmus
Copy link

rezmus commented Oct 23, 2019

token changes on each wifi reset, but your goal is to reset wifi (disconnect vacuum from cloud), get the token and check if you can talk to vacuum when it's not connected to cloud. it looks like it close local miio api after you connect it to wifi/cloud.

@nguyenmnam
Copy link

nguyenmnam commented Oct 23, 2019

I try like this:

  1. Reset Vacuum ( Xiaomi Mijia)
  2. Connect Computer to wifi (from vacuum), send package to vacuum's IP and take 32 digits at the end of the string.
  3. Connect Vacuum to Mihome like normal.
  4. Write the token to config.yaml, check config "OK", restart but hassio logs still like this:
    Update of vacuum.xiaomi_vacuum_cleaner is taking over 10 seconds
    14:31 main.py (WARNING) - message first occured at 22:52, 22 tháng 10, 2019 and shows up 2656 times
    Got exception while fetching the state: No response from the device
    14:31 components/xiaomi_miio/vacuum.py (WARNING) - message first occured at 22:51, 22 tháng 10, 2019 and shows up 2656 times
    Got error when receiving: timed out
    14:31 components/xiaomi_miio/vacuum.py (ERROR) - message first occured at 22:51, 22 tháng 10, 2019 and shows up 2656 times

@rezmus
Copy link

rezmus commented Oct 23, 2019

don't do point 3, don't connect it to cloud (it will change token and probably disable local api).

when you get token in point 2 use python miio or mirobo send raw command for example

miiocli device --ip 192.168.8.1 --token 00112233445566778899aabbccddeeff info

or

mirobo --ip 192.168.8.1 --token 00112233445566778899aabbccddeeff raw-command miIO.info

@nguyenmnam
Copy link

nguyenmnam commented Oct 23, 2019

If dont do point 3, how can robo connect to my wifi? and when to connect robo to Mihome?

@rezmus
Copy link

rezmus commented Oct 23, 2019

just confirm local api is working and let us know. i will check how and where they disable it after cloud connection is done.

@leotreble
Copy link

hi everybody! I have a problem with Xiaomi STYJ02YM. Before an update I had 2 modes on this robot: vacuum and mop. After an update which I received recently I have 3 modes: Vacuum, Vacuum+Mop and Mop. If I choose only Mop mode I have an error: "water reservoir(tank) is not installed, please install water tank", but I already installed 2 in 1 water tank. And right now I can't use only Mop function on this vacuum, but previously everything was fine.
I tried to factory reset it, but a new firmware is still on this robot.
So my question is: can anybody have this kind of problem and can I reset this robot to a previous firmware?
Thank you very much!

@fran6g
Copy link

fran6g commented Nov 1, 2019

Hi leotreble, mine 'mops only' well without the tank filter.

@maats
Copy link

maats commented Nov 4, 2019

@leotreble, regarding to your issue I've seen video on YT with same problem and one comment states that after update for "mopping only" mode you need separate tank which is not included to the vacuum. I expect this tank is only for the water (not dust) and can carry more water. If you want to use your normal tank which is for dust+water you may need to use "vacuum + mop" mode after this update.

@Kitem19
Copy link

Kitem19 commented Nov 24, 2019

Hi all
have you manage to integrate the STYJ02YM in hassio?
Was ready to buy it, but want to be sure it will work
Thanks

@HydrelioxGitHub
Copy link
Contributor Author

Hello @Kitem19 some people are working on it but nothing is sure at this time. There are some questions about the API being accessible without the Xiaomi cloud (local API).

@Kitem19
Copy link

Kitem19 commented Nov 25, 2019

Hello @Kitem19 some people are working on it but nothing is sure at this time. There are some questions about the API being accessible without the Xiaomi cloud (local API).

Thanks.
Do you maybe suggest to buy the S6, instead?
Is it better integrated?

@HydrelioxGitHub
Copy link
Contributor Author

I don't know about the S6. The S5 still a very good solution for now.

@irononreverse
Copy link

Any updates on this?

@rytilahti
Copy link
Member

Basic support is available in the most recent python-miio release, some more features were added with rytilahti/python-miio#590 . The homeassistant integration needs to be updated to allow defining the model to use (as this uses a different protocol, and we cannot reliably detect this for non-cloud connected gen1 vacuums).

@Kitem19
Copy link

Kitem19 commented Dec 23, 2019

Hi @rytilahti
Thanks for the update.
If I well understood the project made some steps forward, but the hassio/homeassistant integration is still not working. Am I right?

@HydrelioxGitHub
Copy link
Contributor Author

Home assistant integration use the python library made by @rytilahti . This library has been updated after the last release of HA. So we have to wait the next release of HA in order to use the last version of the python library.

@Kitem19
Copy link

Kitem19 commented Dec 23, 2019

Thanks
Since it's my first time with this vacuum, I hope you will share the "how to..." guide to help me using it in HA :-)
Wish you great time

@rytilahti
Copy link
Member

@Kitem19 yes, you got it right! The backend library has now support for that device, and using that requires changes in the homeassistant integration.

@HydrelioxGitHub, bumping the version is not enough as this is a different implementation and will require modifications to the vacuum platform (i.e., adding ability to choose which implementation to use, much like with some other xiaomi_miio platforms).

@greengo1
Copy link

greengo1 commented Jan 6, 2020

Hello all! I am also looking forward for update regarding update on this topic.

@rytilahti
Copy link
Member

Try to add the debug flag to your invocations, it will show you what is being received and maybe give a hint what could be the problem. That error message indicates that the device responded with something (unexpected, non-json response) instead of simply timing out what usually happens when the token is incorrect.

@v0d0r
Copy link

v0d0r commented Aug 9, 2020

Try to add the debug flag to your invocations, it will show you what is being received and maybe give a hint what could be the problem. That error message indicates that the device responded with something (unexpected, non-json response) instead of simply timing out what usually happens when the token is incorrect.

@rytilahti

I have added the debug flag and in addition I have also done a packet capture on the interface and grabbed the response back from the vacuum. I am not sure what to expect in the response but it looks like is its sending me back another token the same one I sent in as the magic packet as well as the tocken I sent it from the PC in the mirobo command. Maybe this means something to somebody here?

packet capture response UDP Stream from 192.168.5.1 (vacuum) back to 192.168.5.2 (pc)

21310020ffffffffffffffffffffffffffffffffffffffffffffffffffffffff
21310020ffffffffffffffffffffffffffffffffffffffffffffffffffffffff
21310020ffffffffffffffffffffffffffffffffffffffffffffffffffffffff
2131002000000000126ebbd70000adab6771723256655964726277486f777a4e
2131002000000000126ebbd70000adab6771723256655964726277486f777a4e
2131002000000000126ebbd70000adab6771723256655964726277486f777a4e

Output of command and debug below

mirobo -d --ip 192.168.5.1 --token 6771723256655964726277486F777A4E raw-command miIO.info

INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Connecting to 192.168.5.1 with token 6771723256655964726277486F777A4E
Sending cmd miIO.info with params []
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container:
data = Container:
data = b'' (total 0)
value = b'' (total 0)
offset1 = 32
offset2 = 32
length = 0
header = Container:
data = b'!1\x00 \x00\x00\x00\x00\x12n\xbb\xd7\x00\x00\xad\xa6' (total 16)
value = Container:
length = 32
unknown = 0
device_id = unhexlify('126ebbd7')
ts = 1970-01-01 12:20:54
offset1 = 0
offset2 = 16
length = 16
checksum = b'gqr2VeYdrbwHowzN' (total 16)
DEBUG:miio.miioprotocol:Discovered 126ebbd7 with ts: 1970-01-01 12:20:54, token: b'6771723256655964726277486f777a4e'
DEBUG:miio.miioprotocol:192.168.5.1:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:Retrying with incremented id, retries left: 3
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container:
data = Container:
data = b'' (total 0)
value = b'' (total 0)
offset1 = 32
offset2 = 32
length = 0
header = Container:
data = b'!1\x00 \x00\x00\x00\x00\x12n\xbb\xd7\x00\x00\xad\xab' (total 16)
value = Container:
length = 32
unknown = 0
device_id = unhexlify('126ebbd7')
ts = 1970-01-01 12:20:59
offset1 = 0
offset2 = 16
length = 16
checksum = b'gqr2VeYdrbwHowzN' (total 16)
DEBUG:miio.miioprotocol:Discovered 126ebbd7 with ts: 1970-01-01 12:20:59, token: b'6771723256655964726277486f777a4e'
DEBUG:miio.miioprotocol:192.168.5.1:54321 >>: {'id': 102, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:Retrying with incremented id, retries left: 2
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container:
data = Container:
data = b'' (total 0)
value = b'' (total 0)
offset1 = 32
offset2 = 32
length = 0
header = Container:
data = b'!1\x00 \x00\x00\x00\x00\x12n\xbb\xd7\x00\x00\xad\xb0' (total 16)
value = Container:
length = 32
unknown = 0
device_id = unhexlify('126ebbd7')
ts = 1970-01-01 12:21:04
offset1 = 0
offset2 = 16
length = 16
checksum = b'gqr2VeYdrbwHowzN' (total 16)
DEBUG:miio.miioprotocol:Discovered 126ebbd7 with ts: 1970-01-01 12:21:04, token: b'6771723256655964726277486f777a4e'
DEBUG:miio.miioprotocol:192.168.5.1:54321 >>: {'id': 203, 'method': 'miIO.info', 'params': []}
DEBUG:miio.protocol:Unable to parse json '': Expecting value: line 1 column 1 (char 0)
DEBUG:miio.click_common:Exception: Unable to parse message payload
Traceback (most recent call last):
File "/home/vodor/.local/lib/python3.7/site-packages/miio/protocol.py", line 193, in _decode
return json.loads(decoded)
File "/usr/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/vodor/.local/lib/python3.7/site-packages/miio/click_common.py", line 59, in call
return self.main(*args, **kwargs)
File "/home/vodor/.local/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/vodor/.local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/vodor/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/vodor/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/vodor/.local/lib/python3.7/site-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/vodor/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/vodor/.local/lib/python3.7/site-packages/miio/vacuum_cli.py", line 644, in raw_command
click.echo(vac.raw_command(cmd, params))
File "/home/vodor/.local/lib/python3.7/site-packages/miio/device.py", line 165, in raw_command
return self.send(command, parameters)
File "/home/vodor/.local/lib/python3.7/site-packages/miio/device.py", line 147, in send
command, parameters, retry_count, extra_parameters=extra_parameters
File "/home/vodor/.local/lib/python3.7/site-packages/miio/miioprotocol.py", line 236, in send
extra_parameters=extra_parameters,
File "/home/vodor/.local/lib/python3.7/site-packages/miio/miioprotocol.py", line 236, in send
extra_parameters=extra_parameters,
File "/home/vodor/.local/lib/python3.7/site-packages/miio/miioprotocol.py", line 193, in send
m = Message.parse(data, token=self.token)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 288, in parse
return self.parse_stream(io.BytesIO(data), **contextkw)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 300, in parse_stream
return self._parsereport(stream, context, "(parsing)")
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 312, in _parsereport
obj = self._parse(stream, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 1981, in _parse
subobj = sc._parsereport(stream, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 312, in _parsereport
obj = self._parse(stream, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 2439, in _parse
return self.subcon._parsereport(stream, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 312, in _parsereport
obj = self._parse(stream, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 3987, in _parse
obj = self.subcon._parsereport(stream, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 312, in _parsereport
obj = self._parse(stream, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 4265, in _parse
obj = self.subcon._parsereport(stream, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 312, in _parsereport
obj = self._parse(stream, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/construct/core.py", line 698, in _parse
return self._decode(obj, context, path)
File "/home/vodor/.local/lib/python3.7/site-packages/miio/protocol.py", line 201, in _decode
) from ex
miio.exceptions.PayloadDecodeException: Unable to parse message payload
Error: Unable to parse message payload

@rytilahti
Copy link
Member

Maybe the info command is not working on that device? Something similar happens on rockrobo gen1 vacuums if they are not cloud connected, even when the other commands work. Do all other viomivacuum commands also cause the same error?

@v0d0r
Copy link

v0d0r commented Aug 10, 2020

Maybe the info command is not working on that device? Something similar happens on rockrobo gen1 vacuums if they are not cloud connected, even when the other commands work. Do all other viomivacuum commands also cause the same error?

Tried other commands but I get "no response from device"
I then tried the miiocli command specifically with the viomivacuum switch and I can get a status response this way at least.
I don't know how to connect it to the wifi after this step though (other than using the app) and after that I cant get any info out of it again.

miiocli viomivacuum --ip 192.168.5.1 --token 323776595A70656876594D3xxxxCxxxx status
State: ViomiVacuumState.Idle
Mode: ViomiMode.Vacuum
Error: Unknown error 0
Battery: 95
Fan speed: ViomiVacuumSpeed.Silent
Box type: ViomiBinType.Vacuum
Mop type: 0
Clean time: 0:01:14
Clean area: 58.36
Water grade: ViomiWaterGrade.Low
Remember map: True
Has map: True
Has new map: False
Mop mode: ViomiMode.Vacuum

@aelking
Copy link

aelking commented Aug 10, 2020

I am getting the same issue with my vacuum. It is working through the android app, and using npm miio, it is only from Home Assistant that I am finding it not working

Configuration.yaml
`vacuum:

  • platform: xiaomi_miio
    host: 192.168.1.224
    name: xiaomi_vacuum
    token: 326a516d4a6856535a754875446d5363`

Error
2020-08-10 21:47:15 DEBUG (SyncWorker_2) [miio.miioprotocol] Discovered 126edfca with ts: 2020-08-10 20:47:15, token: b'ffffffffffffffffffffffffffffffff' 2020-08-10 21:47:15 DEBUG (SyncWorker_2) [miio.miioprotocol] 192.168.1.224:54321 >>: {'id': 2028, 'method': 'get_status', 'params': []} 2020-08-10 21:47:20 DEBUG (SyncWorker_2) [miio.miioprotocol] Retrying with incremented id, retries left: 1 2020-08-10 21:47:20 DEBUG (SyncWorker_2) [miio.miioprotocol] Got a response: Container: data = Container: data = b'' (total 0) value = b'' (total 0) offset1 = 32 offset2 = 32 length = 0 header = Container: data = b'!1\x00 \x00\x00\x00\x00\x12n\xdf\xca_1\xb2Y' (total 16) value = Container: length = 32 unknown = 0 device_id = b'\x12n\xdf\xca' (total 4) ts = 2020-08-10 20:47:21 offset1 = 0 offset2 = 16 length = 16 checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)

Any idea what is going on, or is there any more information that I can gather?

@rytilahti
Copy link
Member

The integration supports only rockrobo vacuums at the moment, there is a custom component linked previously in this issue that allows using viomi vacuums with homeassistant. The steps to properly integrate support for these is also contained in some of the previous comments.

@v0d0r
Copy link

v0d0r commented Aug 11, 2020

The integration supports only rockrobo vacuums at the moment, there is a custom component linked previously in this issue that allows using viomi vacuums with homeassistant. The steps to properly integrate support for these is also contained in some of the previous comments.

Thanks this explains a bit. I will read the comments and see what bits are relevant to viomi.

@nhok3296
Copy link

Việc tích hợp chỉ hỗ trợ máy hút bụi rockrobo tại thời điểm hiện tại, có một thành phần tùy chỉnh được liên kết trước đó trong số này cho phép sử dụng máy hút bụi viomi với chất gia cố. Các bước để tích hợp đúng cách hỗ trợ cho những điều này cũng có trong một số nhận xét trước đây.

Cảm ơn điều này giải thích một chút. Tôi sẽ đọc các bình luận và xem những bit nào có liên quan đến viomi.

https://github.com/nqkdev/home-assistant-vacuum-styj02ym
Custom compoments viomi gen 2

@MartijnC1984
Copy link

MartijnC1984 commented Aug 17, 2020

Could the python-mioo be updated for HA > 0.113? Simply editing the manifest.json to reflect 5.0.3 did not work for me... I'm not sure what else to change.

Currently this is breaking the Xiaomi Miio Gateway Alarm integration built into Home Assistant. Downgrading HA to <0.113 will fix the issue.

[edit
Fixed it myself, by changing the manifast.json to "python-miio==0.5.3" (instead of '0.5.0.3') :-)

@v0d0r
Copy link

v0d0r commented Aug 21, 2020

The integration supports only rockrobo vacuums at the moment, there is a custom component linked previously in this issue that allows using viomi vacuums with homeassistant. The steps to properly integrate support for these is also contained in some of the previous comments.

thanks. managed to get it working. it was surprisingly easy. I ended up not resetting my vacuum at all and left it on the wifi as is. Then installed the older version of the mi home app version v5.4.45 in bluestacks. Got the token and it worked first time.

@cpuks
Copy link

cpuks commented Dec 7, 2020

Does anyone has any problems with miio2 & STYJ02YM recently? Running HA 0.118.4 / latest hassos and shortly after turning on it's available and works fine then about hour later:

Logger: custom_components.miio2.vacuum
Source: custom_components/miio2/vacuum.py:390
Integration: miio2
First occurred: 5 grudnia 2020, 16:57:57 (7162 occurrences)
Last logged: 20:06:52

Got exception while fetching the state: Unable to discover the device 192.168.88.128

It's available thorugh Xiaomi app, connected to China server but that does not matter due to fact using LAN, also firmware is 3.5.3.0047

@50l3r
Copy link

50l3r commented Dec 22, 2020

I have the same problem.

Firm: 3.5.3.0047
HA: 2020.12.0

2020-12-22 12:48:27 WARNING (MainThread) [homeassistant.helpers.entity] Update of vacuum.xiaomi_vacuum_cleaner is taking over 10 seconds
2020-12-22 12:48:37 WARNING (MainThread) [homeassistant.components.vacuum] Updating xiaomi_miio vacuum took longer than the scheduled update interval 0:00:20
2020-12-22 12:48:38 ERROR (SyncWorker_1) [miio.miioprotocol] Got error when receiving: timed out
2020-12-22 12:48:57 WARNING (MainThread) [homeassistant.components.vacuum] Updating xiaomi_miio vacuum took longer than the scheduled update interval 0:00:20
2020-12-22 12:48:58 ERROR (SyncWorker_1) [miio.miioprotocol] Got error when receiving: timed out

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@bkupidura
Copy link

STYJ02YM is still not supported by xiaomi_miio

@bkupidura
Copy link

@syssi @rytilahti can you share if there is any progress with this integration? Can we help in anyway?

@rytilahti
Copy link
Member

@bkupidura I haven't heard about anyone working on this. I think the integration would now thanks to the configflow work by @starkillerOG simpler, the necessary steps are mentioned in #27268 (comment)

If you want to help, you could try and see if it is enough to replace Vacuum with ViomiVacuum inside vacuum.py of the integration. If yes, it would be enough to select the class to be used based on the model information. If not, it may be necessary to do some API changes to the backend library (consolidating both vacuum types to have a common API).

@bkupidura
Copy link

bkupidura commented Apr 7, 2021

@rytilahti changing Vacuum to ViaomiVacuum didnt helped. But for me looks like issue with device.py and not vacuum.py. Please check logs from adding vacuum below. Vacuum and token is ok as it works with custom integration.

Maybe STYJ02YM is not supporting device info?

2021-04-07 21:54:17 DEBUG (MainThread) [homeassistant.components.xiaomi_miio.device] Initializing with host 10.0.150.27 (token 76335...)
2021-04-07 21:54:38 ERROR (SyncWorker_22) [miio.miioprotocol] Got error when receiving: timed out
2021-04-07 21:54:38 ERROR (MainThread) [homeassistant.components.xiaomi_miio.device] DeviceException during setup of xiaomi device with host 10.0.150.27

@rytilahti
Copy link
Member

@bkupidura device is a direct base-class for all types of vacuums, are you definitely sure you initialized ViomiVacuum here?

Is miiocli viomivacuum command working for you in console? You could also try to execute info using miiocli viomivacuum --ip <addr> --token <token> info to see if the info works fine.

@bkupidura
Copy link

Ok, so looks like my vacuum was in some weird state. After allowing vacuum access to internet miiocli is working.

bash-5.0# miiocli viomivacuum --ip 10.0.150.27 --token TOKEN info
Model: viomi.vacuum.v8
Hardware version: Linux
Firmware version: 3.5.3_0017

But still, changing Vacuum to ViomiVacuum is not working, as there are differences between those classes.

Ex.

  • fan_speed_presets() is missing for device, its part of device.status
  • device.clean_history() is missing
  • device.last_clean_details() is missing
  • self.vacuum_state.got_error is missing

And more...

After "fixing" those, i got error around fanspeed.

2021-04-07 23:57:14 ERROR (MainThread) [homeassistant.components.vacuum] Error while setting up xiaomi_miio platform for vacuum
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 213, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 322, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 514, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 547, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 310, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/vacuum/__init__.py", line 182, in state_attributes
    data[ATTR_FAN_SPEED] = self.fan_speed
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 282, in fan_speed
    speed = self.vacuum_state.fanspeed
  File "/usr/local/lib/python3.8/site-packages/miio/viomivacuum.py", line 336, in fanspeed
    return ViomiVacuumSpeed(self.data["suction_grade"])
  File "/usr/local/lib/python3.8/enum.py", line 339, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.8/enum.py", line 662, in __new__
    raise ve_exc
ValueError: None is not a valid ViomiVacuumSpeed

But lookss like this is issue with miio package as i get same error from cli:

miiocli viomivacuum --ip 10.0.150.27 --token TOKEN status

Traceback (most recent call last):
  File "/usr/local/bin/miiocli", line 8, in <module>
    sys.exit(create_cli())
  File "/usr/local/lib/python3.8/site-packages/miio/cli.py", line 45, in create_cli
    return cli(auto_envvar_prefix="MIIO")
  File "/usr/local/lib/python3.8/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/miio/click_common.py", line 285, in wrap
    result_msg = result_msg_fmt.format(**kwargs)
  File "/usr/local/lib/python3.8/site-packages/miio/viomivacuum.py", line 336, in fanspeed
    return ViomiVacuumSpeed(self.data["suction_grade"])
  File "/usr/local/lib/python3.8/enum.py", line 339, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.8/enum.py", line 662, in __new__
    raise ve_exc
ValueError: None is not a valid ViomiVacuumSpeed

@rytilahti
Copy link
Member

Could you please open a PR (or an issue with your findings) to python-miio repository? My plan for long has been to consolidate the API per device type (e.g., VacuumDevice) from which all different vacuum implementations inherit from) to make it simpler to support non-rockrobo vacuums easier, alas, I haven't found time to do that.

For the last error, you could use --debug to see what the device responds and why the suction_grade is not reported correctly. Maybe your specific device model or firmware does not have that information available. Feel free to create a separate issue on python-miio for that.

@bkupidura
Copy link

I created rytilahti/python-miio#1003 - probably during weekend i will have more time to investigate issue with python-miio.

@igorsantos07
Copy link
Contributor

Not sure if late to the party, but I was able to get my vacuum (of this model, the CN v7) through this project by nqkdev (via this article). There's also this other by nergal, that I didn't try simply because I only found it later.

I wonder if these (or help from their devs) could be leveraged to get it all working with the main HA Integration?

@rytilahti
Copy link
Member

There is already support on python-miio for vacuums from other vendors besides roborock (viomi, roidmi and dreame), but the library requires some refactoring to make it simpler to support those. Alas, so far none of the developers of the device-specific custom components have been in contact nor tried to actively push changes to python-miio, if any are needed at all.

It's mainly the lack of manpower (and/or interest) why this hasn't happened already. I wrote earlier down some notes (rytilahti/python-miio#1114) that should make it simpler to integrate support for other vacuums when I (or anyone who wishes to do so, contributions are welcome!) find some time to work on it.

Considering this issue has been closed for a while (and that it is about a new feature, i.e., a wish list item), I'll close this for comments. The discussion about feature requests (and custom components) should be continued on the community forums. If anyone (including the authors of custom components) wishes to contribute for the effort, feel free to contact me on the homeassistant discord :-)

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests