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

Identify 438E as Pure Cool Formaldehyde, and add formaldehyde env data #12

Merged
merged 2 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions libdyson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
DEVICE_TYPE_360_EYE,
DEVICE_TYPE_360_HEURIST,
DEVICE_TYPE_PURE_COOL,
DEVICE_TYPE_PURE_COOL_2021,
DEVICE_TYPE_PURE_COOL_FORMALDEHYDE,
DEVICE_TYPE_PURE_COOL_DESK,
DEVICE_TYPE_PURE_COOL_LINK,
DEVICE_TYPE_PURE_COOL_LINK_DESK,
Expand All @@ -29,6 +29,7 @@
from .dyson_360_heurist import Dyson360Heurist
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_link import DysonPureHotCoolLink
Expand All @@ -49,15 +50,16 @@ def get_device(serial: str, credential: str, device_type: str) -> Optional[Dyson
return DysonPureCoolLink(serial, credential, device_type)
if device_type in [
DEVICE_TYPE_PURE_COOL,
DEVICE_TYPE_PURE_COOL_2021,
DEVICE_TYPE_PURE_COOL_DESK,
]:
return DysonPureCool(serial, credential, device_type)
if device_type == DEVICE_TYPE_PURE_COOL_FORMALDEHYDE:
return DysonPureCoolFormaldehyde(serial, credential, device_type)
if device_type == DEVICE_TYPE_PURE_HOT_COOL_LINK:
return DysonPureHotCoolLink(serial, credential, device_type)
if device_type in [
DEVICE_TYPE_PURE_HOT_COOL,
DEVICE_TYPE_PURE_HOT_COOL_NEW,
if device_type in [
DEVICE_TYPE_PURE_HOT_COOL,
DEVICE_TYPE_PURE_HOT_COOL_NEW,
]:
return DysonPureHotCool(serial, credential, device_type)
if device_type == DEVICE_TYPE_PURE_HUMIDIFY_COOL:
Expand Down
4 changes: 2 additions & 2 deletions libdyson/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
DEVICE_TYPE_PURE_COOL_LINK = "475"
DEVICE_TYPE_PURE_COOL_LINK_DESK = "469"
DEVICE_TYPE_PURE_COOL = "438"
DEVICE_TYPE_PURE_COOL_2021 = "438E" # Not sure about the official name
DEVICE_TYPE_PURE_COOL_FORMALDEHYDE = "438E"
DEVICE_TYPE_PURE_COOL_DESK = "520"
DEVICE_TYPE_PURE_HUMIDIFY_COOL = "358"
DEVICE_TYPE_PURE_HOT_COOL_LINK = "455"
Expand All @@ -17,7 +17,7 @@
DEVICE_TYPE_360_EYE: "360 Eye robot vacuum",
DEVICE_TYPE_360_HEURIST: "360 Heurist robot vacuum",
DEVICE_TYPE_PURE_COOL: "Pure Cool",
DEVICE_TYPE_PURE_COOL_2021: "Pure Cool (2021)",
DEVICE_TYPE_PURE_COOL_FORMALDEHYDE: "Pure Cool Formaldehyde",
DEVICE_TYPE_PURE_COOL_DESK: "Pure Cool Desk",
DEVICE_TYPE_PURE_COOL_LINK: "Pure Cool Link",
DEVICE_TYPE_PURE_COOL_LINK_DESK: "Pure Cool Link Desk",
Expand Down
14 changes: 14 additions & 0 deletions libdyson/dyson_pure_cool.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,17 @@ def disable_oscillation(self) -> None:
else:
oson = "OFF"
self._set_configuration(oson=oson)


class DysonPureCoolFormaldehyde(DysonPureCool):
"""This model is compatible with PureCool but has one additional sensor."""

@property
def formaldehyde(self) -> Optional[int]:
"""Return formaldehyde reading."""
# Dyson documentation for Dyson Pure Cool Formaldehyde refers to
# the formaldehyde reading as HCHO (pp5).
# https://www.dyson.com/content/dam/dyson/maintenance/user-guides/en_US/airtreatment/purifiers/TP09/497043-01.pdf
#
# H-CHO is also a common way to refer to formaldehyde.
int(self._get_field_value(self._status, "hcho"))
5 changes: 3 additions & 2 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
DEVICE_TYPE_360_EYE,
DEVICE_TYPE_360_HEURIST,
DEVICE_TYPE_PURE_COOL,
DEVICE_TYPE_PURE_COOL_2021,
DEVICE_TYPE_PURE_COOL_FORMALDEHYDE,
DEVICE_TYPE_PURE_COOL_DESK,
DEVICE_TYPE_PURE_COOL_LINK,
DEVICE_TYPE_PURE_COOL_LINK_DESK,
Expand All @@ -19,6 +19,7 @@
Dyson360Heurist,
DysonDevice,
DysonPureCool,
DysonPureCoolFormaldehyde,
DysonPureCoolLink,
DysonPureHotCool,
DysonPureHotCoolLink,
Expand All @@ -37,7 +38,7 @@
(DEVICE_TYPE_PURE_COOL_LINK_DESK, DysonPureCoolLink),
(DEVICE_TYPE_PURE_COOL_LINK, DysonPureCoolLink),
(DEVICE_TYPE_PURE_COOL, DysonPureCool),
(DEVICE_TYPE_PURE_COOL_2021, DysonPureCool),
(DEVICE_TYPE_PURE_COOL_FORMALDEHYDE, DysonPureCoolFormaldehyde),
(DEVICE_TYPE_PURE_COOL_DESK, DysonPureCool),
(DEVICE_TYPE_PURE_HOT_COOL_LINK, DysonPureHotCoolLink),
(DEVICE_TYPE_PURE_HOT_COOL, DysonPureHotCool),
Expand Down