Skip to content

Commit

Permalink
Merge pull request #881 from bdraco/fix_login
Browse files Browse the repository at this point in the history
Fix login failures
  • Loading branch information
AlexxIT authored Jul 7, 2022
2 parents abc4999 + 8182a15 commit e77f71f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions custom_components/sonoff/core/ewelink/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,23 @@ async def login(self, username: str, password: str, app=0) -> bool:
return await self.login_token(token, 1)

# https://coolkit-technologies.github.io/eWeLink-API/#/en/DeveloperGuideV2
payload = {
"password": password,
"countryCode": "+86",
}
payload = {}
if "@" in username:
payload["email"] = username
elif username.startswith("+"):
payload["phoneNumber"] = username
else:
payload["phoneNumber"] = "+" + username
payload.update({
"password": password,
"countryCode": "+86",
})

appid, appsecret = APP[app]

json_payload = json.dumps(payload, separators=(',',':')).encode()
hex_dig = hmac.new(
appsecret.encode(), json.dumps(payload).encode(), hashlib.sha256
appsecret.encode(), json_payload, hashlib.sha256
).digest()

headers = {
Expand Down

0 comments on commit e77f71f

Please sign in to comment.