Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kongo09 committed Feb 4, 2024
2 parents ad77243 + 0e7b904 commit 84c336a
Show file tree
Hide file tree
Showing 17 changed files with 862 additions and 81 deletions.
66 changes: 40 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ Note: `configuration.yaml` is no longer supported and your configuration is not
- AC3854/51
- AC3858/50
- AC3858/51
- AC3858/86
- AC4236
- AC4550
- AC4558
- AC5659
- AMF765
- AMF870
- CX5120


## Is your model not supported yet?
Expand Down Expand Up @@ -170,31 +174,41 @@ The `fan` entity has some additional attributes not captured with sensors. Speci

The integration also provides the original Philips icons for your use in the frontend. The icons can be accessed with the prefix `pap:` and should be visible in the icon picker. Credit for this part of the code goes to @thomasloven

![Preview](./custom_components/philips_airpurifier_coap/icons/pap/power_button.svg) power_button<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/child_lock_button.svg) child_lock_button<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/auto_mode_button.svg) auto_mode_button<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/fan_speed_button.svg) fan_speed_button<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/humidity_button.svg) humidity_button<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/light_dimming_button.svg) light_dimming_button<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/two_in_one_mode_button.svg) two_in_one_mode_button<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/timer_reset_button.svg) timer_reset_button<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/sleep_mode.svg) sleep_mode<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/auto_mode.svg) auto_mode<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/speed_1.svg) speed_1<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/speed_2.svg) speed_2<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/speed_3.svg) speed_3<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/allergen_mode.svg) allergen_mode<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/purification_only_mode.svg) purification_only_mode<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/two_in_one_mode.svg) two_in_one_mode<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/bacteria_virus_mode.svg) bacteria_virus_mode<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/nanoprotect_filter.svg) nanoprotect_filter<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/filter_replacement.svg) filter_replacement<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/water_refill.svg) water_refill<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/prefilter_cleaning.svg) prefilter_clearning<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/prefilter_wick_cleaning.svg) prefilter_wick_cleaning<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/pm25.svg) pm25<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/iai.svg) iai<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/wifi.svg) wifi<br />
![Preview](./custom_components/philips_airpurifier_coap/icons/pap/reset.svg) reset<br />
| icon | name |
|------------------------------------------------------------------------------------------------|-------------------------|
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/power_button.svg) | power_button |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/child_lock_button.svg) | child_lock_button |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/auto_mode_button.svg) | auto_mode_button |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/fan_speed_button.svg) | fan_speed_button |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/humidity_button.svg) | humidity_button |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/light_dimming_button.svg) | light_dimming_button |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/two_in_one_mode_button.svg) | two_in_one_mode_button |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/timer_reset_button.svg) | timer_reset_button |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/sleep_mode.svg) | sleep_mode |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/auto_mode.svg) | auto_mode |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/speed_1.svg) | speed_1 |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/speed_2.svg) | speed_2 |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/speed_3.svg) | speed_3 |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/allergen_mode.svg) | allergen_mode |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/purification_only_mode.svg) | purification_only_mode |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/two_in_one_mode.svg) | two_in_one_mode |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/bacteria_virus_mode.svg) | bacteria_virus_mode |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/nanoprotect_filter.svg) | nanoprotect_filter |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/filter_replacement.svg) | filter_replacement |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/water_refill.svg) | water_refill |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/prefilter_cleaning.svg) | prefilter_clearning |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/prefilter_wick_cleaning.svg) | prefilter_wick_cleaning |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/pm25.svg) | pm25 |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/iai.svg) | iai |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/wifi.svg) | wifi |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/reset.svg) | reset |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/circulate.svg) | circulate |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/clean.svg) | clean |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/mode.svg) | mode |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/pm25b.svg) | pm25b |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/rotate.svg) | rotate |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/oscillate.svg) | oscillate |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/heating.svg) | heating |
| ![Preview](./custom_components/philips_airpurifier_coap/icons/pap/gas.svg) | gas |

Note: you might have to clear your browser cache after installation to see the icons.
2 changes: 1 addition & 1 deletion custom_components/philips_airpurifier_coap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
_LOGGER = logging.getLogger(__name__)


PLATFORMS = ["fan", "sensor", "switch", "light", "select"]
PLATFORMS = ["fan", "sensor", "switch", "light", "select", "number"]


# icons code thanks to Thomas Loven:
Expand Down
69 changes: 55 additions & 14 deletions custom_components/philips_airpurifier_coap/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,34 @@ async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowRes
_LOGGER.warning(r"Failed to connect: %s", ex)
raise exceptions.ConfigEntryNotReady from ex

# autodetect model and name
self._model = list(
# autodetect model
model_map = map(
status.get,
[
PhilipsApi.MODEL_ID,
PhilipsApi.NEW_MODEL_ID,
PhilipsApi.NEW2_MODEL_ID,
],
)
_LOGGER.debug("model_map retrieved: %s", model_map)
model_filter = filter(None, model_map)
_LOGGER.debug("model_filter applied: %s", model_filter)
model_list = list(model_filter)
_LOGGER.debug("model_list built: %s", model_list)
first_model = model_list[0]
_LOGGER.debug("first model selected: %s", first_model)
self._model = first_model[:9]
_LOGGER.debug("model type extracted: %s", self._model)

# autodetect name
self._name = list(
filter(
None, map(status.get, [PhilipsApi.MODEL_ID, PhilipsApi.NEW_MODEL_ID])
None,
map(
status.get,
[PhilipsApi.NAME, PhilipsApi.NEW_NAME, PhilipsApi.NEW2_NAME],
),
)
)[0][:9]
self._name = list(
filter(None, map(status.get, [PhilipsApi.NAME, PhilipsApi.NEW_NAME]))
)[0]
self._device_id = status[PhilipsApi.DEVICE_ID]
_LOGGER.debug(
Expand Down Expand Up @@ -215,16 +235,37 @@ async def async_step_user(self, user_input: dict[str, Any] = None) -> FlowResult
_LOGGER.warning(r"Failed to connect: %s", ex)
raise exceptions.ConfigEntryNotReady from ex

# autodetect model and name
self._model = list(
filter(
None,
map(status.get, [PhilipsApi.MODEL_ID, PhilipsApi.NEW_MODEL_ID]),
)
)[0][:9]
# autodetect model
model_map = map(
status.get,
[
PhilipsApi.MODEL_ID,
PhilipsApi.NEW_MODEL_ID,
PhilipsApi.NEW2_MODEL_ID,
],
)
_LOGGER.debug("model_map retrieved: %s", model_map)
model_filter = filter(None, model_map)
_LOGGER.debug("model_filter applied: %s", model_filter)
model_list = list(model_filter)
_LOGGER.debug("model_list built: %s", model_list)
first_model = model_list[0]
_LOGGER.debug("first model selected: %s", first_model)
self._model = first_model[:9]
_LOGGER.debug("model type extracted: %s", self._model)

# autodetect name
self._name = list(
filter(
None, map(status.get, [PhilipsApi.NAME, PhilipsApi.NEW_NAME])
None,
map(
status.get,
[
PhilipsApi.NAME,
PhilipsApi.NEW_NAME,
PhilipsApi.NEW2_NAME,
],
),
)
)[0]
self._device_id = status[PhilipsApi.DEVICE_ID]
Expand Down
Loading

0 comments on commit 84c336a

Please sign in to comment.