al-one / hass-xiaomi-miot

Automatic integrate all Xiaomi devices to HomeAssistant via miot-spec, support Wi-Fi, BLE, ZigBee devices. 小米米家智能家居设备接入Hass集成
https://miot-spec.com
Apache License 2.0
4.58k stars 649 forks source link

DE server - Unable to get devices #345

Closed Wh1terat closed 2 years ago

Wh1terat commented 2 years ago

Something has changed with auth to DE server (maybe others) but not CN.

Unable to get devices or tokens, still works in MiHome and CN server still working with integration.

TheLordVader commented 2 years ago

Yes, I can confirm this issue as well. Devices unavailable.

neliets commented 2 years ago

I can also confirm - no devices are found suddenly. For me, even if I select China server, still finds none. Mi home everything is working and present.

this happened overnight from December 30th to 1st of January. No problems before that.

Zeunas commented 2 years ago

Same as above with EU, only CN seems to be working

RPSouto commented 2 years ago

Same here. Only Mi Home is working since yesterday.

raptr55 commented 2 years ago

Same for me. Only mi Home Is working. Not only vacuums but cameras has same problem

balbulator commented 2 years ago

I confirm, I have the same thing, the server is Europe

al-one commented 2 years ago

Are there any related logs ?

raptr55 commented 2 years ago

Are there any related logs ?

Got xiaomi cloud devices for xxxx@xxx.xxx failed: {'code': 0, 'message': 'auth err'}

kennetjuh commented 2 years ago

I'm having the same issue, i don't think it's related to this intergration. the token_extractor is also not able to connect to the europe (de) server.

Logging in...
Logged in.

No devices found for server "cn".
Unable to get devices.
No devices found for server "us".
No devices found for server "ru".
No devices found for server "tw".
No devices found for server "sg".
No devices found for server "in".
No devices found for server "i2".

swapping to the cn server might be a quick fix for now.

No-Smart commented 2 years ago

I have the same problem 😕

al-one commented 2 years ago

Does the same problem exist in HA's built-in component xiaomi_miio ?

balbulator commented 2 years ago

Authorization and connection from the phone through MiHome passes without problems, but with Home Assistant in no way

balbulator commented 2 years ago

Does the same problem exist in HA's built-in component xiaomi_miio ?

No

raptr55 commented 2 years ago

Does the same problem exist in HA's built-in component xiaomi_miio ?

Bult-in component work, my roborock vacuum Is visible and it's working. I have another custom component that extract the Cloud map but It doesn't work either

kennetjuh commented 2 years ago

Does the same problem exist in HA's built-in component xiaomi_miio ?

For me it also fails connecting to the 'de' server. unknown error. when i setup the integration for the 'cn' server i get no devices as expected

image The 1st error is on server 'de' the second on 'cn'

2022-01-01 14:32:21 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/config_flow.py", line 250, in async_step_cloud
    devices_raw = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/site-packages/micloud/micloud.py", line 251, in get_devices
    return json_resp['result']['list']
KeyError: 'result'
RPSouto commented 2 years ago

Tested two more Integrations with same results.

Only DE server with problems

rezmus commented 2 years ago

@al-one they force rc4 on de region since yesterday ;d you may want to enable it by default, because all other clouds will probably follow soon.

KitHubek commented 2 years ago

the same problem here with DE serv. Unknown error occurred Xiaomi app (android and ios too) working ok

unknow error occurreds

rezmus commented 2 years ago

to use rc4 by default try to change crypt=False to crypt=True in core/xiaomi_cloud.py

al-one commented 2 years ago

to use rc4 by default try to change crypt=False to crypt=True in core/xiaomi_cloud.py

Does it work for you ?

rezmus commented 2 years ago

i dont use HA or know python, so cant check, but rc4 works for me on de.

kennetjuh commented 2 years ago

to use rc4 by default try to change crypt=False to crypt=True in core/xiaomi_cloud.py

I tried this quick fix, but for me it's not working. (could still be someting wrong on my end)

wojciea commented 2 years ago

to use rc4 by default try to change crypt=False to crypt=True in core/xiaomi_cloud.py

Does it work for you ?

Changing

-    def request_miot_api(self, api, data, method='POST', crypt=False, debug=True, **kwargs):
+    def request_miot_api(self, api, data, method='POST', crypt=True, debug=True, **kwargs):
        params = {}

does NOT solve the issue. I can see

def request_rc4_api

being used (added some logging there) But still get the Got xiaomi cloud devices for %s failed: {'code': 0, 'message': 'auth err'} from def get_device_list

Wh1terat commented 2 years ago

Should move to the new device list endpoint too now rc4 is enforced (/app/v2/home/device_list_page)

Wh1terat commented 2 years ago

@rezmus , @al-one I made this mitmproxy script to make everyone's lives much easier. (borrowed the rc4 funcs from here @al-one, hope you don't mind)

It's got to catch the ssecurity token from serviceLoginAuth2 to work, or you can set it yourself.

https://gist.github.com/Wh1terat/a9a151d69538abb9d5fe317dee0ffe23

Request Response
Jo-Jo1987 commented 2 years ago

Currently facing the same issues with also the integration of Xiaomi Gateway 3. So i assume the issue is at the DE servers itself. I am also using Xiaomi MIOT auto and i cannot renew anything and it does also not show my current working devices up and running. I tried the workaround with the RC4 to set crypt false but it did not fix anything at all.

urukalo commented 2 years ago

here is a solution used on the token extractor

