krahabb / meross_lan

Home Assistant integration for Meross devices
MIT License
455 stars 47 forks source link

Unable to connect to Meross account #186

Closed ayoward closed 1 year ago

ayoward commented 2 years ago

Hello,

I have recently installed Home Assistant so am fairly new to this, but I like to think I am IT literate (I have managed to make a career out of it) however, I am struggling with getting Home Assistant/Meross LAN to connect to my account for the device key.

I bought a Meross Smart WiFi Surge Protector specifically because of the Home Assistant integration and while I have successfully attached it to the WiFi, set up a Meross account on the app and linked the device, installed Meross LAN via HACS, but when it comes to the configuration, which rightly or wrongly I set as Cloud Retrieval (not sure how to change that now, but that's another issue) it is asking for my credentials for Device Key Retrieval which when I put them in, it fails every time.

Does anyone know what I am doing wrong? I know the credentials are correct as I have them stored in my password vault.

Any help would be greatly appreciated.

Thanks,

Andrew

Meross
krahabb commented 2 years ago

Hello @ayoward , I see by the screenshot you get an 'unable to connect' error so I would investigate why you can't reach to the meross login servers which (as implemented in meross_lan) should respond on 'https://iot.meross.com/v1/Auth/Login'

squaredcircle commented 2 years ago

I also have this problem - same error message "unable to connect". My instance of Home Assistant can communicate with https://iot.meross.com/v1/Auth/Login as seen here:

image

Anything I can try to make this work?

krahabb commented 2 years ago

Hello, I've checked the meross_lan code in search of clues and I have to admit the 'unable to connect' error is raised on any error, I've also seen that now, if you enter wrong credentials, the actual flow implementation just 'works' by returning an empty key with no error warning to the user so I'm going to try refactor the code a bit trying to add more detailed informations on the error.

krahabb commented 2 years ago

Hello @squaredcircle, I've just released an 'alpha' with a small fix so to have better insights on this error. You should see an additional field on the form stating the actual reason for the error so we might have a better chance to further investigate it

squaredcircle commented 2 years ago

Hey @krahabb, I updated to the new alpha and tried again - here's the error:

image

krahabb commented 2 years ago

Awww.. this message looks like the key field is missing from the server response. The reason is still unclear though since this error happens in an unexpected piece of code. The server response usually carries the reason but we've missed that. I'll better refine the error handling so to try have this 'reason' shown in the form

aaronschriever commented 2 years ago

HI guys, Not sure if this is helpful or not. I had a " character in my original password for meross which broke the api call. Once the password was changed not to contain that character it was fine.

squaredcircle commented 2 years ago

Just checked - my password also contains multiple symbols, including a " character.

krahabb commented 2 years ago

HI guys, Not sure if this is helpful or not. I had a " character in my original password for meross which broke the api call. Once the password was changed not to contain that character it was fine.

Hello @aaronschriever , that could explain the issue. I'll check if the password encoding needs some extra care when using these characters

EDIT: the username/password encoding in meross_lan was a bit optimistic about the values and was likely failing to encode in a proper way. Next release should fix this kind of issues with cloud key retrieve

bossloper commented 2 years ago

I had an ! (exclamation mark) in my password. It failed to log in to the cloud unless I changed my password to not have it. v2.6.2

krahabb commented 2 years ago

Hello @bossloper , I'll review the actual implementation to try understand why! Thank you for sharing this

cpighin commented 2 years ago

Hello, I also have an authentication error problem. I just installed Meross LAN 2.6.2 on Home assistant and tried to integrate a SmartPlugEnergyMonitor. The integration process fails as in the picture Schermata del 2022-11-21 16-40-12

Claudio

krahabb commented 2 years ago

Hello @cpighin, I still haven't checked the code for this and I guess the issue lies in some special character not being encoded correctly (like the '!' in the previous post). Can you share, if any of these specials is used inside your password ? or just say 'yes there are a ton of them' :)

cpighin commented 2 years ago

Hallo krahabb,

thanks for replying ... NO, my Meross password consists only of lowercase and uppercase letters and numbers :(

krahabb commented 2 years ago

I'm in the process to update the login flow in order to better report the error codes from the server so to have a better understanding of what went wrong. The reasons for failures might range from incorrect pwd/login to server unavailability or even 'too many requests'... I've actually retested it and the formatting of any character including specials seems to work fine in my tests. Of course I cannot try any possible combination since I risk getting banned from Meross :(

cpighin commented 2 years ago

Well, so I just have to wait for a new version of Meross LAN and try the integration again, counting on the possibility of reporting a more precise error message? From the information you have, do you think there are many or few users who are unsuccessful with the integration in Home Assistant?

krahabb commented 2 years ago

It's hard to say...since I don't have the big picture of how many users are actually using meross_lan. I guess some in the like of 1 every 10 has few issues actively reported

cpighin commented 2 years ago

thanks

andrelung commented 1 year ago

This was my previous password: garlicky-allergen-knowing-jalousie

changing it to something simpler (and shorter) made the integration work.

krahabb commented 1 year ago

Hello @andrelung, Did your 'long' password fail on latest alpha too (2.7.xxx) ?

andrelung commented 1 year ago

Sorry, I've only tested the version which is available in HACS

TheMastro-11 commented 9 months ago

Hi, same problem, more specific error:int([x]) -> integerint(x, base=10) -> integerConvert a number or string to an integer, or return 0 if no argumentsare given. If x is a number, return x.__int__(). For floating pointnumbers, this truncates towards zero.If x is not a number or if base is given, then x must be a string,bytes, or bytearray instance representing an integer literal in thegiven base. The literal can be preceded by '+' or '-' and be surroundedby whitespace. The base defaults to 10. Valid bases are 0 and 2-36.Base 0 means to interpret the base from the string as an integer literal.>>> int('0b100', base=0)4

DrOctogone commented 9 months ago

Hi, same problem, more specific error:int([x]) -> integerint(x, base=10) -> integerConvert a number or string to an integer, or return 0 if no argumentsare given. If x is a number, return x.__int__(). For floating pointnumbers, this truncates towards zero.If x is not a number or if base is given, then x must be a string,bytes, or bytearray instance representing an integer literal in thegiven base. The literal can be preceded by '+' or '-' and be surroundedby whitespace. The base defaults to 10. Valid bases are 0 and 2-36.Base 0 means to interpret the base from the string as an integer literal.>>> int('0b100', base=0)4

Hello, I had the same problem as you. I simply deactivated 2-factor authentication with the application and it worked.

tombout commented 5 months ago

Hi, I have a similar problem. I get the error message: 'Expecting value: line 1 column 3022 (char 3021)' when I try to connect a meross-smart-switch.

krahabb commented 5 months ago

Hello @tombout, Issues about the login process (especially the latest from @DrOctogone and @TheMastro-11) were fixed with Moonlight release back in February. There was a lot going on there with a 'big' api change from Meross and the added multi-factor authentication but then, it was finally revised and tested to work at the time (now, things keep changing so if something worked before it might not be the case anymore but...)

Now, your error is a bit different and likely a different issue. Which version of meross_lan are you using ? Could you also provide more context as to when and where the message appears? I must suppose you're trying to add a new device to HA... To better inspect what's going on I suggest you to enable debug logging for the meross_lan integration so that the HA log has more insights abvout the different phases of the configuration process.

Jkr1978 commented 4 months ago

Hi, I am having the same issue. My HA installation is also quite fresh and I am first getting started. The version of meross lan is v5.2.2 The login to the meross cloud is not working and I get the feedback wrong password although the login is working on the meross app.

krahabb commented 4 months ago

Hello @Jkr1978, Even though 5.2.2 should be 'state of the art' regarding login I suggest you to update to the latest meross_lan (5.3.0) so that we have a solid reference to test with. I've just re-checked it (v5.3.0) and it works fine even with MFA.

marwiak commented 1 month ago

I am also having an issue with version 5.3.1. I dont have MFA enabled, i am not an experienced user, so sorry if i make a stupid mistake, but i could not find anything about this on the internet. ConfigEntry.init() missing 1 required keyword-only argument: 'discovery_keys'

spiralcb commented 1 month ago

Hello, I just install meross_lan on my Home Assistant and I have the same issue. MFA is not set on my Meross account. "ConfigEntry.init() missing 1 required keyword-only argument: 'discovery_keys'"

Hope this will be fixed.

Have a nice day

krahabb commented 1 month ago

This new issue (likely a compatibility problem with 2024.10) is being tracked in #497

leovj commented 1 month ago

Hello, I just install meross_lan on my Home Assistant and I have the same issue. MFA is not set on my Meross account. "ConfigEntry.init() missing 1 required keyword-only argument: 'discovery_keys'"

Hope this will be fixed.

Have a nice day

I have the same problem..

krahabb commented 1 month ago

Pls post in #497...this is an old issue not relevant anymore