Closed jlockham closed 2 years ago
Seems Dyson changes it's login process again. I'll try to fix it later. I would recommend set up Dyson local using device WiFi SSID if your device support that.
Same issue on my end. My TP04 did not come with WiFi SSID "support" but getting the identity using libdyson does work as a workaround for people with some experience.
Removed comment, my login failed because I forgot I was connected to a corporate VPN, so login probably failed because I was in a different region.
libdyson does work as a workaround for people with some experience
@pbrunier can you detail what you mean by this? Running get_devices.py
doesn't work. I modified the script to not use the Dyson Cert as they are not using that anymore and have a valid cert. Have tried logout/login on dysonlink app just before running get_devices.py
. Have tried the various user-agent's noted in other repos issues. All do not work currently and return a 401.
If you could supply a bit more detail on what you did, happy to do own legwork.
I was trying to set up my TP04 and faced the same error as OP described. but then I opened my Dyson app from mobile after that I could go through and asked for the password and code (sent by email) and then a successful login :). Perhaps you can try this way.
procedure:
🙏 @arifroni that worked a treat, now connected, many thanks. Hope you don't mind me fleshing out the steps, I locked my account getting it wrong order first few times:
I was trying to set up my TP04 and faced the same error as OP described. but then I opened my Dyson app from mobile after that I could go through and asked for the password and code (sent by email) and then a successful login :). Perhaps you can try this way.
procedure:
- add dyson cloud integration wait until it ask for email.
- open dyson app (maybe go to the machine settings, that's what I did)
- then enter region and email ID in HA and hit submit
This method worked for me too but when i then try and add my local device, i get Failed to connect.
Any tricks to get past this? I have a TP07 device.
I am having the same issue with failing to connect.
What device do you have?
TP04
I am also unable to add Dyson Cloud integration. It asks for the e-mail address and comes back with 'Failed to connect'. I tried the trick of waiting on the e-mail screen and opening the Dyson Link app ... but that didn't improve things for me. The e-mail address is correct as I've logged into the Link app with it. I thought this might be to do with the new version of HA (core-2021.8.3) which I upgraded to and then lost access to my Dyson TP04.
same issue after upgrading to HA 2021.8.x. I have downgraded to HA 2021.7 to get Dyson working again. After reading through all the comments above, I tried the libdyson method (after upgrading to 2021.8.3 again) and was able to reconnect to Dyson 527E again locally. Thanks for the libdyson @shenxn
Hey @appler1d3r thanks for letting me know it wasn't just me. I've downgraded (and restored to a snapshot) to get the Dyson working again. Is there information that we can extract in the working state that can be used after the upgrade? Or do I need to learn how to use the libdyson method.
If it looks like the only way is via libdyson, can someone give me some basic advice:
Thanks
@fhopley My first thought was exactly what you asked - why core update should break this? I tried turning on the logging for dyson local. But that didnt show anything other than unable to connect. My suspicion is that the core update has bumped some of the underlying python libs that breaking the link to Dyson equipment and re-connection is not successful through integration itself. When you restore the snapshot, it doesnt have to reconnect as the link to the local device is intact. I didnt spend much time on debugging. I also had a Dyson plugin that I integrated in Homebridge as a workaround if I'd to upgrade to 2021.8.x at any point. Anyways, here's what I did to get credentials. Followed exact steps by shenxn.
Assuming you have a dyson account and the devices are added under that, try following. 1) you can download the repo (https://github.com/shenxn/libdyson ) to your Mac ( that's exactly what I did) 2) Ran pip3 install -r requirements.txt from terminal on Mac after setting your present working directory to libdyson folder 3) run python3 get_devices.py It will ask for few questions such as region, email and password 4) Once you enter the password, check your dyson account email for the login 2fa code 5) enter the 2fa code at the terminal prompt.
This is what I got as the output (I have scrubbed some of the data with XXXX)
Serial: J7Z-AU-PCA0XXXX Name: Master bedroom Device Type: 527E Credential: XXXXQVv1PIzdvqRXpVvvXXXXryXqcSgIHEUpXXXe/XXXX4HDJ4GPtwXDiycFmUNNxH8TbXXXXTvEMFa1YA==
I only have one device.
Now next step is to add the device using Dyson Local integration in HA using the above information. Please note I was not successful at first attempt. I had to restart HA couple of times get it working. Twice it said failed to connect. I provided the IP of my dyson device as well rather than forcing discovery. Also, closed and opened Dyson Link app on my phone and made sure it is connected to the device. One thing I noticed that my entity names have now changed because earlier I used Dyson Cloud to set up my devices. So I'd to change that in automation and lovelace references On a side note, as I mentioned, I do have a Homebridge plugin as well. It uses a credential generator and which is more or less same API and logic. But the credential received for Dyson local through above steps is different as that plugin is not a device specific installation but rather it shows all the devices from the account. So more like Dyson Cloud integration( I could be wrong and happy to be stand corrected). I have not had a chance to go through each code and debug yet. But now things are working for me, I will leave this integration as i now until something causes havoc again.
Thx for the step-by-step guide. After installing, when I run get_devices.py (step 3), I get the following error message:
File "get_devices.py", line 15 verify = account.login_mobile_otp(f"+86{mobile}") ^ SyntaxError: invalid syntax
Any clue what I'm doing wrong here?
Not sure. Have you verified that you have entered the mobile number in correct format with out the country code? I didnt use option 1 (mainland China). I used option 2 as I am not from Mainland China and therefore wouldnt work for me anyways. So verification was based on email address and not phone number. So for sake of testing, I tried with option 1 and step3 successfully got executed. Since I gave a random phone number (I gave it without +86), I cannot proceed further as expected. But I didnt get any invalid syntax errors in step 3.
So either the number format you entered is wrong or there are some dep libraries missing from step 1 or step 2
@fhopley My first thought was exactly what you asked - why core update should break this? I tried turning on the logging for dyson local. But that didnt show anything other than unable to connect. My suspicion is that the core update has bumped some of the underlying python libs that breaking the link to Dyson equipment and re-connection is not successful through integration itself. When you restore the snapshot, it doesnt have to reconnect as the link to the local device is intact. I didnt spend much time on debugging. I also had a Dyson plugin that I integrated in Homebridge as a workaround if I'd to upgrade to 2021.8.x at any point. Anyways, here's what I did to get credentials. Followed exact steps by shenxn.
Assuming you have a dyson account and the devices are added under that, try following.
- you can download the repo (https://github.com/shenxn/libdyson ) to your Mac ( that's exactly what I did)
- Ran pip3 install -r requirements.txt from terminal on Mac after setting your present working directory to libdyson folder
- run python3 get_devices.py It will ask for few questions such as region, email and password
- Once you enter the password, check your dyson account email for the login 2fa code
- enter the 2fa code at the terminal prompt.
This is what I got as the output (I have scrubbed some of the data with XXXX)
Serial: J7Z-AU-PCA0XXXX Name: Master bedroom Device Type: 527E Credential: XXXXQVv1PIzdvqRXpVvvXXXXryXqcSgIHEUpXXXe/XXXX4HDJ4GPtwXDiycFmUNNxH8TbXXXXTvEMFa1YA==
I only have one device.
Now next step is to add the device using Dyson Local integration in HA using the above information. Please note I was not successful at first attempt. I had to restart HA couple of times get it working. Twice it said failed to connect. I provided the IP of my dyson device as well rather than forcing discovery. Also, closed and opened Dyson Link app on my phone and made sure it is connected to the device. One thing I noticed that my entity names have now changed because earlier I used Dyson Cloud to set up my devices. So I'd to change that in automation and lovelace references On a side note, as I mentioned, I do have a Homebridge plugin as well. It uses a credential generator and which is more or less same API and logic. But the credential received for Dyson local through above steps is different as that plugin is not a device specific installation but rather it shows all the devices from the account. So more like Dyson Cloud integration( I could be wrong and happy to be stand corrected). I have not had a chance to go through each code and debug yet. But now things are working for me, I will leave this integration as i now until something causes havoc again.
Thanks for the Detailed Instructions. I have been following them to try and add my device TP07. I still get a failed to connect error, but i also noticed that Home assistant seems to crash for a moment and i see this in the log:
[36m2021-08-09 09:46:46 DEBUG (MainThread) [custom_components.dyson_local.config_flow] Failed to connect to device: [0m
[31m2021-08-09 09:46:46 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 673, in ping
await self._send_frame(message, WSMsgType.PING)
File "/usr/local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 650, in _send_frame
self._write(header + message)
File "/usr/local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 660, in _write
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport[0m
[31m2021-08-09 09:46:46 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 673, in ping
await self._send_frame(message, WSMsgType.PING)
File "/usr/local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 650, in _send_frame
self._write(header + message)
File "/usr/local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 660, in _write
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport[0m
sorry @fhopley dont think I can help here much. Looks like the device is timing out. For me, it took couple of attempts and restart of HA. Also, I kept the app open and running on the phone to make sure that the Dyson device is active and able to connect. It is a silly thing - but can you try restarting you router? Worth a shot. The error did say something positive - the connect did happen but the device immediately terminated it. Either Dyson didnt like multiple connections or may be there was a typo in the credential.
@appler1d3r - thanks for your reply. Unfortunately, I'm not getting to any verification. Immediately, after entering the "python3 get_devices.py" line, I get the SytnaxError.
@MarcusKapun I suspect that you might be missing some files or python libraries on your system or it could be that .py file somehow got modified. May be you can re clone or download the whole repo again to different machine or location. Also make sure that pip3 install -r requirements.txt does run successfully.
Is this a Mac or Windows or some other Linux machine?
This is the python I'm having on my Mac and the .py scripts are getting validated without any issues.
Python 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)] on darwin
For some reason the runtime compilation is failing.
I did try different changes to my get_deviced.py file to replicate the issue, but couldnt replicate the exact Invalid Syntax error.
thanks @appler1d3r for the detailed instructions. I tried to follow but have hit a snag. The code is downloaded, the requirements installed (although I had to add a '-- user' to the pip3 command to get that to work), but now I'm stuck at running 'get_devices.py'.
When trying to run get_devices.py - I can successfully enter that I'm in the 'rest of the world', provide my region 'AU', and my e-mail address. However it then dies with what looks like an SSL error. I've pasted what appears to be the key line of log below:
File "/Users/fhopley/Library/Python/3.7/lib/python/site-packages/urllib3/util/ssl_.py", line 402, in ssl_wrap_socket context.load_verify_locations(ca_certs, ca_cert_dir, ca_cert_data) ssl.SSLError: [X509] PEM lib (_ssl.c:4053)
File "/Users/fhopley/Library/Python/3.7/lib/python/site-packages/urllib3/util/ssl_.py", line 404, in ssl_wrap_socket raise SSLError(e) urllib3.exceptions.SSLError: [X509] PEM lib (_ssl.c:4053)
Any advice much appreciated - I'm getting a bit worried as I might be stuck on an old version of HA indefinitely! Or maybe at least until @shenxn gets the new login api sorted.
I too have faced this issue @fhopley Try the dev Branch of the Library. After after selecting rest of the world. Type AU as your country, but before pressing enter, open the Dyson app on your phone, click setting s and then machine settings, then try to progress the rest of the python script
hi @wranglatang thanks! The link you gave was for Dyson Local, rather than dev for libdyson - but I found it thanks to your advice and it worked to get the credentials. Looks like I might be ok to try the upgrade again!
Thanks to @appler1d3r details instructions I was able to add my TP-07 Fan to HA 2021.8.6 on Linux using the Dyson Local repository. (The Dyson Cloud would not connect).
My observations...
get_devices.py
hey guys, having this same issue. Dyson integration stopped working (previously setup via Dyson Cloud. I removed the integration and re-added it. Immediately after entering the email address I have associated with my Dyson Account it said "Failed to Connect".
I followed the above instructions from @appler1d3r. Downloaded libdyson-dev, ran 'pip3 install -r requirements.txt' all good, then ran python3 get_devices.py and now I get the below.
PS C:\Users\Darklyte\Desktop\libdyson-dev> python3 get_devices.py Traceback (most recent call last): File "C:\Users\Darklyte\Desktop\libdyson-dev\get_devices.py", line 3, in <module> from libdyson.cloud import DysonAccount File "C:\Users\Darklyte\Desktop\libdyson-dev\libdyson\__init__.py", line 27, in <module> from .discovery import DysonDiscovery # noqa: F401 File "C:\Users\Darklyte\Desktop\libdyson-dev\libdyson\discovery.py", line 7, in <module> from zeroconf import ServiceBrowser, ServiceInfo, Zeroconf ModuleNotFoundError: No module named 'zeroconf'
*not sure why it's not formatting correctly
You can try few things. Requirements.txt should have already installed zeroconf.
Try pip3 install zeroconf
or py -m pip install zeroconf
to force latest python zeroconf.
Thank you @appler1d3r. I ran those and it updated zeroconf then after running "python3 get_devices.py" it then said "No module named phao". I ran those commands to force phao_mqtt and it also updated.
Next I ran "python3 get_devices.py" again and now I get;
PS C:\Users\Darklyte\Desktop\libdyson-dev> python3 get_devices.py Traceback (most recent call last): File "C:\Users\Darklyte\Desktop\libdyson-dev\get_devices.py", line 3, in <module> from libdyson.cloud import DysonAccount File "C:\Users\Darklyte\Desktop\libdyson-dev\libdyson\cloud\__init__.py", line 3, in <module> from .account import DysonAccount, DysonAccountCN # noqa: F401 File "C:\Users\Darklyte\Desktop\libdyson-dev\libdyson\cloud\account.py", line 6, in <module> import requests ModuleNotFoundError: No module named 'requests' PS C:\Users\Darklyte\Desktop\libdyson-dev>
I am not a Python expert, but it looks like you are missing the Python requests Module in your current Python installation.
Try this. Hope this could fix that error up.
python -m pip install requests
If any modules are missing down the lane, pypi.org would have commands to get those modules.
Thank you guys very much for your help! It took a bit to fix up those module's but after a couple hours I was able to get output from get_devices.py and setup locally!
I'm also trying to find the credentials for my Pure Hot + Cool Fan
After running:
python3 get_devices.py Please choose your account region 1: Mainland China 2: Rest of the World Region [1/2]: 2 Region code: GB Email: xxx
I get this:
Traceback (most recent call last): File "get_devices.py", line 22, in <module> verify = account.login_email_otp(email, region) File "/Users/Fred/Documents/libdyson-main/libdyson/cloud/account.py", line 132, in login_email_otp auth=False, File "/Users/Fred/Documents/libdyson-main/libdyson/cloud/account.py", line 119, in request raise DysonInvalidAuth libdyson.exceptions.DysonInvalidAuth
Any ideas what's happening?
is that the end of the output? if so, it took me running "get_devices.py" like 4-5 times before it spit it all out. Everytime I did it, it got a little bit further. Just my experience.
Just tried a few more times and got it to work! Can't seem to connect to fan now though using the credential. I have pasted in the serial, credential, matching device type and the host IP (tried without IP first) and it's failing to connect.
Same for me.
Doh! Turns out I picked the wrong model. I had picked 527E rather than 527. All working now!
Hey, so I also can't login both in Dyson Cloud in HA and in the Python script, I come as far as putting in my Email and then I get an error code. Is there any fix for it? (I tired logging out and an back, in the app while doing the process)
Getting the same error every time I get up to the email part of the script:
Traceback (most recent call last):
File "get_devices.py", line 22, in <module>
verify = account.login_email_otp(email, region)
File "H:\Downloads\libdyson-main\libdyson-main\libdyson\cloud\account.py", line 127, in login_email_otp
response = self.request(
File "H:\Downloads\libdyson-main\libdyson-main\libdyson\cloud\account.py", line 119, in request
raise DysonInvalidAuth
libdyson.exceptions.DysonInvalidAuth
Tried it multiple times (Option 2 - RoW, Region Code: AU) without any success. Once I type in my email, I get the above error.
Edit: Aftter turning My TP04 off and on again, running the script seems to let me progress past the Email stage.
I got libdyson.exceptions.DysonInvalidAuth
as all you guys did.
But after I logout and login again in the Dyson app, I re-run script python3 get_devices.py
. I get this error libdyson.exceptions.DysonOTPTooFrequently
.
I try again after few minutes. It works. There might be some magics in the app.
Thanks it works fine.
I was getting libdyson.exceptions.DysonInvalidAuth
After disconnecting from the mobile app, it works fine.
When doing the HA config menu be sure to select the correct model otherwise it won't work.
Anyhow would be nice to get the yaml configuration possibility as well.
Also be sure to use python3 otherwise you will get the following error:
# python get_devices.py
File "get_devices.py", line 15
verify = account.login_mobile_otp(f"+86{mobile}")
See #66
[In Australia] I did a traffic capture on the connectivity between my iPhone and dyson. There are what appears to be two connections, one to the dyson api address in the US and another that goes to EU-West amazon (could be a red herring).
I used US as my country and this work without issue. After submitting it takes a couple of seconds to return with a screen requesting password and validation code. The validation code will turn up in your email. Put in both values and the system works without issue (so far).
A couple of extra prompts on the screen would be helpful, such as "verification code emailed from Dyson for login"... or similar. This step left me scratching my head for a couple of seconds and the email ended up in the spam folder. Aside from that the process was pretty simple.
I have a Purifier Hot and Cold and Purifier Cool, both cloud connected.
I'm new to HA and trying to get it to use your plugin for my dyson devices. I ahve added both repo's to the HACS, and trying to install teh dyson-cloud integration. Get through teh Country - GB, and then it asks for my email - type in my email, and click submit, and all i get then is an error:- Unknown error occurred
stack trace from error in log is as follows;-
This error originated from a custom integration.
Logger: aiohttp.server Source: custom_components/dyson_cloud/config_flow.py:71 Integration: dyson_cloud (documentation, issues) First occurred: 15:39:07 (1 occurrences) Last logged: 15:39:07
Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request resp = await self._request_handler(request) File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle resp = await handler(request) File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 76, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 155, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 63, in wrapper result = await method(view, request, *args, *kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 202, in async_configure result = await self._async_handle_step(flow, cur_step["step_id"], user_input) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 260, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/dyson_cloud/config_flow.py", line 71, in async_step_email self._verify = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(self.args, **self.kwargs) File "/usr/local/lib/python3.8/site-packages/libdyson/cloud/account.py", line 127, in login_email_otp response = self.request( File "/usr/local/lib/python3.8/site-packages/libdyson/cloud/account.py", line 119, in request raise DysonInvalidAuth libdyson.exceptions.DysonInvalidAuth