Skip to content
12 changes: 12 additions & 0 deletions libpurecool/dyson.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ def login(self):
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
_LOGGER.debug("Disabling insecure request warnings since "
"dyson are using a self signed certificate.")

#Must first check account status
accountstatus = requests.get(f"https://{self._dyson_api_url}/v1/userregistration/userstatus?country={self._country}&email={self._email}", verify=False)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I go to this URL I get cloudflare warning but the SSL certificate is valid. Are they redirecting away from cloudflare or something?

if accountstatus.status_code == requests.codes.ok:
json_status = accountstatus.json()
if json_status['accountStatus'] != "ACTIVE":
#The account is not active
self._logged = False
return self._logged
else:
self._logged = False
return self._logged

request_body = {
"Email": self._email,
Expand Down