Skip to content

Commit

Permalink
start support for AMF765 and CX5120
Browse files Browse the repository at this point in the history
  • Loading branch information
kongo09 committed Jan 9, 2024
1 parent 1c9cf0e commit 5dfbd86
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
16 changes: 16 additions & 0 deletions custom_components/philips_airpurifier_coap/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class FanModel(StrEnum):
AC4550 = "AC4550"
AC4558 = "AC4558"
AC5659 = "AC5659"
AMF765 = "AMF765"
CX5120 = "CX5120"


class PresetMode:
Expand Down Expand Up @@ -293,6 +295,7 @@ class PhilipsApi:
SWITCH_ON: "1",
SWITCH_OFF: "0",
}

# the AC1715 seems to follow a new scheme, this should later be refactored
NEW_NAME = "D01-03"
NEW_MODEL_ID = "D01-05"
Expand All @@ -304,6 +307,12 @@ class PhilipsApi:
NEW_PM25 = "D03-33"
NEW_PREFERRED_INDEX = "D03-42"

# there is a third generation of devices with yet another scheme
NEW2_NAME = "D01S03"
NEW2_MODEL_ID = "D01S05"
NEW2_POWER = "D03102"
NEW2_DISPLAY_BACKLIGHT = "D0312D"

PREFERRED_INDEX_MAP = {
"0": ("Indoor Allergen Index", ICON.IAI),
"1": ("PM2.5", ICON.PM25),
Expand Down Expand Up @@ -506,6 +515,13 @@ class PhilipsApi:
SWITCH_ON: 100,
SWITCH_OFF: 0,
},
PhilipsApi.NEW2_DISPLAY_BACKLIGHT: {
ATTR_ICON: ICON.LIGHT_DIMMING_BUTTON,
FanAttributes.LABEL: FanAttributes.DISPLAY_BACKLIGHT,
CONF_ENTITY_CATEGORY: EntityCategory.CONFIG,
SWITCH_ON: 100,
SWITCH_OFF: 0,
},
}

SELECT_TYPES: dict[str, SelectDescription] = {
Expand Down
55 changes: 52 additions & 3 deletions custom_components/philips_airpurifier_coap/philips.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,45 @@ class PhilipsNewGenericCoAPFan(PhilipsGenericCoAPFanBase):
STATE_POWER_OFF = "OFF"


class PhilipsNew2GenericCoAPFan(PhilipsGenericCoAPFanBase):
"""Class to manage another new generic CoAP fan."""

AVAILABLE_PRESET_MODES = {}
AVAILABLE_SPEEDS = {}

AVAILABLE_ATTRIBUTES = [
# device information
(FanAttributes.NAME, PhilipsApi.NEW2_NAME),
(FanAttributes.MODEL_ID, PhilipsApi.NEW2_MODEL_ID),
(FanAttributes.PRODUCT_ID, PhilipsApi.PRODUCT_ID),
(FanAttributes.DEVICE_ID, PhilipsApi.DEVICE_ID),
# (FanAttributes.SOFTWARE_VERSION, PhilipsApi.SOFTWARE_VERSION),
(FanAttributes.WIFI_VERSION, PhilipsApi.WIFI_VERSION),
# (FanAttributes.ERROR_CODE, PhilipsApi.ERROR_CODE),
# (FanAttributes.ERROR, PhilipsApi.ERROR_CODE, PhilipsApi.ERROR_CODE_MAP),
# device configuration
# (
# FanAttributes.PREFERRED_INDEX,
# PhilipsApi.NEW_PREFERRED_INDEX,
# PhilipsApi.NEW_PREFERRED_INDEX_MAP,
# ),
# device sensors
# (
# FanAttributes.RUNTIME,
# PhilipsApi.RUNTIME,
# lambda x, _: str(timedelta(seconds=round(x / 1000))),
# ),
]

AVAILABLE_LIGHTS = [PhilipsApi.NEW2_DISPLAY_BACKLIGHT]
AVAILABLE_SWITCHES = []
AVAILABLE_SELECTS = []

KEY_PHILIPS_POWER = PhilipsApi.NEW2_POWER
STATE_POWER_ON = 1
STATE_POWER_OFF = 0


class PhilipsHumidifierMixin(PhilipsGenericCoAPFanBase):
"""Mixin for humidifiers."""

Expand Down Expand Up @@ -1153,9 +1192,9 @@ class PhilipsAC3836(PhilipsGenericCoAPFan):

AVAILABLE_PRESET_MODES = {
PresetMode.AUTO: {
PhilipsApi.POWER: "1",
PhilipsApi.MODE: "AG",
PhilipsApi.SPEED: "1"
PhilipsApi.POWER: "1",
PhilipsApi.MODE: "AG",
PhilipsApi.SPEED: "1",
},
# make speeds available as preset
PresetMode.SLEEP: {
Expand Down Expand Up @@ -1469,6 +1508,14 @@ class PhilipsAC5659(PhilipsGenericCoAPFan):
AVAILABLE_SELECTS = [PhilipsApi.PREFERRED_INDEX]


class PhilipsAMF765(PhilipsNew2GenericCoAPFan):
"""AMF765."""


class PhilipsCX5120(PhilipsNew2GenericCoAPFan):
"""CX5120."""


model_to_class = {
FanModel.AC0850: PhilipsAC0850,
FanModel.AC1214: PhilipsAC1214,
Expand All @@ -1495,4 +1542,6 @@ class PhilipsAC5659(PhilipsGenericCoAPFan):
FanModel.AC4550: PhilipsAC4550,
FanModel.AC4558: PhilipsAC4558,
FanModel.AC5659: PhilipsAC5659,
FanModel.AMF765: PhilipsAMF765,
FanModel.CX5120: PhilipsCX5120,
}

0 comments on commit 5dfbd86

Please sign in to comment.