Python plugin: Dyson pure link

Python and python framework

Moderator: leecollings

JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python plugin: Dyson pure link

Post by JanJaap »

Hi,

First of all, I mis the loglines that display the version info, please make sure to use the latest (3.0.0), have domoticz on latest Dev version and your Raspian version updated.

This error indicates that the Dyson machine doesn't allow the MQTT connection (even though it logs at first MQTT connected). This is because the connection is authenticated on application level, after transport has been established. This is normally because either the user name or the password is incorrect.
As you can see in the loglines with 'local device pwd' and 'cloud device pwd', these 2 passwords are not equal, which they are in my case. The local password is taken form the input page of the plugin (hashed), the cloud p[assword is taken from your Dyson account. What you can do/try:
- fill in only local credentials, see the wiki on github for more info or lool at topics A and B on the plugin itself;
- see why the 2 passwords are not equal by editing the cloud account settings
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
FrancescoS
Posts: 12
Joined: Sunday 19 May 2019 21:16
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Dyson pure link

Post by FrancescoS »

Hi,

thank you for your answer.

I am using version 3.0.0 and updated raspbian to the latest version.
I think i have found the issues.
One issue is that I was referring to the wrong devices. Using the Python libcoolpure library i discovered that there are currently two devices linked to my account

[DysonPureHotCoolLink(serial=PT4-EU-KKA0925A,active=False,name=Salotto,version=21.04.03,auto_update=True,new_version_available=False,product_type=455,network_device=None), DysonPureHotCool(serial=A1A-EU-MBA6412A,active=None,name=Dyson,version=ECG2PF.30.06.003.0002,auto_update=True,new_version_available=False,product_type=527,network_device=None)]

The first one is a previsou version of the dyson purifier i gave back and bought the new one (HP04) unfortunately i forgot to unregister.

Now your plugin is not listing this second device, while the original python library is doing correctly.
I think the problem is that the original library is identifying this with v2

if self._logged:
Domoticz.Debug("Fetching devices from Dyson Web Services.")
device_response = requests.get(
"https://{0}/v1/provisioningservice/manifest".format(
DYSON_API_URL), verify=False, auth=self._auth)
device_v2_response = requests.get(
"https://{0}/v2/provisioningservice/manifest".format(
DYSON_API_URL), verify=False, auth=self._auth)
devices = []


while your plugin is not addressing the v2 provisioning service

I can confirm this, as I created a new account and now there is only one device which is shown from the library

>>> print(devices)
[DysonPureHotCool(serial=A1A-EU-MBA6412A,active=None,name=Cucina,version=ECG2PF.30.06.003.0002,auto_update=True,new_version_available=False,product_type=527,network_device=None)]

but not from this plugin

2020-10-25 11:15:27.096 (Dyson) Fetching devices from Dyson Web Services.
2020-10-25 11:15:27.247 (Dyson) Reply from Dyson: []'
2020-10-25 11:15:27.247 (Dyson) No devices found in Dyson cloud account
2020-10-25 11:15:27.247 (Dyson) Heartbeat interval set to: 10.

so my conclusion is the plugin is currently not able to manage devices newer that 2018, correct me if i am wrong.
Libcoolink is quite old now, the new version libpurecool is more complete and can handle also more recent devices

https://libpurecool.readthedocs.io/en/latest/

Thank you

Francesco
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python plugin: Dyson pure link

Post by JanJaap »

Hi Fransesco,

That is a very sharp observation, I completely missed the changed URL. I updated the plugin, when you pull the latest version I hope it works now. This would, hopefully, solve the issues as many others have reported as well (not finding devices in dyson cloud). The v2 provisioning also works correct with my older device.

It would have been interesting to see if it would works also with 2 devices in the account. Hope you can still reproduce that?
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
FrancescoS
Posts: 12
Joined: Sunday 19 May 2019 21:16
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Dyson pure link

Post by FrancescoS »

Hi,

just added back the device to the old account. Now it is the only one being listed, the old one is missing. Moreover the controls are not fully working, sensor data are not being populated etc.

In my opininion this is because the two types of devices must cohexist in the library / cool pure and cool pure link are slightly different devices

The new version of libpurecool is > https://github.com/etheralm/libpurecool

if you look at dyson.py you will see both are there and added to the list.

I think that only adding the new provisioning method is not sufficient to make the plugin work for new devices.
In the past i coded a plugin myself for my device based on your code to support mine HP04. I did this because the commands were slightly different than the one in v1 and i noticed the new provisioning v2 . Recently my plugin stopped working as well, probably due to the apps server changes.

I come back to your which i see has a lot of interesting widgets, but the new command set will require several coding to make it work probably.

Thanks

Francesco
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python plugin: Dyson pure link

Post by JanJaap »

Hi,

The fact that the newer Dyson machines have different states and thus commands is in it self nothing to worry about. I added some stuff for the older model with heating as well, that worked OK. So could you please create an issue in my git (or use this one: issue 20) and paste the telegrams received from your Dyson machine, preferably with some explanation of which data represents what (they use 4 character keys, they are not always that clear). So I'd be happy to add them to this plugin. In fact I'm on a different branch trying to make the plugin such that it will only make the widgets that are relevant for the machine type, based on the status telegrams. But that is still in development. So I can add your machine first in the 'old' way.

And with all the Covid business, one needs a hobby to spend some time on, right?

Regards, Jan-Jaap
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Python plugin: Dyson pure link

Post by jannl »

Hi,

I just looked at my Dyson Tower Ventilatortoday again (updated the plugin mostly), and most things seem to work now.

However, I just don't seem to be able to switch off the fan with Domoticz, which switch should do that?

Any clues?

Jan
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python plugin: Dyson pure link

Post by JanJaap »

Hi,

The main control widget for the fan is the one called 'Fan speed' (which may be a bit misleading), it allows to switch off, select a speed or go to auto mode:

Alternatively you can use the widget 'Fan Mode' which allows switching on/off/auto.

Hope this helps
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Python plugin: Dyson pure link

Post by jannl »

Hi,

hm, doesn't seem to work. I can set the fan speed, but switching off does not work. I tried them both.
Other switches do work, like oscillation/night mode...

Jan
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python plugin: Dyson pure link

Post by JanJaap »

Hi,

Please make a detailed bug report on GitHub and be sure to add the needed loglines + the actions you took.
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Python plugin: Dyson pure link

Post by jannl »

Created an issue, if you need more info, please let me know.

The issue regarding the focus does not occur here, I can switch the focus from within Domoticz.
Using the stable version 2020.2

Some strange things, fan speed only changes speed. Back to auto can only be done with another switch.

In the domoticz app most switches must be operated twice to get a result.
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python plugin: Dyson pure link

Post by JanJaap »

Since early 2021 Dyson updated their cloud account provider to demand 2-factor authentication. The plugin has been updated to retrieve all needed info's from the cloud and store them in the domoticz DB (using the new Configurations).
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
K0enH
Posts: 32
Joined: Monday 20 March 2017 14:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Dyson pure link

Post by K0enH »

hi there, hopefully somebody in this topic can assists.
my plugin was running fine in the past, however I do not use it all year as the dyson is mainly used in the summer.
now I wanted to start using the plugin again and I keep getting errors
2022-06-16 14:00:48.466 Error: Dyson-Fan: (DysonPureLink) failed to load 'plugin.py', Python Path used was '/home/k0enh/domoticz/plugins/DysonPureLink/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages
2022-06-16 14:00:48.466 Error: Dyson-Fan: Module Import failed, exception: 'ModuleNotFoundError'
2022-06-16 14:00:48.466 Error: Dyson-Fan: Module Import failed: ' Name: Crypto'
2022-06-16 14:00:48.466 Error: Dyson-Fan: Error Line details not available.
2022-06-16 14:00:48.466 Error: Dyson-Fan: Exception traceback:
2022-06-16 14:00:48.466 Error: Dyson-Fan: ----> Line 77 in '/home/k0enh/domoticz/plugins/DysonPureLink/plugin.py', function <module>
2022-06-16 14:00:48.466 Error: Dyson-Fan: ----> Line 3 in '/home/k0enh/domoticz/plugins/DysonPureLink/dyson_pure_link_device.py', function <module>
2022-06-16 14:00:48.466 Error: Dyson-Fan: ----> Line 4 in '/home/k0enh/domoticz/plugins/DysonPureLink/commands.py', function <module>
2022-06-16 14:00:48.466 Error: Dyson-Fan: ----> Line 3 in '/home/k0enh/domoticz/plugins/DysonPureLink/cloud/__init__.py', function <module>
2022-06-16 14:00:48.466 Error: Dyson-Fan: ----> Line 18 in '/home/k0enh/domoticz/plugins/DysonPureLink/cloud/account.py', function <module>
2022-06-16 14:00:48.466 Error: Dyson-Fan: ----> Line 3 in '/home/k0enh/domoticz/plugins/DysonPureLink/cloud/device_info.py', function <module>
2022-06-16 14:00:48.466 Error: Dyson-Fan: ----> Line 9 in '/home/k0enh/domoticz/plugins/DysonPureLink/cloud/utils.py', function <module>
I have tried several things about reinstalling the Crypto package with pip3 and also routes like the one explained here: https://github.com/volatilityfoundation ... issues/771

however I get lost and have no other clues what is going wrong..
so maybe somebody here can guide me?

Regards,

K0enH
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python plugin: Dyson pure link

Post by JanJaap »

I had to re-install my RPi after a crash and ran into the same issue. I made some changes and pushed it recently, which worked for me. Did you use latest version? Should be 4.0.4, please check your plugin version. If it does not work still, then please let me know.

Btw the linked issue was found on Python 2, we're using python 3 here nowadays, not sure if the same tricks work.
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
K0enH
Posts: 32
Joined: Monday 20 March 2017 14:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Dyson pure link

Post by K0enH »

JanJaap wrote: Saturday 25 June 2022 14:14 I had to re-install my RPi after a crash and ran into the same issue. I made some changes and pushed it recently, which worked for me. Did you use latest version? Should be 4.0.4, please check your plugin version. If it does not work still, then please let me know.

Btw the linked issue was found on Python 2, we're using python 3 here nowadays, not sure if the same tricks work.
Yes have latest version:
k0enh@HomeControl:~/domoticz/plugins/DysonPureLink$ sudo git pull
Already up to date.
I understand that the link I mentioned is for python2 however Instead of using python in the commands I used python3.
but even that gives still the same issue..
so if you have any other tips for this..


PS. I am not running an RPI but am running domoticz on an Intel NUC with Ubuntu 22.04
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python plugin: Dyson pure link

Post by JanJaap »

Well the below is the list of Python packages I've got installed (retreived via dpkg -l)

Code: Select all

ii  python-apt-common                    2.2.1                            all          Python interface to libapt-pkg (locales)
ii  python-is-python3                    3.9.2-1                          all          symlinks /usr/bin/python to python3
ii  python-pip-whl                       20.3.4-4+rpt1                    all          Python package installer (pip wheels)
ii  python3                              3.9.2-3                          armhf        interactive high-level object-oriented language (default python3 version)
ii  python3-apt                          2.2.1                            armhf        Python 3 interface to libapt-pkg
ii  python3-certifi                      2020.6.20-1                      all          root certificates for validating SSL certs and verifying TLS hosts (python3)
ii  python3-chardet                      4.0.0-1                          all          universal character encoding detector for Python3
ii  python3-colorzero                    1.1                              all          Construct, convert, and manipulate colors in a Pythonic manner.
ii  python3-crypto                       2.6.1-13.1+b1                    armhf        cryptographic algorithms and protocols for Python 3
ii  python3-debconf                      1.5.77                           all          interact with debconf from Python 3
ii  python3-dev                          3.9.2-3                          armhf        header files and a static library for Python (default)
ii  python3-distro                       1.5.0-1                          all          Linux OS platform information API
ii  python3-distutils                    3.9.2-1                          all          distutils package for Python 3.x
ii  python3-gpiozero                     1.6.2-1                          all          Simple API for controlling devices attached to a Pi's GPIO pins.
ii  python3-idna                         2.10-1                           all          Python IDNA2008 (RFC 5891) handling (Python 3)
ii  python3-lib2to3                      3.9.2-1                          all          Interactive high-level object-oriented language (lib2to3)
ii  python3-minimal                      3.9.2-3                          armhf        minimal subset of the Python language (default python3 version)
ii  python3-pip                          20.3.4-4+rpt1                    all          Python package installer
ii  python3-pkg-resources                52.0.0-4                         all          Package Discovery and Resource Access using pkg_resources
ii  python3-requests                     2.25.1+dfsg-2                    all          elegant and simple HTTP library for Python3, built for human beings
ii  python3-rpi.gpio                     0.7.0-0.2+b1                     armhf        Module to control Raspberry Pi GPIO channels (Python 3)
ii  python3-setuptools                   52.0.0-4                         all          Python3 Distutils Enhancements
ii  python3-six                          1.16.0-2                         all          Python 2 and 3 compatibility library (Python 3 interface)
ii  python3-spidev                       20200602~200721-1                armhf        Bindings for Linux SPI access through spidev (Python 3)
ii  python3-urllib3                      1.26.5-1~exp1                    all          HTTP library with thread-safe connection pooling for Python3
ii  python3-wheel                        0.34.2-1                         all          built-package format for Python
ii  python3.9                            3.9.2-1+rpi1                     armhf        Interactive high-level object-oriented language (version 3.9)
ii  python3.9-dev                        3.9.2-1+rpi1                     armhf        Header files and a static library for Python (v3.9)
ii  python3.9-minimal                    3.9.2-1+rpi1                     armhf        Minimal subset of the Python language (version 3.9)
and further what I've got in pip3 (using pip3 list):

Code: Select all

Package       Version
------------- ---------
certifi       2020.6.20
chardet       4.0.0
colorzero     1.1
ConsoleMenu   1.0.1
crypto        1.4.1
distro        1.5.0
gpiozero      1.6.2
gyp           0.1
idna          2.10
Naked         0.1.31
pip           20.3.4
pycrypto      2.6.1
python-apt    2.2.1
PyYAML        6.0
requests      2.25.1
RPi.GPIO      0.7.0
setuptools    52.0.0
shellescape   3.8.1
six           1.16.0
spidev        3.5
ssh-import-id 5.10
urllib3       1.26.5
wheel         0.34.2
Please check your list and install whatever seems relevant that is missing.....
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
K0enH
Posts: 32
Joined: Monday 20 March 2017 14:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Dyson pure link

Post by K0enH »

I validated and everything seems to be fine with the installed packages.
even when I run the import command via the shell it doesnt give an error on the import of the Crypto modules:
k0enh@HomeControl:~/domoticz/plugins/DysonPureLink$ python3
Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from Crypto.Cipher import AES2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'AES2' from 'Crypto.Cipher' (/usr/local/lib/python3.10/dist-packages/Crypto/Cipher/__init__.py)
>>> from Crypto.Cipher import AES
>>> import Crypto
>>>
to show that it is working I made an obvious mistake by using AES2 instead of AES which then gives an error.
but on the normal import it is working fine..
so I'm still confused why this then doesnt work from Domoticz...
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Dyson pure link

Post by waltervl »

Normally when import modules gives issue install them with elevated rights like
sudo pip3 install Crypto
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
K0enH
Posts: 32
Joined: Monday 20 March 2017 14:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Dyson pure link

Post by K0enH »

solved issue (by almost killing my Ubuntu install..)
the issue was that I was having multiple python versions installed (3.7 and 3.10) where domoticz was using another version (3.7) than the system (3.10)
therefore Crypto was not installed under 3.7 but under 3.10

finally got this solved however it was almost the end of my ubuntu install as I tried to remove python3.10 which led to changed network interfaces etc. so I had no network config etc and had to fix that as well..
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest