Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add new model #31

Open
littlehasty opened this issue Oct 21, 2022 · 9 comments
Open

Please add new model #31

littlehasty opened this issue Oct 21, 2022 · 9 comments

Comments

@littlehasty
Copy link

Hello,

First of all, thank you for the working local integration. My TP09 is now FINALLY in HA. Would it be possible to update the database for the newer models too please? The one missing for me is Purifier Hot+Cool Formaldehyde™ (HP09, Device Type is 527K).

Thank you!

@Ulrar
Copy link

Ulrar commented Dec 10, 2022

I've used PR #30 as a base to manually add support and it connects fine, so it's just a matter of adding a few lines to support it.
That PR identifies it as a Hot+Cool only so the formaldehyde measurements are missing, but everything else seems to be working well as far as I can tell.

I'll try to see if I can open a PR myself to add proper support for it including the formaldehyde sensor.

@Ulrar
Copy link

Ulrar commented Dec 10, 2022

Okay so here's what I've got so far :

diff --git a/libdyson/libdyson/__init__.py b/libdyson-new/__init__.py
index 7b05791..ae8fb07 100644
--- a/libdyson/libdyson/__init__.py
+++ b/libdyson-new/__init__.py
@@ -15,6 +15,7 @@ from .const import (
     DEVICE_TYPE_PURE_HOT_COOL_LINK,
     DEVICE_TYPE_PURE_HUMIDIFY_COOL,
     DEVICE_TYPE_PURIFIER_HUMIDIFY_COOL_FORMALDEHYDE,
+    DEVICE_TYPE_PURE_HOT_COOL_FORMALDEHYDE,
 )
 from .const import CleaningMode  # noqa: F401
 from .const import CleaningType  # noqa: F401
@@ -32,7 +33,7 @@ from .dyson_device import DysonDevice
 from .dyson_pure_cool import DysonPureCool
 from .dyson_pure_cool import DysonPureCoolFormaldehyde
 from .dyson_pure_cool_link import DysonPureCoolLink
-from .dyson_pure_hot_cool import DysonPureHotCool
+from .dyson_pure_hot_cool import DysonPureHotCool, DysonPureHotCoolFormaldehyde
 from .dyson_pure_hot_cool_link import DysonPureHotCoolLink
 from .dyson_pure_humidify_cool import DysonPureHumidifyCool, DysonPurifierHumidifyCoolFormaldehyde
 from .utils import get_mqtt_info_from_wifi_info  # noqa: F401
@@ -58,6 +59,8 @@ def get_device(serial: str, credential: str, device_type: str) -> Optional[Dyson
         return DysonPureCoolFormaldehyde(serial, credential, device_type)
     if device_type == DEVICE_TYPE_PURE_HOT_COOL_LINK:
         return DysonPureHotCoolLink(serial, credential, device_type)
+    if device_type == DEVICE_TYPE_PURE_HOT_COOL_FORMALDEHYDE:
+        return DysonPureHotCoolFormaldehyde(serial, credential, device_type)
     if device_type in [
         DEVICE_TYPE_PURE_HOT_COOL,
         DEVICE_TYPE_PURE_HOT_COOL_NEW,
diff --git a/libdyson/libdyson/const.py b/libdyson-new/const.py
index 254e1cb..d655aa0 100644
--- a/libdyson/libdyson/const.py
+++ b/libdyson-new/const.py
@@ -13,6 +13,7 @@ DEVICE_TYPE_PURIFIER_HUMIDIFY_COOL_FORMALDEHYDE = "358E"
 DEVICE_TYPE_PURE_HOT_COOL_LINK = "455"
 DEVICE_TYPE_PURE_HOT_COOL = "527"
 DEVICE_TYPE_PURE_HOT_COOL_NEW = "527E"
+DEVICE_TYPE_PURE_HOT_COOL_FORMALDEHYDE = "527K"

 DEVICE_TYPE_NAMES = {
     DEVICE_TYPE_360_EYE: "360 Eye robot vacuum",
@@ -27,6 +28,7 @@ DEVICE_TYPE_NAMES = {
     DEVICE_TYPE_PURE_HOT_COOL_LINK: "Pure Hot+Cool Link",
     DEVICE_TYPE_PURE_HUMIDIFY_COOL: "Pure Humidify+Cool",
     DEVICE_TYPE_PURIFIER_HUMIDIFY_COOL_FORMALDEHYDE: "Purifier Humidify+Cool Formaldehyde",
+    DEVICE_TYPE_PURE_HOT_COOL_FORMALDEHYDE: "Pure Hot+Cool Formaldehyde"
 }

 ENVIRONMENTAL_OFF = -1
diff --git a/libdyson/libdyson/dyson_pure_hot_cool.py b/libdyson-new/dyson_pure_hot_cool.py
index 3ceb789..561b383 100644
--- a/libdyson/libdyson/dyson_pure_hot_cool.py
+++ b/libdyson-new/dyson_pure_hot_cool.py
@@ -1,8 +1,17 @@
 """Dyson Pure Hot+Cool device."""

+from typing import Optional
+
 from .dyson_device import DysonHeatingDevice
 from .dyson_pure_cool import DysonPureCool

-
 class DysonPureHotCool(DysonPureCool, DysonHeatingDevice):
     """Dyson Pure Hot+Cool device."""
+
+class DysonPureHotCoolFormaldehyde(DysonPureHotCool):
+    """Dyson Pure Hot+Cool Formaldehyde device."""
+
+    @property
+    def formaldehyde(self) -> Optional[int]:
+        """Return formaldehyde reading."""
+        return self._get_environmental_field_value("hcho")

Instantiates and works fine, but the formaldehyde entity is still missing, not sure why.
I'll have another look later on, but hopefully this is about it and just need a small fix to get the sensor to register.

@Ulrar
Copy link

Ulrar commented Dec 12, 2022

Quick update, this actually works fine, I was just missing a change in the actual integration to use that sensor.

Basically in sensor.py for the dyson local integration you just need to add DysonPureHotCoolFormaldehyde to the import, and or isinstance(device, DysonPureHotCoolFormaldehyde) line 71 in the condition and it works fine.
Interestingly the sensor doesn't have a unit in HA, so I'm not sure what to make of the readings, but it is reading.

I'll open proper PRs now

@terzo33
Copy link

terzo33 commented Mar 4, 2023

Quick update, this actually works fine, I was just missing a change in the actual integration to use that sensor.

Basically in sensor.py for the dyson local integration you just need to add DysonPureHotCoolFormaldehyde to the import, and or isinstance(device, DysonPureHotCoolFormaldehyde) line 71 in the condition and it works fine. Interestingly the sensor doesn't have a unit in HA, so I'm not sure what to make of the readings, but it is reading.

I'll open proper PRs now

Hi, do you have news for Formaldehyde sensor?
Thanks

@Ulrar
Copy link

Ulrar commented Mar 4, 2023

@terzo33 Have a look at my two PRs, works fine with them

@terzo33
Copy link

terzo33 commented Mar 4, 2023

@terzo33 Have a look at my two PRs, works fine with them

Can I have link? Thanks

@terzo33 Have a look at my two PRs, works fine with them

I understood that to see the Formaldehyde sensor I have to modify the sensor.py file but I didn't understand where to put my hands, could you paste your sensor.py here? A thousand thanks

@terzo33
Copy link

terzo33 commented Mar 4, 2023

Quick update, this actually works fine, I was just missing a change in the actual integration to use that sensor.

Basically in sensor.py for the dyson local integration you just need to add DysonPureHotCoolFormaldehyde to the import, and or isinstance(device, DysonPureHotCoolFormaldehyde) line 71 in the condition and it works fine. Interestingly the sensor doesn't have a unit in HA, so I'm not sure what to make of the readings, but it is reading.

I'll open proper PRs now

I made the change on import and then I add this string here(line 81). is that okay?

Screenshot_20230304_143331_Home Assistant

@terzo33
Copy link

terzo33 commented Mar 6, 2023

I managed to integrate the Formaldehyde sensor but the values ​​do not coincide with the Dyson application values. for example on the Dyson application it marks 0.004 mg/m3 while on the home assistant it marks 1.5 (without units of measurement). even if on the Dyson application the unit of measurement is mg/m3 and on HA it is µg/m3... 0.004mg/m3 would be 4µg/m3 and not 1.5 as marked on the home assistant. so there is something wrong...

@Ulrar
Copy link

Ulrar commented Mar 6, 2023

Yes, the formaldehyde sensor in the current version isn't correctly defined, that's also addressed in my PR.
As for the values themselves some of the fields in the app are indexes, meaning it's not actually letting you see the real value, that may be why. It may also be doing some kind of aggregation over time, I'm not sure maybe @shenxn would know.

shenxn/ha-dyson#175
#36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants