Skip to content
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

Get credentials #5

Closed
proatwork opened this issue Mar 2, 2021 · 40 comments
Closed

Get credentials #5

proatwork opened this issue Mar 2, 2021 · 40 comments

Comments

@proatwork
Copy link

proatwork commented Mar 2, 2021

Update:

@shenxn: #5 (comment)

I've added 2FA support to libdyson (https://github.com/shenxn/libdyson). Download or clone the repo, then run python3 get_devices.py to get credentials. You may also need to install some dependencies using pip3 install -r requirements.txt.

Old

Not an actual issue, but wanted to make this available for other people

I've managed to get credentials in two ways:

1. Using libpurecool

Use this fork of libpurecool (fix_auth branch): https://github.com/bfayers/libpurecool/tree/fix_auth
python3 -m pip install https://github.com/bfayers/libpurecool/archive/fix_auth.zip

  1. Create a new file called whatever.py
  2. Paste this in:
    #!/usr/bin/python3
    from libpurecool.dyson import DysonAccount
    
    dyson_account = DysonAccount("email","password","lang")
    logged = dyson_account.login()
    
    if not logged:
        print('Unable to login to Dyson account')
        exit(1)
    devices = dyson_account.devices()
    for device in devices:
        print(device.serial);
        print(device.name);
        print(device.credentials);
        print(" ");
  1. Open your DysonLink app and stare at the welcome screen :)
  2. python3 whatever.py
  3. Cross your fingers 🤞 and hope it works.

⚠️ Don't try to loging in too fast/spam the script or you'll get IP blocked by Dyson
I've also noticed that I'm getting immediately denied login if I'm going through a VPN

2. Using an Android phone

You can probably do this with an iOS device, but I haven't tested (https://stackoverflow.com/a/8512455)

  1. Download the Packet Capture app from Google Playstore (https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture&hl=en&gl=US)
  2. Open Dyson Link and leave it running in the background
  3. Run the Packet Capture app, allow it to create a VPN if you're prompted
  4. Hit the play button with the 1 and choose the Dyson Link app
  5. Switch to the Dyson Link app, it will probably do a quick refresh of the welcome page
  6. Switch back to Packet Capture and stop capturing
  7. Look through the captured packets for something like this:
    Screenshot_20210305-024635
@ripburger
Copy link

Thx! But I am still stuck on getting the credentials. I am running Home Assistant on a PI4, and have no idea how to get them. Any suggestions? :)

@proatwork
Copy link
Author

proatwork commented Mar 3, 2021

@ripburger you need to run that python code snippet (quoted above) after installing the libpurecool library from bfayers (linked above).
https://adamj.eu/tech/2019/03/11/pip-install-from-a-git-repository/

python -m pip install https://github.com/bfayers/libpurecool/archive/fix_auth.zip

@soffes
Copy link

soffes commented Mar 3, 2021

@proatwork I keep getting Unable to login to Dyson account. I can use the email and password I supplied to sign in on the website. I can also curl https://appapi.cp.dyson.com/v1/userregistration/userstatus and see that my account is active with the US country.

Any tips?

@proatwork
Copy link
Author

Hey @soffes
Are you using the libpurecool fork above?
The credentials should be the ones you use for the Dyson mobile app
If I have some free time tomorrow I will write a step by step of how I managed to make it work

@soffes
Copy link

soffes commented Mar 4, 2021

@proatwork I tried this:

$ python3 -m pip install https://github.com/bfayers/libpurecool/archive/fix_auth.zip
$ python3 dyson.py

dyson.py is your script from above. From reading the integration documentation it says US is a known working language. From reading the libpurecool code it actually passes the "language" as a country in the URL so I think US is correct.

I verified that the credentials I used work in the iOS app and can control my fan.

Any help would be awesome. Super appreciate your time on this! :)

@proatwork
Copy link
Author

@soffes

pi@raspberrypi:[~]$ python3.7 -m pip install https://github.com/bfayers/libpurecool/archive/fix_auth.zip

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting https://github.com/bfayers/libpurecool/archive/fix_auth.zip
  Using cached https://github.com/bfayers/libpurecool/archive/fix_auth.zip
