Integrate Dyson Pure Cool Link

Preface

The integration of the Dyson air purifier was my first attempt to integrate a device into openHAB. Therefore this post can change time to time and for sure there are better ways on implementing some of the stuff. If you have feedback or questions on something, just post it.
At the first version of this post, I included all file content in here. In the meantime I decided to outsource it to github into a repository with all needed files included.
The repository can be found here -> https://github.com/mecks52/openhab2-dyson475

Problem Statement

You are the happy owner of a Dyson Pure Cool Link air purifier and you want to integrate it into openHAB.

Used Versions

  • OS: Ubuntu 16.04 LTS
  • openHAB: 2.4.0 Release Build
  • Dyson SW-Ver.: 21.03.08
  • Python 3.5

Overview

The solution uses binding-mqtt and transformation-jsonpath to communicate with the air purifier and parsing the received messages.
Openhab subscribes on the Dyson, which acts as mqtt-broker. On changes of the state, the air purifier sends messages to the subscribers and a rule parses the information to the Items. The current sensor values are only send on demand. Therefore a rule requests them each 30 seconds. Another rule parses the answer. Together with the sensor data, the current state is also sent and parsed. If an Item is commanded, a message is created and sent to the air purifier and triggers a state change message on the Dyson.
The goal was to implement the functionality of the Android App. The details about which functionality is implemented are stated in the README file within the repository.

Preconditions

I assume, your air purifier is already connected to your network and binding-mqtt and transformation-jsonpath are installed on openhab. Also python 3 is installed on the PC.
You will need the “Product SSID” and “Product WiFi Password” from the sticker beyond the filter of the Dyson. Additionally the ip address of the air purifier is needed.

Step 1: Prepare files

Download the files from the repository and start the script “prepare.py”. It will ask you for the needed data and modifies the files to match your device.

Step 2: Copy files to openhab

Now copy “dyson475.items” to “openhab2/items”, “dyson475.rules” to “openhab2/rules”, both “dyson475-**.sitemap” to “openhab2/sitemaps” and “dysonapbroker.things” to “openhab2/things”.

Usage

You can use the air purifier now out of the box from one of the given sitemaps. Alternatively you can use the Items in your own sitemaps and rules.

7 Likes

That sounds awesome! Just did a quick test and the prepare.py doesn’t work for me:

...
Type in the IP-Adress of the air purifier (e.g. 192.168.178.100):192.168.1.145
Traceback (most recent call last):
  File "prepare.py", line 34, in <module>
    dyson475_items_str.replace("<dev-id>", dev-id)
NameError: name 'dev' is not defined

Anyway, was able to use your solution by using getPwdHash.py to generate the password hash and manually editing the files. Also, in my case it’s a Hot+Cool link so the model code is 455 instead of 475. Simply had to replace the mqtt topics in the item file. A few values (remaining filter hours, v-value, p-value) are empty so far but only just got it working. Thanks for your work!

Thank a lot for the feedback.
Shame on me, I haven’t tested the prepare.py and introduced a typo. I corrected it and will test it back home if it works.

If you want, we could try to add the features of the Hot + Cool Link. A first step would be to have a look on the messages, the 455 is sending. You could help me (because I got no 455 at hand) by posting the content of the two Items wich are introduced by adding

...
//DEBUG
String Dyson_Debug_SensorValues "[%s]"
String Dyson_Debug_CurrentState "[%s]"

to the dyson475.items.
They will be filled by adding

