shenxn / ha-dyson

HomeAssitant custom integration for dyson
MIT License
306 stars 60 forks source link

Adding support for 527K - Dyson Pure Hot+Cool Formaldehyde #175

Open Ulrar opened 1 year ago

Ulrar commented 1 year ago

This adds support for the Dyson Pure Hot+Cool Formaldehyde (527K).

This depends on https://github.com/shenxn/libdyson/pull/36. This solves https://github.com/shenxn/ha-dyson/issues/167

Ulrar commented 1 year ago

I've added a second commit fixing the class and unit of the formaldehyde sensor, which were not being seen by HA as a measurement class. Feel free to reject that second commit if that was setup that way on purpose, but I suspect it wasn't intentional.

dustingrady commented 1 year ago

Great work! Hoping to see this merged soon. Been waiting for Formaldehyde sensor support for my TP09 :)

Ulrar commented 1 year ago

It should be easy to apply this (and related PR to libdyson) by hand on your system in the mean time, if you don't want to wait

dustingrady commented 1 year ago

It should be easy to apply this (and related PR to libdyson) by hand on your system in the mean time, if you don't want to wait

It seems I get the following. I've seen others with this in the issues section.

Platform not found (cannot import name 'DysonPureHotCoolFormaldehyde' from 'libdyson' (/usr/local/lib/python3.10/site-packages/libdyson/init.py)).

Ulrar commented 1 year ago

Yeah you need to patch your libdyson with the content of that PR first, the code here depends on the lib already supporting the fan

dustingrady commented 1 year ago

Yeah you need to patch your libdyson with the content of that PR first, the code here depends on the lib already supporting the fan

Gotcha, thank you. I made that change and the error is gone, but I do not see the HCHO sensor appear. I made sure the changes I added from your diff are in my sensor.py and that manifest.json points to the new lib like your previous comment. I've tried reloading the device and rebooting HA. Maybe I missed something.

Guessing maybe the isinstance isn't picking up my TP09. I'll have to see where the model info is stored so I can change it if is incorrect

Update: @Ulrar it seems it was the isinstance since mine is a DysonPureCoolFormaldehyde and doesn't have heat. After importing that and adding an isinstance check for it, it's working as expected. Thanks again, and Happy Holidays!

Ulrar commented 1 year ago

Ah yes, that's a different device. If you know what code it is (get_devices.py says it) we could always add it to the PRs, should be easy enough

dustingrady commented 1 year ago

@Ulrar , I get libdyson.exceptions.DysonInvalidAuth when trying to use get_devices.py, similar to this post. I have a Dyson Pure Cool Formaldehyde TP09.

Modifying your changes to the following allow me to see the HCHO readings in HA that match my TP09

from libdyson import (
    Dyson360Eye,
    Dyson360Heurist,
    DysonDevice,
    DysonPureCoolLink,
    DysonPureHumidifyCool,
    DysonPurifierHumidifyCoolFormaldehyde,
    DysonPureHotCoolFormaldehyde,
    DysonPureCoolFormaldehyde,
)
if isinstance(device, DysonPurifierHumidifyCoolFormaldehyde) or isinstance(
            device, DysonPureHotCoolFormaldehyde) or isinstance(
            device, DysonPureCoolFormaldehyde):

I'm not sure what the best way to add it is since you have a PR pending. I can branch from your branch, or you can add, either way :P

Ulrar commented 1 year ago

Ah sorry, completely missed this. Looking here it sounds like the product code might be 438E, does that sound right ?

Ideally you wouldn't just use this PR as is, since your device doesn't have heating, but we can add another instance without heating for that product code, assuming that's the right one.

TerrorSource commented 1 year ago

@Ulrar i have a HP09, got the serial and the credentials via libdyson. I've downloaded dyson-local, did the changes to the sensor.py manually, restarted HA. When i try to add the device i get "Failed to connect".

How can i solve that?

Ulrar commented 1 year ago

Have you made the changes to libdyson as well? There's two PRs, one for the HA integration and one for the underlying libdyson, both are needed

dustingrady commented 1 year ago

Ah sorry, completely missed this.

No worries.

Looking https://github.com/lukasroegner/homebridge-dyson-pure-cool/issues/225 it sounds like the product code might be 438E, does that sound right ?

Yes, that is correct. I've been using the changes I mentioned above without issue for a couple weeks now.

TerrorSource commented 1 year ago

@Ulrar @dustingrady do you also use HomeAssistant? Cause i cant find the libdyson folder in HomeAssistant, i've done the changes in dyson-local files.

Ulrar commented 1 year ago

Yeah but I don't use Hass OS so I can't talk to it, I just use the docker container. Have a look in the other PR, there's discussions about this

TerrorSource commented 1 year ago

I have created a fork of libdyson and added the code of @Ulrar into the fork so everyone can use it directly untill the maintainer of dyson-local merges Ulrar's code

source = https://github.com/shenxn/libdyson/pull/36/commits/6a8ed5c59ecf17d06facb4121ec6752095b7694e#diff-ef0658f150dc67e06f245eb9a355b958562f9f9cc24c8360f3e8c54417b7c3c2

In HomeAssistant edit /config/custom_components/dyson_local/manifest.json replace the content with this: { "domain": "dyson_local", "name": "Dyson Local", "config_flow": true, "documentation": "https://github.com/shenxn/ha-dyson", "issue_tracker": "https://github.com/shenxn/ha-dyson/issues", "dependencies": ["zeroconf"], "codeowners": ["@shenxn"], "requirements": ["git+https://github.com/TerrorSource/libdyson.git@main#libdyson==0.9.1"], "version": "0.16.4-4", "iot_class": "local_polling" }

Restart HomeAssistant and add the Hot+Cool Formaldehyde via local method

dustingrady commented 1 year ago

Is the main project we're branching from still supported? I haven't seen any merges recently by the author.

dotvezz commented 1 year ago

Support for both 527K devices (Formaldehyde and non-Formaldehyde) has been implemented on https://github.com/libdyson-wg/ha-dyson and https://github.com/libdyson-wg/libdyson-neon

@dustingrady sadly, while we're grateful for shenxn's building of the foundation, they are no longer active. the ha-dyson fork has been created to continue development of these projects.