mac-zhou / midea-ac-py

Home Assistant Custom Integration for Midea Group(Hualing, Senville, Klimaire, AirCon, Century, Pridiom, Thermocore, Comfee, Toshiba, Carrier, Goodman, Friedrich, Samsung, Kenmore, Trane, Lennox, LG and much more) Air Conditioners via LAN.
MIT License
519 stars 101 forks source link

midea-discover returns code 3004 "value is illegal" #217

Open Xe138 opened 11 months ago

Xe138 commented 11 months ago

Describe the bug (描述一下问题) Running midea-discover fails with "RecursionError" after multiple cloud POST attempts.

Screenshots / Logs / Pcap File(屏幕截图/日志/抓包文件)

midea-discover -a [ACCOUNT] -p [PASSWORD] -d -i 192.168.20.60
INFO:msmart.cli:Debug mode active
INFO:msmart.cli:msmart version: 0.2.5 Currently only supports ac devices, only support MSmartHome and 美的美居 APP.
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:msmart.scanner:Message sent
DEBUG:msmart.scanner:Midea Local Data 192.168.20.60 837000c8200f00005a5a0111b8007a80000000005e9102001f071714190303000089000000000000000001800000000078a086a57bf11b616c0f9552b7deec477ee2c11fcfdeee58ef906e0fa5170bf12eef680226f3bea7639f92c9f6331c9860f4e458b57fcd0408fbfcb52b0c7594f60080bf6a2220ddeb9bf244cdc41334aa50fed3be676d17ed6fb38c2691b88546cc8a3f287d37a7e9fdd547194fd8ad0bb19369bf0317b24d3a4de9e6a131067e2b1bd8453878df33b1624510779f83d8320d16b42dde320b144364a850c433
DEBUG:msmart.scanner:Decrypt Reply: 192.168.20.60 3c14a8c02c19000030303030303050303030303030305131414339334334313738373830303030300b6e65745f61635f383738300000870002000000000000000000ac00acac00000000ac93c41787801500230821220003005d548a309eb8592407e030b90905f70f0000000000000000000000000000000000
INFO:msmart.cloud:Using Midea cloud server: https://mp-prod.appsmb.com/mas/v5/app/proxy?alias= False
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/user/login/id/get HTTP/1.1" 200 41
DEBUG:msmart.cloud:Response: {"code":"3004","msg":"value is illegal."}
DEBUG:msmart.cloud:Error ignored: '3004' - 'value is illegal.'
DEBUG:msmart.cloud:Retrying API call: '/v1/user/login/id/get'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/user/login/id/get HTTP/1.1" 200 41
DEBUG:msmart.cloud:Response: {"code":"3004","msg":"value is illegal."}
DEBUG:msmart.cloud:Error ignored: '3004' - 'value is illegal.'
DEBUG:msmart.cloud:Retrying API call: '/v1/user/login/id/get'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/user/login/id/get HTTP/1.1" 200 41
DEBUG:msmart.cloud:Response: {"code":"3004","msg":"value is illegal."}
DEBUG:msmart.cloud:Error ignored: '3004' - 'value is illegal.'
DEBUG:msmart.cloud:Retrying API call: '/v1/user/login/id/get'
Traceback (most recent call last):
  File "/home/bballou/.local/bin/midea-discover", line 8, in <module>
    sys.exit(discover())
  File "/home/bballou/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/bballou/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/bballou/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/bballou/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cli.py", line 51, in discover
    found_devices = loop.run_until_complete(discovery.get_all() if ip == '' else discovery.get(ip))
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 205, in get
    await self._process_tasks([task])
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 199, in _process_tasks
    [self.result.add(task.result()) for task in tasks]
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 199, in <listcomp>
    [self.result.add(task.result()) for task in tasks]
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 50, in support_test
    _device = await self.support_testv3(account, password)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 65, in support_testv3
    token, key = await loop.run_in_executor(None, gettoken, udpid, account, password)
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 255, in gettoken
    Client.login()
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 143, in login
    self.get_login_id()
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 132, in get_login_id
    response = self.api_request(
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 121, in api_request
    return self.api_request(endpoint, args)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 121, in api_request
    return self.api_request(endpoint, args)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 123, in api_request
    raise RecursionError()
RecursionError

Versions (版本信息)

mill1000 commented 11 months ago

Does it work if you don't specify an account and password?

Xe138 commented 11 months ago

Does it work if you don't specify an account and password?

Same result

midea-discover -d -i 192.168.20.60
INFO:msmart.cli:Debug mode active
INFO:msmart.cli:msmart version: 0.2.5 Currently only supports ac devices, only support MSmartHome and 美的美居 APP.
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:msmart.scanner:Message sent
DEBUG:msmart.scanner:Midea Local Data 192.168.20.60 837000c8200f00005a5a0111b8007a8000000000544d0e0201081714190303000089000000000000000001800000000078a086a57bf11b616c0f9552b7deec477ee2c11fcfdeee58ef906e0fa5170bf12eef680226f3bea7639f92c9f6331c9860f4e458b57fcd0408fbfcb52b0c7594f60080bf6a2220ddeb9bf244cdc41334f62b1d8bb9e5c25dba7bf8e0cc4c77944bdfb3e16e33d88768cc4c3d0658937d0bb19369bf0317b24d3a4de9e6a1310679713337f1d8aa3071e0b68f082982f2d8320d16b42dde320b144364a850c433
DEBUG:msmart.scanner:Decrypt Reply: 192.168.20.60 3c14a8c02c19000030303030303050303030303030305131414339334334313738373830303030300b6e65745f61635f383738300000870002000000000000000000ac00acac00000000ac93c4178780150023082122000300000000000000000000000000000000000000000000000000000000000000000000
INFO:msmart.cloud:Using Midea cloud server: https://mp-prod.appsmb.com/mas/v5/app/proxy?alias= False
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/user/login/id/get HTTP/1.1" 200 41
DEBUG:msmart.cloud:Response: {"code":"3004","msg":"value is illegal."}
DEBUG:msmart.cloud:Error ignored: '3004' - 'value is illegal.'
DEBUG:msmart.cloud:Retrying API call: '/v1/user/login/id/get'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/user/login/id/get HTTP/1.1" 200 41
DEBUG:msmart.cloud:Response: {"code":"3004","msg":"value is illegal."}
DEBUG:msmart.cloud:Error ignored: '3004' - 'value is illegal.'
DEBUG:msmart.cloud:Retrying API call: '/v1/user/login/id/get'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/user/login/id/get HTTP/1.1" 200 41
DEBUG:msmart.cloud:Response: {"code":"3004","msg":"value is illegal."}
DEBUG:msmart.cloud:Error ignored: '3004' - 'value is illegal.'
DEBUG:msmart.cloud:Retrying API call: '/v1/user/login/id/get'
Traceback (most recent call last):
  File "/home/bballou/.local/bin/midea-discover", line 8, in <module>
    sys.exit(discover())
  File "/home/bballou/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/bballou/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/bballou/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/bballou/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cli.py", line 51, in discover
    found_devices = loop.run_until_complete(discovery.get_all() if ip == '' else discovery.get(ip))
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 205, in get
    await self._process_tasks([task])
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 199, in _process_tasks
    [self.result.add(task.result()) for task in tasks]
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 199, in <listcomp>
    [self.result.add(task.result()) for task in tasks]
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 50, in support_test
    _device = await self.support_testv3(account, password)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 65, in support_testv3
    token, key = await loop.run_in_executor(None, gettoken, udpid, account, password)
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/scanner.py", line 255, in gettoken
    Client.login()
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 143, in login
    self.get_login_id()
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 132, in get_login_id
    response = self.api_request(
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 121, in api_request
    return self.api_request(endpoint, args)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 121, in api_request
    return self.api_request(endpoint, args)
  File "/home/bballou/.local/lib/python3.10/site-packages/msmart/cloud.py", line 123, in api_request
    raise RecursionError()
RecursionError
mill1000 commented 11 months ago

Confirmed the same behavior on my end. Maybe Midea has changed their API or something

mill1000 commented 11 months ago

I believed I've fixed this in my fork: mill1000/midea-ac-py

jkfoong commented 11 months ago

Tested and working well on my side. Thanks!

TopoTop1 commented 7 months ago

I believed I've fixed this in my fork.

You can update msmart with pip like so

pip install git+https://github.com/mill1000/midea-msmart.git

Thank you! How do Install your version? I am not sure how this work in Home Assistant

mill1000 commented 7 months ago

Thank you! How do Install your version? I am not sure how this work in Home Assistant

My fork is now a default in HACs. You can either search for "Midea Smart AC" or click the link here: https://github.com/mill1000/midea-ac-py/#install-via-hacs

Edit: Or if you're just looking for an updated tool to discover tokens & keys see this fork: https://github.com/mill1000/midea-msmart

TopoTop1 commented 7 months ago
Yes sir, thanks for doing this BTW. I just found it, installed it and am working through it but it will not discover my Midea Cube Dehumes. The original AC LAN one from the other guy does discover them. I used that version to get my ID’s, and then used yours to try to install. Your fork will not auto discover so I went manually and input the IDs, IP Addressees and used the default port but the error I get is here. Thoughts?:  Sent from Mail for Windows From: Tucker KernSent: Wednesday, November 29, 2023 2:02 PMTo: mac-zhou/midea-ac-pyCc: TopoTop1; CommentSubject: Re: [mac-zhou/midea-ac-py] midea-discover returns code 3004 "value is illegal" (Issue #217) Thank you! How do Install your version? I am not sure how this work in Home AssistantMy fork is now a default in HACs. You can either search for "Midea Smart AC" or click the link here: https://github.com/mill1000/midea-ac-py/#install-via-hacs—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***> 
mill1000 commented 7 months ago

My integration only supports air conditioning type devices. You should continue to use georgezhao2010/midea_ac_lan integration with your dehumidifiers.

TopoTop1 commented 7 months ago

Ok bummer. Thanks.

His is broken and won't login to the cloud.

Yours looks great. I hope ypu decide to add dehumes as your install is cleaner, UI experience is easier.

Keep up the great work!

On Wed, Nov 29, 2023, 2:23 PM Tucker Kern @.***> wrote:

My integration only supports air conditioning type devices. You should continue to use georgezhao2010's midea_ac_lan https://github.com/georgezhao2010/midea_ac_lan integration with your dehumidifiers.

— Reply to this email directly, view it on GitHub https://github.com/mac-zhou/midea-ac-py/issues/217#issuecomment-1832645529, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEKNA43QE6B242KHNTS2XA3YG6KSJAVCNFSM6AAAAAA264LJBSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZSGY2DKNJSHE . You are receiving this because you commented.Message ID: @.***>