...

    if (msg == "ENVIRONMENTAL-CURRENT-SENSOR-DATA") {
        postUpdate(Dyson_Debug_SensorValues, content) //Add this line
        val String tact_str = transform("JSONPATH", "$.data.tact", content)
...
    } else if (msg == "CURRENT-STATE") {
        postUpdate(Dyson_Debug_CurrentState, content) //Add this line
        val String fmod_str = transform("JSONPATH", "$.product-state.fmod", content)
...

to the dyson475.rules
Afterwards they should show the content of the sensor data and current state messages. Posting their content (or send it to me via pm) will help to see which data the 455 sends and expect.

Thanks for the feedback, sure, I can try to help. Send you a PM with the debug messages. Let me know if there’s anything else I can send or test.

Thanks for the data. As expected, only a little bit of information more in the messages but nearly the same.

I also had a look on the prepare.py, seems that the script isn’t working yet as expected. Again an example how important testing is :wink: .

I try to fix the script on the next days and will have a look onto the changes necessary for the 455, but it does not look too complicated.

Sounds great, thanks. Let me know if I should test something or if I can help in any way.

Does this issue already fixed in current version?

i use pure hot+cool link and got follow error:

Traceback (most recent call last):
  File "prepare.py", line 12, in <module>
    ssid = input("Product SSID (e.g.: DYSON-NN2-EU-ABC1234D-475):")
  File "<string>", line 1, in <module>
NameError: name 'DYSON' is not defined

You have to use python 3 (I tested with Python 3.5). I got the same error if I use python 2.

At the moment, the script does not prepare the files for the pure hot + cool link (it’s the 455), but only for the pure cool link (the 475). If you wand to use the 455 (pure hot + cool link), you have to use the files from the branch “455” on the linked github page, get the password by using getPwdHash.py and replace the placeholders within the mqtt.cfg and dyson455.items files. Additionally the 475 entries have to be removed from the mqtt.cfg.
The plans are to include the 455 also into the preparation script, but due to a lack of available time at my side it’s not implemented yet.

1 Like

I invested some time and modified the files in branch “455”. The prepare.py script now asks for the air purifier and prepares the corresponding files. For the 455 you have to copy

  • mqtt.cfg
  • dyson455.items
  • dyson455.rules
  • dyson455en.sitemap

to your openhab installation after running the prepare.py script.

thank you very much!!!

it works great

BTW: sometimes i got follow error:

==> /var/log/openhab2/openhab.log <==
2018-03-31 18:36:12.517 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule '455/<id>/status/current': For input string: "["2970","2970"]"

I had a look regarding your reported error. On the rule which reads the values on a state change was an issue. It is fixed in the branch.
It should be sufficient to replace the dyson455.rules file with the latest from the branch.

Thanks for this code, it actually works for my 455.
However, there are two things that are not quite as they should be:

  1. When I run the prepare.py from the 455 branch, the mqtt.cfg file is nor filled. I used the one from the master branch and renamed the 475 to 455.
  2. The fanspeed is always reads as 11, even when i set it to 4 or any other number. The numbers I set, are correctly set at the device though.

thanks for the feedback.
The prepare script should work, and the 11 should only be displayed when running in “AUTO” mode. That’s strange.

As a starting point to investigate you could provide me your 455 configuration files (.items, mqtt.cfg, .rules and .sitemap) maybe I find out what was going wrong.

Thanks for this works great. Only problem I encountered is that updating the Turning & Night Mode doesn’t seem to work. It recognises the changes on the sitemap when I use the remote but changing the item through the sitemap doesn’t work.

Any ideas what the problem might be?

Are you operating the 455 or the 475?

475

All the other commands are working as expected?
On my side it’s working without limitations or problems. What are the versions (openhab, addons, firmware) you are using?

Thanks, it works perfect in BASIC UI

but how can i add multiple fans? i got 3 dyson fans in my home

And how can i make the .things file for paper UI?

Please advise.

Thanks much,

Hi,
regarding paper UI I can give no advise due to my lack of experience on this topic.

If you want to use 3 devices it should work with the following steps:

  1. Create the config for the first one.
  2. Replace “dyson475” with “dyson47501” and “Dyson475” with “Dyson47501” in files mqtt.cfg, dyson475.items, dyson475.rules and dyson475.sitemap. Also replace it in the filenames.
  3. Create the config for the second one (in an other directory).
  4. Replace “dyson475” with “dyson47502” and “Dyson475” with “Dyson47502” in files mqtt.cfg, dyson475.items, dyson475.rules and dyson475.sitemap. Also replace it in the filenames.
  5. Copy the content from the second mqtt.cfg into the first one.
  6. Copy the other files of the second configuration to the same directory as configuration one.

Repeat steps 3 to 6 for each additional air purifier with increasing the last to digits after “Dyson475”/“dyson475” (e.g. config 3 Dyson47503, config 10 Dyson47510).

  1. Copy the directory of the first configuration (now all configurations are in there) into your openhab config.

Hopefully the explanation was clear enough, even though it was short and not exhaustive.

Hello, First off thank you for your work.
The binding was running for quite a time, but since i moved my openhab2 install to a new system i experienced strange behaviour… maybe someone can help me out.
i have the 475-model, mqtt seems to be allright - i get messages like this one in the openhab-logs:

[vent.ItemStateChangedEvent] - Dyson475_Topic_Status_Current changed from {“msg”:“CURRENT-STATE”,“time”:“2019-01-08T10:53:28.000Z”,“mode-reason”:“LSCH”,“state-reason”:“ENV”,“dial”:“OFF”,“rssi”:“-52”,“product-state”:{“fmod”:“AUTO”,“fnst”:“OFF”,“fnsp”:“AUTO”,“qtar”:“0003”,“oson”:“OFF”,“rhtm”:“OFF”,“filf”:“4036”,“ercd”:“02C0”,“nmod”:“OFF”,“wacd”:“NONE”},“scheduler”:{“srsc”:“7252”,“dstv”:“0001”,“tzid”:“0001”}} to {“msg”:“ENVIRONMENTAL-CURRENT-SENSOR-DATA”,“time”:“2019-01-08T10:53:28.001Z”,“data”:{“tact”:“2939”,“hact”:“0074”,“pact”:“0002”,“vact”:“0000”,“sltm”:“OFF”}}

i understand this line “{“msg”:“ENVIRONMENTAL-CURRENT-SENSOR-DATA”,“time”:“2019-01-08T10:53:28.001Z”,“data”:{“tact”:“2939”,“hact”:“0074”,“pact”:“0002”,“vact”:“0000”,“sltm”:“OFF”}}” i giving openhab2 the data for temp and humidity (tact and hact)

i have moved the items file to items and set-up a sitemap with:
Frame label=“Klima” {
Default item=Dyson475_Tact label=“Temperatur [%.1f °C]”
Default item=Dyson475_Hact label=“Feuchtigkeit [%.0f %%]”
}

but i get no values there any more.

what am i missing? python3.5 is installed on the system, also mqtt1 binding in openhab2.

i do have the this part also in the same sitemap:

Frame label=“Pure Cool Link” {
Default item=Dyson475_Fnst label=“Lüfteraktivität [%d]”
Switch item=Dyson475_Fmod label=“Modus” mappings=[0=“OFF”, 1=“FAN”, 2=“AUTO”]
Default item=Dyson475_Oson label=“Drehung”
Default item=Dyson475_Nmod label=“Nachtmodus”
}

and the buttons are working . i can switch to auto, night-mode, etc. - so the communication between the dyson and openhab seems to work. but i get no values ion my sitemap.

any ideas? thanks for your help!