Requirement already satisfied: netifaces in /home/pi/.local/lib/python3.7/site-packages (from libpurecool==0.6.4) (0.10.9)
Requirement already satisfied: paho_mqtt in /home/pi/.local/lib/python3.7/site-packages (from libpurecool==0.6.4) (1.5.1)
Requirement already satisfied: pycryptodome in /home/pi/.local/lib/python3.7/site-packages (from libpurecool==0.6.4) (3.10.1)
Requirement already satisfied: requests<3,>=2 in /usr/lib/python3/dist-packages (from libpurecool==0.6.4) (2.21.0)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from libpurecool==0.6.4) (1.12.0)
Building wheels for collected packages: libpurecool
  Running setup.py bdist_wheel for libpurecool ... done
  Stored in directory: /tmp/pip-ephem-wheel-cache-gm2k7gt0/wheels/7f/8a/a5/8fa837fd233e6ab9b9c1fa2d26046d8db278c5279547827ba9
Successfully built libpurecool
Installing collected packages: libpurecool
Successfully installed libpurecool-0.6.4

pi@raspberrypi:[~]$ python3.7 ~/test.py

yZZpyItgEttmmWqzUxY5HzC+y66j4K51u/O****Kpt5n6DrbrDDBtilqbImu7BcUJNPyBBy6ZIxqd+TTZsI3w==

@krazar
Copy link

krazar commented Mar 4, 2021

@soffes

pi@raspberrypi:[~]$ python3.7 -m pip install https://github.com/bfayers/libpurecool/archive/fix_auth.zip

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting https://github.com/bfayers/libpurecool/archive/fix_auth.zip
  Using cached https://github.com/bfayers/libpurecool/archive/fix_auth.zip
Requirement already satisfied: netifaces in /home/pi/.local/lib/python3.7/site-packages (from libpurecool==0.6.4) (0.10.9)
Requirement already satisfied: paho_mqtt in /home/pi/.local/lib/python3.7/site-packages (from libpurecool==0.6.4) (1.5.1)
Requirement already satisfied: pycryptodome in /home/pi/.local/lib/python3.7/site-packages (from libpurecool==0.6.4) (3.10.1)
Requirement already satisfied: requests<3,>=2 in /usr/lib/python3/dist-packages (from libpurecool==0.6.4) (2.21.0)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from libpurecool==0.6.4) (1.12.0)
Building wheels for collected packages: libpurecool
  Running setup.py bdist_wheel for libpurecool ... done
  Stored in directory: /tmp/pip-ephem-wheel-cache-gm2k7gt0/wheels/7f/8a/a5/8fa837fd233e6ab9b9c1fa2d26046d8db278c5279547827ba9
Successfully built libpurecool
Installing collected packages: libpurecool
Successfully installed libpurecool-0.6.4

pi@raspberrypi:[~]$ python3.7 ~/test.py

yZZpyItgEttmmWqzUxY5HzC+y66j4K51u/O****Kpt5n6DrbrDDBtilqbImu7BcUJNPyBBy6ZIxqd+TTZsI3w==

Hello, I have the same problem,

I reproduced what you described ☝️ and I get "Unable to login to Dyson account".

I still can logout and login to the mobile app with those credentials. I also tried with a new account without success.

Are there any other step to take into account ?
Thank you.

@proatwork
Copy link
Author

proatwork commented Mar 4, 2021

@krazar
I created my account through https://www.dyson.com/your-dyson, if that makes any difference 🤷

you might want to make sure that you have the bfayers fork lib installed and not etheralm or CharlesBlonde

@krazar
Copy link

krazar commented Mar 4, 2021

That's really strange.

I can connect with my account on the dyson website (from my region)
And, to be sure, I uninstalled libpurecool and reinstall the version from bfayers from the snippet above.
Nothing changes.

@soffes
Copy link

soffes commented Mar 4, 2021

Same here @krazar. The bfayers fork was working for me until the most recent HA update :/

