Skip to content

AC changes mac address?? #306

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

Closed
Rjdrenth opened this issue Feb 13, 2025 · 9 comments
Closed

AC changes mac address?? #306

Rjdrenth opened this issue Feb 13, 2025 · 9 comments

Comments

@Rjdrenth
Copy link

Rjdrenth commented Feb 13, 2025

Hi, I've got a Midea AC unit and I've used this integration with mixed results. However, that is not due to this integration, but rather my AC unit I believe.
So why am I posting here? Because I hope that someone can help me with a solution..

This is my situation:

  • Running msmart-ng discover always discovers my device and gives the following output:
    {'ip': '192.168.1.138', 'port': 6444, 'id': 208......, 'online': False, 'supported': False, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_F714', 'sn': '000000P0000000Q1502DBB58F7140000', 'key': None, 'token': None}
    It says 'supported': False. I am not sure why it says that, because the integration works fine when it finds my device.
  • Sometimes my air condition unit is available for long or short periods, sometimes it is not. It tends to give authentication errors, but this is not the real issue as I am not connecting with the cloud.
  • I noticed that the IP address seems to change. I noticed this from running msmart-ng discover and checking the contents of home-assistant-config/.storage/core.config_entries. Sometimes this was a different IP address than what msmart-ng reported. Changing the IP and restarting HA would make the device work again.
  • You would think setting a static IP address would be an obvious solution. That is what I thought too and why I felt like I was going crazy. Turns out I am not entirely crazy, because..
  • I started writing down the mac addresses and IP addresses of all my devices and was starting to blame my ISP's router for not handling DHCP properly, until I noticed that the MAC address changed.. Currently I've noticed 2 different address, but I am not discounting the possibility that there's more or that it's randomly generated.

Anyhow.. Has anyone encountered this issue before?
Or does anyone have any advice?

Unfortunately I cannot map 2 MAC addresses to the same IP..

Finally, apologies if this is not the place for my troubles. I can always close the issue, but any help or thoughts would be appreciated regardless.

@mill1000
Copy link
Owner

Hi there.

It says 'supported': False. I am not sure why it says that, because the integration works fine when it finds my device.

That's interesting. Can you run the discover command with the --debug options and post the output?

Sometimes my air condition unit is available for long or short periods, sometimes it is not. It tends to give authentication errors, but this is not the real issue as I am not connecting with the cloud.

This could be caused by a few things. One thing to try is the Maximum Connection Lifetime setting. The energy sensors have caused issues for some users due to their device not responding to the message.

Can't say anything about the MAC addresses. That's an odd one for sure.

@Rjdrenth
Copy link
Author

Thanks for taking a look.

Sure:

msmart-ng discover --debug
DEBUG:asyncio:Using selector: EpollSelector
INFO:msmart.cli:Discovering all devices on local network.
DEBUG:msmart.discover:Discovery sent to 255.255.255.255:6445.
DEBUG:msmart.discover:Discovery sent to 255.255.255.255:20086.
DEBUG:msmart.discover:Waiting 5 seconds for responses...
DEBUG:msmart.discover:Discovery response from 192.168.1.138: 837000b8200f04075a5a0111a8007a80000000000000000000000000273e00000013000000000000000000000000000047ece2e934f84ffb6a7149090033f6c9ba01498e6a0eb794a728cf3138af55512103a3492a6170ac40d4a7f2fc6281c4b0193039b791caa545d09454f3c164e59c0f71c63acd90e87f9918bc15de5fba682b11e235eef961e588bd6fd663cf18f31443d17c3aac03a7656614ae1dca448185f0f2a2feaacafc8624951973590fb2bd22a34d74542dc3f3f457eca949d9
DEBUG:msmart.discover:Decrypted data from 192.168.1.138: 8a01a8c02c19000030303030303050303030303030305131353032444242353846373134303030300b6e65745f61635f463731340000000001000000040000000000ac00000000000000502dbb58f714069fcd0300060103000000000000000000000000000000000000000000
INFO:msmart.cloud:Using Midea cloud server: https://mp-prod.appsmb.com (China: False).
INFO:httpx:HTTP Request: POST https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=/v1/user/login/id/get "HTTP/1.1 200 "
DEBUG:msmart.cloud:API response: {"code":"3102","msg":"Account or password incorrect, please re-enter"}
ERROR:msmart.discover:Failed to login to cloud. Error: Code: 3102, Message: Account or password incorrect, please re-enter
ERROR:msmart.discover:Could not establish cloud connection.
DEBUG:msmart.discover:Discovered 1 devices.
INFO:msmart.cli:Found 1 devices.
INFO:msmart.cli:Found device:
{'ip': '192.168.1.138', 'port': 6444, 'id': 20890720943655, 'online': False, 'supported': False, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_F714', 'sn': '000000P0000000Q1502DBB58F7140000', 'key': None, 'token': None}

I tried tuning the Maximum Connection Lifetime setting. But I am unsure what the recommended value is. I assumed it would be a longer value, e.g. 60 seconds, but I also saw something like 15 seconds. What do you recommend?

@mill1000
Copy link
Owner

ERROR:msmart.discover:Failed to login to cloud. Error: Code: 3102, Message: Account or password incorrect, please re-enter
ERROR:msmart.discover:Could not establish cloud connection.
{'ip': '192.168.1.138', 'port': 6444, 'id': 20890720943655, 'online': False, 'supported': False, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_F714', 'sn': '000000P0000000Q1502DBB58F7140000', 'key': None, 'token': None}

This is the bigger problem. Try setting a different cloud region or using another username & password.

@fcordella
Copy link

fcordella commented Mar 3, 2025

Not sure is it is the same problem, but my "Midea" airconditioners stop woking a couple of days ago: they became not available (it happened a week ago too, and I thought it was because the IP addresses changed: I deleted them from HA integration, rediscoverd and they worked again) and, after deleted them, I cannot add anymore: Midea Smart AC HACS integration found them, but I receive the message "unable to connect".
So I tried with msmart-ng discover --region DE and it says:

`INFO:msmart.cli:Discovering` all devices on local network.
INFO:msmart.cloud:Using Midea cloud server: https://mp-prod.appsmb.com (China: False).
ERROR:msmart.discover:Code: 3004, Message: value is illegal.
ERROR:msmart.discover:Code: 3004, Message: value is illegal.
ERROR:msmart.discover:Code: 3004, Message: value is illegal.
ERROR:msmart.discover:Code: 3004, Message: value is illegal.
INFO:msmart.cli:Found 2 devices.
INFO:msmart.cli:Found device:
{'ip': '192.168.0.89', 'port': 6444, 'id': 152832116327243, 'online': False, 'supported': False, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_2DF0', 'sn': '000000P0000000Q1D48457F82DF00000', 'key': None, 'token': None}
INFO:msmart.cli:Found device:
{'ip': '192.168.0.51', 'port': 6444, 'id': 153931627954517, 'online': False, 'supported': False, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_7094', 'sn': '000000P0000000Q1D48457FB70940000', 'key': None, 'token': `None}`

It finds 2 units, but they are 3 (yes, the third one is connected and available on the local network)

This is the output with --debug option:

`DEBUG:asyncio:Using selector: EpollSelector
INFO:msmart.cli:Discovering all devices on local network.
DEBUG:msmart.discover:Discovery sent to 255.255.255.255:6445.
DEBUG:msmart.discover:Discovery sent to 255.255.255.255:20086.
DEBUG:msmart.discover:Waiting 5 seconds for responses...
DEBUG:msmart.discover:Discovery response from 192.168.0.89: 837000c8200f00005a5a0111b8007a8000000000b8b62110030319144b030100008b0000000000000000018000000000c5731cad5cfbf46dfd22d316266505afe9771bdade987b4bcbcb938c0e3d3482bcc641bd4a55ea7912d7075b3c6e7cea8caefd69cb1f88473232b5bba394ee3feb9857bf9d0d026c9c90e4d96093841ed02d2c8d499d71354c08e60d8bd50b304bdfb3e16e33d88768cc4c3d0658937d0bb19369bf0317b24d3a4de9e6a13106f10a3e4519ead5c81b1db7c2c2e2c9cbe1a0b7560325df007fcc1368f29ecae5
DEBUG:msmart.discover:Decrypted data from 192.168.0.89: 5900a8c02c19000030303030303050303030303030305131443438343537463832444630303030300b6e65745f61635f324446300000870002000000000000000000ac00acac00000000d48457f82df0150029102237000300000000000000000000000000000000000000000000000000000000000000000000
INFO:msmart.cloud:Using Midea cloud server: https://mp-prod.appsmb.com (China: False).
DEBUG:msmart.discover:Discovery response from 192.168.0.51: 837000c8200f00005a5a0111b8007a8000000000d3b621100303191455010100008c00000000000000000180000000006940a167b0314c6eac0cb9d4bb1ddbaf5e3107850064c5dd59b6ccfeeccb3625680caf139735d73b693df5fd1c82de14a0d659c19ab6f721d3573702de9d3372f69f9edaffac8644b6da8b21d092535cd02d2c8d499d71354c08e60d8bd50b304bdfb3e16e33d88768cc4c3d0658937d0bb19369bf0317b24d3a4de9e6a13106bb257449364571db8e9891ba75e96aafdf20e55aae0f006c199b8ed2b822357d
DEBUG:msmart.discover:Decrypted data from 192.168.0.51: 3300a8c02c19000030303030303050303030303030305131443438343537464237303934303030300b6e65745f61635f373039340000870002000000000000000000ac00acac00000000d48457fb7094150029102237000300000000000000000000000000000000000000000000000000000000000000000000
INFO:httpx:HTTP Request: POST https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=/v1/user/login/id/get "HTTP/1.1 200 "
DEBUG:msmart.cloud:API response: {"code":"0","msg":"ok","data":{"loginId":"184608c6-0bcf-458c-a358-46174494"}}
DEBUG:msmart.cloud:Received loginId: 184608c6-0bcf-458c-a358-46174494
DEBUG:msmart.discover:Discovered 2 devices.
INFO:httpx:HTTP Request: POST https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=/mj/user/login "HTTP/1.1 200 OK"
DEBUG:msmart.cloud:API response: {"code":0,"msg":"成功","data":{"randomData":"37654f0a14db0144e2ff6591045495797cb4e832d30e5dc43d7e8c36acca9490","uid":"d503d0236bbe1a0dc975d17c82ab2ec7","accountId":"1057428409","nickname":"midea_eu","mdata":{"tokenPwdInfo":{"tokenPwd":"f3a2e922d66e4c69895cfcbc8b395d5c","expiredDate":1743611641007,"createDate":1741019641007},"userInfo":{"sourceId":"mj_12345","empId":"6027259613409280","address":"","gender":"0","mobile":"midea_eu@mailinator.com","userDeptInfoList":null,"extras":null,"nameEn":null,"employeeNumber":null,"headPhoto":null,"uid":"d503d0236bbe1a0dc975d17c82ab2ec7","name":"midea_eu@mailinator.com","email":null},"doDeviceBind":null,"accessToken":"T1p6n2rez9c0yy5z","signUnlockEnabled":null},"accessToken":"f5c43d285f96f24c04d1f7ff0a9f14f061f99e3892add4d09850d9fc88ccaddd","userId":"162078981390337","email":"midea_eu@mailinator.com"}}
DEBUG:msmart.cloud:Received accessToken: T1p6n2rez9c0yy5z
DEBUG:msmart.discover:Fetching token and key for udpid 'd0b2db0ed98a3b188f9908b86b574397' (little).
DEBUG:msmart.discover:Fetching token and key for udpid '2e8980b80597320024c2ec037bf32d88' (little).
INFO:httpx:HTTP Request: POST https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=/v1/iot/secure/getToken "HTTP/1.1 200 OK"
DEBUG:msmart.cloud:API response: {"code":"3004","msg":"value is illegal."}
ERROR:msmart.discover:Code: 3004, Message: value is illegal.
DEBUG:msmart.discover:Fetching token and key for udpid 'e1a0b7560325df007fcc1368f29ecae5' (big).
INFO:httpx:HTTP Request: POST https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=/v1/iot/secure/getToken "HTTP/1.1 200 OK"
DEBUG:msmart.cloud:API response: {"code":"3004","msg":"value is illegal."}
ERROR:msmart.discover:Code: 3004, Message: value is illegal.
DEBUG:msmart.discover:Fetching token and key for udpid 'df20e55aae0f006c199b8ed2b822357d' (big).
INFO:httpx:HTTP Request: POST https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=/v1/iot/secure/getToken "HTTP/1.1 200 OK"
DEBUG:msmart.cloud:API response: {"code":"3004","msg":"value is illegal."}
ERROR:msmart.discover:Code: 3004, Message: value is illegal.
INFO:httpx:HTTP Request: POST https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=/v1/iot/secure/getToken "HTTP/1.1 200 OK"
DEBUG:msmart.cloud:API response: {"code":"3004","msg":"value is illegal."}
ERROR:msmart.discover:Code: 3004, Message: value is illegal.
INFO:msmart.cli:Found 2 devices.
INFO:msmart.cli:Found device:
{'ip': '192.168.0.51', 'port': 6444, 'id': 153931627954517, 'online': False, 'supported': False, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_7094', 'sn': '000000P0000000Q1D48457FB70940000', 'key': None, 'token': None}
INFO:msmart.cli:Found device:
{'ip': '192.168.0.89', 'port': 6444, 'id': 152832116327243, 'online': False, 'supported': False, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_2DF0', 'sn': '000000P0000000Q1D48457F82DF00000', 'key': None, 'token': None}`

@Rjdrenth
Copy link
Author

Rjdrenth commented Mar 4, 2025

ERROR:msmart.discover:Failed to login to cloud. Error: Code: 3102, Message: Account or password incorrect, please re-enter
ERROR:msmart.discover:Could not establish cloud connection.
{'ip': '192.168.1.138', 'port': 6444, 'id': 20890720943655, 'online': False, 'supported': False, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_F714', 'sn': '000000P0000000Q1502DBB58F7140000', 'key': None, 'token': None}

This is the bigger problem. Try setting a different cloud region or using another username & password.

Obviously you're the expert, but I did not think that was the issue, as I have been able to connect to the device and control it locally without ever supplying a username and password.
But maybe the device fails and switches IP as a safety measure? That would be a bit unconventional, but who knows..

What I did as a solution was butcher your code and hardcoded 2 IP addresses in (https://github.com/mill1000/midea-msmart/blob/main/msmart/base_device.py)[msmart/base_device]. I then initialised 2 Lan objects and made _lan a list of those. With some additional changes, mainly in _send_command I simply try one object and if it fails it tries the other..

As a coder I think it's ugly and I apologise that you had to read this, haha.
Buuuut... It works.

It doesn't seem like a common problem, but if you like, I could try and make the code acceptable and make a pull request? The idea would then be that a user could enter multiple comma-separated IP addresses when adding the device to HA.

For the record, I 100% believe it is an issue with my particular / a select few of USB dongles and not with this library. So thank you for maintaining it.

@fcordella I honestly have no clue. I just know python, but very little about Home Assistant and A/C's

@mill1000
Copy link
Owner

@fcordella Your issue appears to be related to mill1000/midea-msmart#193

The Midea cloud has started rejecting the requests being made to it by this integration. However, this only effects the discovery process for V3 devices.

@Rjdrenth Well I'm glad you found a solution for yourself and I appreciate the offer. I'm not sure I'd want to merge that change. It's fixing a very specific problem I'm not sure others experience.

Have you tried assigning a hostname to the device? I think the library can use a hostname in place of an IP address without issue.

@Rjdrenth
Copy link
Author

Thanks for the suggestion of assigning a hostname. That was my initial preferred solution as well, but I did not manage to set that up properly :(

If you happen to know how that can be achieved I would love to know it; googling or asking chatgpt did not yield any usable results, but perhaps I was simply using the wrong terminology.

@mill1000
Copy link
Owner

Gotcha.

It really depends on the capabilities of your router and/or if you have another DNS system setup (e.g. Pi-Hole or AdGuard Home).

Or if you're on a Linux system, maybe try adding an entry to /etc/hosts

@Rjdrenth
Copy link
Author

Thanks, I'll look into those :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants