Closed etheralm closed 4 years ago
I just bought one of these too. I seem to be able to log into my Dyson account but I get an empty device list returned.
Yeah, it looks like they introduced a new version of the provisioning API for those under:
https://api.cp.dyson.com/v2/provisioningservice/manifest
I think I got it sorted out, give me an hour or two to go through the last of the new state properties and I'll push my changes.
One thing that would be nice to know is if the old models are showing in the new version of the API, because I'm currently assuming that they are not. It would be really great if someone that has pure cool link can check that.
Ok here are all the fields in the state json that I figured out so far:
Field | Description | States | Notes |
---|---|---|---|
fpwr | Power | ON, OFF | Turns Fan On/Off |
fdir | Front direction | ON, OFF | Switches between blowing from the front and the back of the fan |
auto | Auto mode | ON, OFF | Enables/Disables Auto mode |
oscs | Oscillation status | ON, OFF, IDLE | Oscillation goes to idle when auto mode is on and target air quality is reached |
oson | Oscillation | ON, OFF | Turns the ossicallation on and off |
nmod | Night Mode | ON, OFF | Enables night mdode |
rhtm | Continuous Monitoring | ON, OFF | Switches continious monitoring onn and off |
fnst | Fan state | FAN, OFF | Have to check if there aren't other states |
ercd | unknown | Those two are ignored in the previous fans too, looks like some sort of condition or state | |
wacd | unknown | ||
nmdv | Night Mode Fan Speed | 1-10? | Shows 4 right now |
fnsp | Fan speed | AUTO, 1-10 | Controls the fan speed |
bril | unknown | 2? | No idea what this is, but its always 2 |
corf | unknown | ON? | No idea what this is either but it is always on |
cflr | Carbon filter status | 1 - 100 | Carbon filter status in percentage |
hflr | HEPA filter status | 1 - 100 | HEPA filter status in percentage |
sltm | Sleep timer | OFF, 1-540? | Integer representing minutes, maximum number in android app is 540 |
osal | Oscillation lower angle | 5 - 355 | Configures the lower angle of the arc of oscillation |
osau | Oscillation upper angle | 5 - 355 | Configures the upper angle of the arc of oscillation. Can't be lower than the lower one. If both are set to the same value oscillation is disabled and it configures the angle of the fan |
ancp | Unknown | CUST | No idea, it is always set to cust |
The ones that I couldn't figure out are marked as unknown in the table above. ercd, wacd, bril, corf and, ancp. It looks like ercd, wacd are also in the the state response for the old models. All have the same values no matter what I change in the app.
Anyway I'll implement the state based on the table above now.
Have you had to modify the request to get this data? As far as I can see I'm getting logged in successfully but the data request returns 200 and no json.
I connected directly to the fan's mqtt broker to track the states and see what changes what when I change the different settings in the app. So far it looks like apart from the provisioning api version and the different state and sensor responses, everything else is the same.
ok, so far so good. I just pushed the changes I was working on in my own repo. If you want to try it out its here: https://github.com/etheralm/libpurecoollink
The basic functionality is there, you can turn the fan on and off and the sensors are reporting properly. Whats still not working is the auto mode and the oscillation angle settings, it seems to be ignoring those fields. I'll try to capture what the app is sending as STATE-CHANGE for those with wireshark when I get back home later and reproduce it.
Works for me - thanks. Can see and change power status etc. Having trouble getting at the sensor data though.
Its under
devices[0].environmental_state
not devices[0].environment_state
like it says it in the documentation, I think its a typo.
Thanks!
Ok I just pushed another update where I fixed the oscillation angle and sleep timer configuration parameters (duh the fan expects a string and not an integer...)
So now basically you can set the oscillation angle with something like this:
devices[0].set_configuration(oscillation=Oscillation.OSCILLATION_ON, oscillation_angle_low=120, oscillation_angle_high=160)
Keep in mind that the higher angle should be either equal, or 30 or more than the lower for the command to work.
I've also added several helper methods for the most common commands (the ones available on the main screen of the android app) where I do validation on the input, the following methods are available:
turn_on()
turn_off()
enable_oscillation(oscillation_angle_low, oscillation_angle_high) # both arguments must be int
disable_oscillation()
enable_sleep_timer(duration) # takes int (minutes)
disable_sleep_timer()
set_fan_speed(fan_speed) # takes fan FanSpeed enum as input
enable_frontal_direction()
disable_frontal_direction()
enable_auto_mode()
disable_auto_mode()
enable_night_mode()
disable_night_mode()
I hope that they are all self explanatory. For example to set the fan oscillation between 120 and 160 degrees you can call:
devices[0].enable_oscillation(120, 160)
and to set the fan speed to auto you can call
devices[0].set_fan_speed(FanSpeed.FAN_SPEED_AUTO)
I'll try to clean up the code, write the tests and the documentation and submit a pull request over the weekend.
Sounds good - I'll try it out today. I got an error on the nitrogen dioxide yesterday when I first switched on the Dyson but it cleared after a minute or two. I think perhaps that parameter might need the same conditional handling used for the volatile organic compounds value. What do you think?
Very good catch, thanks. I completely forgot to test the fan with continuous monitoring off. While trying it out several other issues related to the sensor states cropped up, but I think I managed to cover them all. I just pushed the fix to the repo.
Cool. Installed and looking good. :)
ok I just finished the tests and submitted the PR. Now onto integrating this in home assistant.
Btw as mentioned in the PR, I've only added support for the tower purifier (TP04) because this is what I have, I'll leave this ticket open for now in hopes that someone with the desk model (DP04) shows up, so that they can get the product type for it and that we can test if everything works as expected with it too.
@etheralm the new desktop fan (DP04) ProductType is 520 FYI
Thx, I'll push and update shortly, do you have one and can you test if everything is working afterwards?
Thank you for the PR @sheppy
@charlesblonde Hi is this PR complete and going to be pulled into a new release? I’d like to add my new TP04 to HomeAssistant and it doesn’t work, I assume requiring the changes in this PR. Thanks.
@shortbloke Hi, the changes in this pr are indeed required in order to get those fans to work with home assistant, but the dyson component and the frontend also have to be updated for them to work. I'm currently working on this, let me know if you are interested in testing, I can help you set it up.
Sure @etheralm I'm happy to have a go, feel free to send me details of where to get the necessary files and how to apply them. Hopefully not complicated by running using hass.io.
Was the change ever released? I just bought a TP04 and would like to integrate with HomeAssistant
Hi @etheralm ! I downloaded this branch and am able to now see my device however it will not connect to it using auto or manual. When I enter connected = devices[0].connect("192.168.1.2")
as stated in the libpurecoollink installation guide I get the following error message:
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Has anyone else run into this issue?
@snjoetw I've already submitted a pr for home assistant support, but I need to do some changes before it is accepted. You can track the progress here: https://github.com/home-assistant/home-assistant/pull/19311
@LauraFlem Looks like it can't find the fan for some reason, maybe its a firewall issue? One thing I noticed with my fan is that it likes to release its dhcp lease once a day and then get a new ip. This breaks home assistant when the ip changes even when using the auto configuration, so I had to reserve an ip for the fan's MAC in my DHCP server. Can you ping the ip of the fan?
@etheralm Thanks for that, it worked and I've gotten it working now! I was wondering do you know how to access the air quality, VOC, and PM readings at all? Sorry, the project I'm working on involves using this data and I can't figure out how to access it.
@LauraFlem No worries, you can get the readings from the environment state object.
For example:
connected = devices[0].connect("192.168.1.2")
env_state = connected.environmental_state
pm25 = env_state.particulate_matter_25
pm10 = env_state.particulate_matter_10
voc = env_state.volatile_organic_compounds
@snjoetw FYI, until PR#19311 gets merged, you can always just use @etheralm's existing code as a custom component in HomeAssistant - see my custom_components folder.
@etheralm thank you so much for continuing to work on this (despite Martin's intense code review feedback - I know how frustrating it can be to be asked to refactor/improve someone else's code, especially when it seems the whole air quality component in hass is a bit of a moving target right now). Your work has made my Dyson air purifier so much more valuable/interesting to me now I've got sensor values feeding into my hass dashboard 😄
@beveradb Thank you very much for the kind words. I was extremely busy up until last week and couldn't start working on the requested changes. I looked at them on Monday and started throwing something together and was about to post an update in the PR. If all goes well it should be ready by the end of the week 😃 .
@etheralm Hi there and thank you for proposing this updated library to interact with newer Dyson products. I have a TP04 and just installed the library and while I manage to connect to my Dyson account, the json return by the .device() function is always empty. What would you suggest I do to investigate this further and understand why my device is not listed? This causes the connect functions to fail because of IndexError: list index out of range.
Thank you in advance.
@debarrylt which version are you running? Sounds like you are running the old version which doesn't support TP04, try to test it with the the one from my PR.
You can get it with pip with
pip install libpurecool
@debarrylt which version are you running? Sounds like you are running the old version which doesn't support TP04, try to test it with the the one from my PR.
You can get it with pip with
pip install libpurecool
@etheralm I manually installed the lib and must have mixed it up... Thanks for the reply, it solved the issue.
Hey all,
Are you all still able to connect to your TP04 devices? I noticed that my device updated last night and since then I can connect to it...
I now disabled the auto update but I guess this is too late and Dyson might have changed their API.
Let me know if you experience the same issue.
Thanks,
Laurent
Did you update the climate component for the dyson pure cool V2. I've got both the new Hot Cold & Pure Cool. The fan component is working great for both but only the Hot Cold works with the climate component. I'm going to modify the climate file but would be good if you have already done it.
The new pure cool v2s are fans only, so I'm not sure what you mean. My understanding was that the climate component is only for devices where you can set the desired temperature.
edit: nevermind I fail at reading, there is a new pure hot+cool model? Oh yes its called pure hot+cool. I'm afraid it probably won't be enough to just update the climate component in ha to get it working.
Ah true, no mine is the pure cool v2 - just the fan. What I wanted was the temperature reading so I can have consistency across my devices, therefore even though its not technically a climate component, I wanted the interface to be similar, see image below (living room is pure cool v2) :
Probably a better way to do it - but will keep my modified climate component for now.
I just received my new Dyson Pure Cool TP04 fan and sadly it doesn't work with the current version of libpurecoollink, but I kinda expected that with it being a brand new model. I'm talking about this one: https://www.dyson.com/purifiers/dyson-pure-cool-overview.html The one with the round display on the front.
Anyway I started working on adding support for it and it is already connecting, but there are still some new fields in the state and sensor jsons that I have to figure out and I have to write the tests for it before I can submit a PR, so I'm just opening this in case that someone runs into the same issue before its ready.
Cheers.