@eiddor
Copy link

eiddor commented Mar 4, 2021

Not able to get credentials here, either - I finally managed to get get_devices.py to run :-)

I have tried the mobile login/logout process already.

bash-5.0# python get_devices.py                                                 
Please choose your account region                                               
1: Mainland China
2: Rest of the World
Region [1/2]: 2
Region code: US
Email: [email protected]
Password: 
Traceback (most recent call last):
  File "/config/custom_components/libdyson-main/libdyson/cloud/account.py", line 127, in login_email_password
    response = self.request(
  File "/config/custom_components/libdyson-main/libdyson/cloud/account.py", line 109, in request
    raise DysonInvalidAuth
libdyson.exceptions.DysonInvalidAuth

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "get_devices.py", line 23, in <module>
    account.login_email_password(email, password, region)
  File "/config/custom_components/libdyson-main/libdyson/cloud/account.py", line 138, in login_email_password
    raise DysonLoginFailure
libdyson.exceptions.DysonLoginFailure

@kintaroju
Copy link

kintaroju commented Mar 4, 2021

ok, i'm new to this don't shoot me, but when i enter into the bash session inside my home assistant docker session, i've tried to execute the bfayers python code, except i get the following:

bash-5.0# python3 dyson.py
Traceback (most recent call last):
  File "dyson.py", line 12, in <module>
    from .dyson_pure_cool import DysonPureCool
ImportError: attempted relative import with no known parent package

is the path for the package correct:

/usr/local/lib/python3.8/site-packages/libpurecool

I think I am missing something here to get the credential info, any help is appreciated!

@eiddor
Copy link

eiddor commented Mar 4, 2021

@kintaroju I managed to get get_devices.py from https://github.com/shenxn/libdyson/ to run.

Still having a problem logging in, but that's a different problem.

@kintaroju
Copy link

@eiddor i am guessing it's related to the new 2FA issue? lol

@eiddor
Copy link

eiddor commented Mar 4, 2021

@eiddor i am guessing it's related to the new 2FA issue? lol

Yeah, that's what I suspect.

@kintaroju
Copy link

@eiddor totally hear you. I think if the developer can somehow trigger the 2FA email and integrate the 2FA value I think we can be in the clear.

@eiddor
Copy link

eiddor commented Mar 4, 2021

@eiddor totally hear you. I think if the developer can somehow trigger the 2FA email and integrate the 2FA value I think we can be in the clear.

That may work ok for Dyson Local and grabbing the credentials once, but I don't know how well it would scale for the native HA Dyson implementation or @shenxn's Dyson Cloud.

I'm not a dev, so maybe I'm missing something - I think it's more a matter of Dyson catching their API up with their mobile app.

@kintaroju
Copy link

@eiddor , you are right, but let's see what developer can do.

if the developer can figure this out, big thank you in advance!

@monsieurlatte
Copy link

I manually copied the github folder and when I go into the libepurcool folder and run dyson.py I get this.

C:\Python\libpurecool\libpurecool>python dyson.py
Traceback (most recent call last):
File "dyson.py", line 12, in
from .dyson_pure_cool import DysonPureCool
ImportError: attempted relative import with no known parent package

@proatwork
Copy link
Author

@monsieurlatte you're not supposed to run that :)
create a new .py file and paste the snippet from the first comment then run that

@monsieurlatte
Copy link

Thanks, that helps a ton, figured it out, now I just get the same as everyone else with the whole unable to log into dyson account.

@proatwork
Copy link
Author

proatwork commented Mar 5, 2021

I also managed to get the credentials by using my android phone.
https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture&hl=en&gl=US

I used this to monitor the Dyson app for a couple of seconds (by pressing the triangle icon with the 1, and selecting Dyson Link), and lo and behold, the credentials.
The serial and credentials are separated by an X, at least in my case

Screenshot_20210305-024635

@monsieurlatte
Copy link

I also managed to get the credentials by using my android phone.
https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture&hl=en&gl=US

I used this to monitor the Dyson app for a couple of seconds (by pressing the triangle icon with the 1, and selecting Dyson Link), and lo and behold, the credentials.
The serial and credentials are separated by an X, at least in my case

Screenshot_20210305-024635

that's awesome, dont see anything for iOS in my first look through the app store.

@proatwork
Copy link
Author

Haven't tested, but maybe you can make it work with Bluestacks

@proatwork
Copy link
Author

proatwork commented Mar 5, 2021

@monsieurlatte this might help if you've used Wireshark before https://stackoverflow.com/a/8512455

@shenxn
Copy link
Owner

shenxn commented Mar 5, 2021

I'll work on the new 2FA over the weekend. Hopefully that will fix the problem.

@monsieurlatte
Copy link

@monsieurlatte this might help if you've used Wireshark before https://stackoverflow.com/a/8512455
Thanks, I'll look into that!

@monsieurlatte
Copy link

So here's something, I updated the App on my phone, opened the dyson link app on the phone made sure it connected and all that. Then I just added in the HACS Dyson Cloud integration and now it works? Seems like you need the new Dyson app to trigger something to allow it to work.

@soffes
Copy link

soffes commented Mar 6, 2021

Confirmed! Just opening the app and then rerunning the script with no changes fixed it for me! Thanks so much ❤️

@shenxn
Copy link
Owner

shenxn commented Mar 6, 2021

I've added 2FA support to libdyson (https://github.com/shenxn/libdyson). Download or clone the repo, then run python3 get_devices.py to get credentials. You may also need to install some dependencies using pip3 install -r requirements.txt.

@krazar
Copy link

krazar commented Mar 6, 2021

Now, I can get the credentials.
Thank you !

@kintaroju
Copy link

Just tried your libdyson and it works like hot cakes. Do you plan to integrate it with your Dyson local implementation @shenxn to simplify the process?

@shenxn
Copy link
Owner

shenxn commented Mar 7, 2021

@kintaroju Use ha-dyson-cloud (https://github.com/shenxn/ha-dyson-cloud). Set up Dyson Cloud with your account first, then all your devices will be shown as discovered entities.

@shenxn shenxn closed this as completed Mar 7, 2021
@Anto79-ops
Copy link

hey, nice managed to get my dysons fans connected using the packet readrer on my Android phone. Question, for some, I have:

Dyson Purifier Hot+Cool Formaldehyde HP09
Dyson Pure Hot+Cool™ HP04

  1. What is the difference between "Dyson Pure Hot+Cool (new)" and "Dyson Pure Hot+Cool"?
  2. Also, I manged to add the HP09 as a "Dyson Pure Hot+Cool (new)" seems to work...but definitly not seeing the formaldehyde numbers nor the catalyst life for the formaldehyde..I guess a future update?

@ghost
Copy link

ghost commented Feb 15, 2022

managed to get my dysons fans connected using the packet readrer on my Android phone

How did you do this? I have been unable to get credentials using libdyson after months of trying.

I have credentials for Homebridge, but there doesn't seem to be a way to convert them to work in Homeassistant.

@Anto79-ops
Copy link

managed to get my dysons fans connected using the packet readrer on my Android phone

How did you do this? I have been unable to get credentials using libdyson after months of trying.

I have credentials for Homebridge, but there doesn't seem to be a way to convert them to work in Homeassistant.

Scroll up to the instructions from monsierlatte, and that's what I followed. Once I got the username and credentials, sometimes I had to try a couple of times before it actually submitted successfully probably due to Wi-Fi connection to the fan.

@ghost
Copy link

ghost commented Feb 15, 2022

cheers.

I am on iOS so was looking for it's equivalent, but Apple won't let you do it (security).

@Anto79-ops
Copy link

cheers.

I am on iOS so was looking for it's equivalent, but Apple won't let you do it (security).

Probably, You may wish to make friends with Android people LOL

@ghost
Copy link

ghost commented Feb 16, 2022

You may wish to make friends with Android people

Ha, yes! 👍

@erd82
Copy link

erd82 commented Jan 12, 2023

Maybe this post helps you: #178

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

10 participants