seanrees / prometheus-dyson

Prometheus client for DysonLink fans (Pure Hot+Cool)
MIT License
13 stars 9 forks source link

Unable to verify OTP in config_builder in version 0.3.3 #16

Open Scaredycrow opened 2 years ago

Scaredycrow commented 2 years ago

Hi there, as per my comment in a previous issue I can now run the config_builder but it's failing when verifying the OTP.

Steps to repro:

Error: Enter OTP: 221443 Traceback (most recent call last): File "/tmp/Bazel.runfiles_1xfvuosz/runfiles/__main__/config_builder.py", line 181, in <module> main(sys.argv) File "/tmp/Bazel.runfiles_1xfvuosz/runfiles/__main__/config_builder.py", line 170, in main devices = _query_dyson(creds) File "/tmp/Bazel.runfiles_1xfvuosz/runfiles/__main__/config_builder.py", line 73, in _query_dyson verify_fn(otp, creds.password) File "/tmp/Bazel.runfiles_1xfvuosz/runfiles/pip/pypi__libdyson/libdyson/cloud/account.py", line 145, in _verify response = self.request( File "/tmp/Bazel.runfiles_1xfvuosz/runfiles/pip/pypi__libdyson/libdyson/cloud/account.py", line 113, in request raise DysonInvalidAuth libdyson.exceptions.DysonInvalidAuth

seanrees commented 2 years ago

Thanks for the bug report.

This is unfortunately a known issue in libdyson (see https://github.com/shenxn/libdyson/issues/15). My intuition is that the Dyson login flow, which AIUI is an unpublished API, has changed and the existing pathway is unreliable. My hope is that libdyson will reverse engineer whatever changes are needed and we'll come along for the ride at some point in future.

With that said, are you blocked from using prometheus-dyson at all? If so -- I just released 0.3.4 and this includes a new flag for config_builder: --mode=wifi. This will let you generate a config based on the label details on the device. This is also relying on libdyson code, and works for my fan, but not sure how well it works across Dyson's whole range. :/

Example flow:

% config_builder --config=new.ini --mode=wifi
This requires the WiFi credentials from the label on the Dyson
device. This will be used to calculate the secret required
to connect to this device locally. This script does NOT need
to modify WiFi settings in any way.

The product SSID might look like: DYSON-AB0-XX-ABC1234D-123

Enter product SSID            : DYSON-AB0-ZZ-ABC1234D-999
Enter product WiFi password   : abcdefgh
Device name (e.g; Living Room): My Fan

Configuration generated; press return to view.
[Hosts]

[PE9-UK-KJA2271A]
name = My Fan
serial = AB0-ZZ-ABC1234D
localcredentials = random-string==
producttype = 999