https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor/commit/0e98bcae9aef525a7945e8c6a41df2c4e2d54ba5

al-one commented 2 years ago

Thanks! I have fixed the bug in the latest commit of branch v0.4.x. Please urgrade and try. If it works, I will publish the version and merge it into the master branch.

To upgrade to latest commit of v0.4.x:

wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | ARCHIVE_TAG=v0.4.x bash -
RPSouto commented 2 years ago

Tested and everything seems to work just fine! Amazing!

kennetjuh commented 2 years ago

Thanks! I have fixed the bug in the latest commit of branch v0.4.x. Please urgrade and try. If it works, I will publish the version and merge it into the master branch.

To upgrade to latest commit of v0.4.x:

wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | ARCHIVE_TAG=v0.4.x bash -

This fix works perfect for me. thanks for your effort!!!

pkejval commented 2 years ago

I can confirm that fix in https://github.com/al-one/hass-xiaomi-miot/issues/345#issuecomment-1003857714 is working! Thank you!

kodifan commented 2 years ago

fix is working like a charm. thx :)

Jo-Jo1987 commented 2 years ago

works fine again!

alimek commented 2 years ago

works for me too 👍 💯

Jo-Jo1987 commented 2 years ago

Hi, It looks fixed at first sight! But, i do have a bootup time from Home assistant which needed 149 seconds!

Yesterday i faced issues all over the place with Xiaomi cloud DE servers. Now this has been fixed in Xiaomi miot auto and as well in the xiaomi cloud map extractor.

I use a roborock S7 , but after all the updates. I lost my map and it does not start up correct Also my home assistant keeps starting , and waiting on something right now and became very slow xiaomi_miot: username: password: camera:

Using above settings in my config.yaml

All things working according in Xiaomi , except my robot. And as well , the booting time takes more than 140 seconds right now. So i guess, it is not completely fixed yet.

mentalloflex commented 2 years ago

I'm afraid I still get the error with the DE server. Have tried reinstalling the integration but to no avail. What could I be doing wrong?

sdimitrov-sms commented 2 years ago

@mentalloflex the fix is not official yet, so you have to update manually, as it was explained earlier in the thread. When @al-one makes it official and pushes it to master, only then reinstalling will fix the issue OOTB.

mentalloflex commented 2 years ago

Got it! Thank you!

No-Smart commented 2 years ago

Manual FIX Work OK!!!!!!!! Fantastic

wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | ARCHIVE_TAG=v0.4.x bash -

raptr55 commented 2 years ago

Hi, It looks fixed at first sight! But, i do have a bootup time from Home assistant which needed 149 seconds!

Yesterday i faced issues all over the place with Xiaomi cloud DE servers. Now this has been fixed in Xiaomi miot auto and as well in the xiaomi cloud map extractor.

I use a roborock S7 , but after all the updates. I lost my map and it does not start up correct Also my home assistant keeps starting , and waiting on something right now and became very slow xiaomi_miot: username: password: camera:

  • platform: xiaomi_cloud_map_extractor host: token: username: password: draw: ['all'] attributes:

    • calibration_points

Using above settings in my config.yaml

All things working according in Xiaomi , except my robot. And as well , the booting time takes more than 140 seconds right now. So i guess, it is not completely fixed yet.

You have closed this bug in the other thread.

@al-one could you kindly merge this fix info the master branch?

Zeunas commented 2 years ago

Same 😃

kimme1024 commented 2 years ago

Tried upgrading on MacOS but still can't login into integration (unknown error occured)

balbulator commented 2 years ago

Tell me, maybe I'm doing something wrong, but this is what I get in the terminal 1

Jo-Jo1987 commented 2 years ago

you miss the wget in the front. don't copy paste. Please type it in.

szymonmal commented 2 years ago

@balbulator I think it's spaces after ARCHIVE_TAG and equals sign, please remove them and try again. Change ARCHIVE_TAG = v0.4.x to ARCHIVE_TAG=v0.4.x

Copy paste from al-one post should also work:

wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | ARCHIVE_TAG=v0.4.x bash -
balbulator commented 2 years ago

Thanks! Everything works as before!

kimme1024 commented 2 years ago

Hi,

I tried

wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | ARCHIVE_TAG=v0.4.x bash -

This installs the component as it should.

However I still can't connect to miio with this as a log:

Logger: aiohttp.server
Source: components/xiaomi_miio/config_flow.py:250 
First occurred: 16:52:36 (1 occurrences) 
Last logged: 16:52:36

Error handling request
Traceback (most recent call last):
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware
    return await handler(request)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/auth.py", line 181, in auth_middleware
    return await handler(request)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/components/config/config_entries.py", line 157, in post
    return await super().post(request, flow_id)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/data_entry_flow.py", line 252, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/homeassistant/components/xiaomi_miio/config_flow.py", line 250, in async_step_cloud
    devices_raw = await self.hass.async_add_executor_job(
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/kimheymans/Documents/homeassistant/lib/python3.9/site-packages/micloud/micloud.py", line 251, in get_devices
    return json_resp['result']['list']
KeyError: 'result'

I'm running Monterey on an M1 mini.

Thanks in advance!

al-one commented 2 years ago

@kimme1024 xiaomi_miio is not this custom component.

Wh1terat commented 2 years ago

With https://github.com/al-one/hass-xiaomi-miot/commit/6ef3e24b9f3742b586135c0371efad9b27ae1a34 being merged, I'm going to close this issue now.

Thanks @al-one 😄

balbulator commented 2 years ago

An update has come, thanks to the author