kongo09 / philips-airpurifier-coap

💨 Philips AirPurifier custom component for Home Assistant. Supports local CoAP protocol.
175 stars 27 forks source link

AC1214/10 #11

Closed kine90 closed 1 year ago

kine90 commented 2 years ago

I´ve just updated the integration for my purifier, before I was using the one from Betaboon.

preset_modes: allergen, auto, night
percentage: 50
percentage_step: 25
preset_mode: null
name: Bedroom
type: AC1214
model_id: AC1214/10
product_id: dca8c9d2f2ab11e8a1e3061302926720
device_id: 2b36c7fe68c211ec837242a9fde9d653
software_version: 2.0.0
wifi_version: AWS_Philips_AIR@69.1
error_code: 0
error: 0
preferred_index: Indoor Allergen Index
runtime: 1 day, 23:38:53
icon: pap:fan_speed_button
friendly_name: Bedroom
supported_features: 9
kongo09 commented 2 years ago
  • I can set the speed only to 75% max,

In the code there is a turbo speed setting. Does your device have a turbo mode?

  • is not possible anymore to turn it on

This feels like the connectivity problem. Not sure if this can be fixed. Was that the same with the previous betaboon integration?

  • "Set preset" commands to "auto", "night", or "allergen" have no effect.

This is strange. It might also explain why you don't get full speed in the turbo mode, as this is set in a similar way as the presets. Can you please enable debug logging and share a log with the response data from the device?

  • Child-lock switch don´t show up.

There is no child-lock for this device in the code right now. I've added this for the next release. Thanks for pointing that out.

  • Backlight controls and brightness don´t work

Again, please post a debug log with the data.

kongo09 commented 2 years ago

child lock switch added in v0.9.5

kine90 commented 2 years ago

Hi, thanks for following back! I´ve reverted to Betaboon to keep some automations and flows going. I will re-install your version and provide the logs as soon I have some time, probably tomorrow. For now I can say:

Regarding the modes, I´ve noticed that, when calling fan.set_preset for Turbo, Allergen or Night mode, my device doesn´t even emit any beep to notify a received command, while calling set_preset Auto always results in a beep from the device. Also, using Betaboon, there are times when the device is off and simply sending fan.switch_on does not work. In these cases, adding set_preset to Auto brings back the device on in manual mode. May it be some kind of state-machine logic defining how the commands are interpreted according to the current purifier state?

kongo09 commented 2 years ago

These are interesting observations. As my work builds on betaboon, the internal settings logics are pretty much the same. If you discover a wake up method, that's worth understanding and verifying. Please keep observing and reporting.

kongo09 commented 2 years ago

The WiFi firmware seems to be the latest from Philips.

I think the next bit to look into is the question why the preset modes are always empty. Before controlling anything, you should at least see the current data. Can you post a full log of the device response. It should be a show up if you enable debug logging in HA for the integration.

lwd1991 commented 2 years ago

Concerning: "Set preset" commands to "auto", "night", or "allergen" have no effect. As Im also using the AC1214 and experienced the same issue.

Found the following lines in Philips.py line 372

# TODO consolidate these classes as soon as we see a proper pattern
class PhilipsAC1214(PhilipsGenericCoAPFan):
    AVAILABLE_PRESET_MODES = {
        PRESET_MODE_AUTO: {PHILIPS_POWER: "1", PHILIPS_MODE: "P"},
        PRESET_MODE_ALLERGEN: {PHILIPS_POWER: "1", PHILIPS_MODE: "A"},
        # make speeds available as preset
        PRESET_MODE_NIGHT: {PHILIPS_POWER: "1", PHILIPS_MODE: "N"},
        SPEED_1: {PHILIPS_POWER: "1", PHILIPS_MODE: "M", PHILIPS_SPEED: "1"},
        SPEED_2: {PHILIPS_POWER: "1", PHILIPS_MODE: "M", PHILIPS_SPEED: "2"},
        SPEED_3: {PHILIPS_POWER: "1", PHILIPS_MODE: "M", PHILIPS_SPEED: "3"},
        PRESET_MODE_TURBO: {PHILIPS_POWER: "1", PHILIPS_MODE: "T", PHILIPS_SPEED: "t"},
    }
    AVAILABLE_SPEEDS = {
        PRESET_MODE_NIGHT: {PHILIPS_POWER: "1", PHILIPS_MODE: "N"},
        SPEED_1: {PHILIPS_POWER: "1", PHILIPS_MODE: "M", PHILIPS_SPEED: "1"},
        SPEED_2: {PHILIPS_POWER: "1", PHILIPS_MODE: "M", PHILIPS_SPEED: "2"},
        SPEED_3: {PHILIPS_POWER: "1", PHILIPS_MODE: "M", PHILIPS_SPEED: "3"},
        PRESET_MODE_TURBO: {PHILIPS_POWER: "1", PHILIPS_MODE: "T", PHILIPS_SPEED: "t"},
    }
    AVAILABLE_SWITCHES = [PHILIPS_CHILD_LOCK]

Removed: PHILIPS_POWER: "1" on all lines Changed for TURBO: PHILIPS_MODE: "T", to PHILIPS_MODE: "M",

I have no further knowledge on the subject, just edited this(trail and error) to get my automation working again and havent experienced any errors because of this change. Hope it may help!

Thanks for keeping the integration alive.

kongo09 commented 2 years ago

Found the following lines in Philips.py line 372

Yes, you find the right place where the specific settings for the AC1214 are defined :-)

The PHILIPS_POWER: "1" is supposed to make sure that the device can switch on should it be off when setting one of the modes. It feels strange that you remove it. Just to be clear: you eliminate that bit and when the device is off, you can still select a preset mode and the device switches on in that selected preset mode?

With your change for the TURBO mode, is the device then working as expected for TURBO? Other devices have the same pattern that you discovered. If you confirm that this works, I'll change it in the code.

kongo09 commented 2 years ago

@lwd1991 what might be insightful is if you enable debug logging or directly try to use aioairctrl from the command line to report back the answer message from the device for the various preset modes. Can you post that here?

lwd1991 commented 2 years ago

No, after removing PHILIPS_POWER: "1" device does not switch on when selecting preset. Observed the following:

For Turbo mode, in my case at least, I can confirm this change made it working again. Besides above mentioned for switching from AUTO or NIGHT.

Ill enable logging and try to use aioairctrl and get back to you when I have time. For me this remedy solves my issues, hopefully this helps you and the topic starter a bit. Thanks for your time.

kongo09 commented 2 years ago

Hm, very fascinating. Thanks for clarifying. That feels like switching on and selecting the preset have to be separate actions and cannot be done in one call.

With Turbo mode, I'll change the setting. If that breaks for other AC1214 owners, I'll probably hear from them ;-)

kongo09 commented 2 years ago

I'd like to bring some structure into this. As far as I understand, we have three issues and three hypotheses for solutions:

kongo09 commented 2 years ago

Can someone with an AC1214 please check v0.10.1-beta1214.2 and report back what works and what doesn't?

kine90 commented 2 years ago

Hi kongo09, thanks a lot for this release! It took a while but finally I had the time to test. The installation was smooth, first impressions are very positive. Everything is working out-of-the-box, except:

Tricky point: If the purifier goes into "Night mode" it remains stuck there. Whatever other mode you try to activate, the purifier blinks but does not execute the command, except for Auto. So, if the purifier is in Night mode and you want to change, i.e. to Turbo, first you have to recall Auto. Then you can switch to Turbo. Once known, one can script something to check the purifier mode and send an "Auto" command in case it needs to be awaken from being stuck into Night, but it would be nicer if this is implemented in the integration and happens in background. Unfortunately, this purifier comes with a light sensor, to set automatically Night mode under a certain brightness, so the chances to get stuck are hight.

However, brilliant work, this is the best Philips AC1214 integration I´ve tried so far. Thank you!

kine90 commented 2 years ago

After fewo hours it stopped working and never come back, even powercycling the purifier and HA. HA log gives the following errors:

Logger: homeassistant.components.fan
Source: custom_components/philips_airpurifier_coap/philips.py:151
Integration: Fan (documentation, issues)
First occurred: 1:24:14 PM (1 occurrences)
Last logged: 1:24:14 PM

Error while setting up philips_airpurifier_coap platform for fan
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/philips_airpurifier_coap/fan.py", line 41, in async_setup_entry
    device = model_class(
  File "/config/custom_components/philips_airpurifier_coap/philips.py", line 243, in __init__
    super().__init__(coordinator, model, name)
  File "/config/custom_components/philips_airpurifier_coap/philips.py", line 201, in __init__
    super().__init__(coordinator)
  File "/config/custom_components/philips_airpurifier_coap/philips.py", line 151, in __init__
    self._serialNumber = coordinator.status["DeviceId"]
TypeError: tuple indices must be integers or slices, not str

Logger: homeassistant.components.switch
Source: custom_components/philips_airpurifier_coap/philips.py:151
Integration: Switch (documentation, issues)
First occurred: 1:24:14 PM (1 occurrences)
Last logged: 1:24:14 PM

Error while setting up philips_airpurifier_coap platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/philips_airpurifier_coap/switch.py", line 67, in async_setup_entry
    switches.append(PhilipsSwitch(coordinator, name, model, switch))
  File "/config/custom_components/philips_airpurifier_coap/switch.py", line 88, in __init__
    super().__init__(coordinator)
  File "/config/custom_components/philips_airpurifier_coap/philips.py", line 151, in __init__
    self._serialNumber = coordinator.status["DeviceId"]
TypeError: tuple indices must be integers or slices, not str

Logger: homeassistant.components.light
Source: custom_components/philips_airpurifier_coap/philips.py:151
Integration: Light (documentation, issues)
First occurred: 1:24:14 PM (1 occurrences)
Last logged: 1:24:14 PM

Error while setting up philips_airpurifier_coap platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/philips_airpurifier_coap/light.py", line 72, in async_setup_entry
    lights.append(PhilipsLight(coordinator, name, model, light))
  File "/config/custom_components/philips_airpurifier_coap/light.py", line 93, in __init__
    super().__init__(coordinator)
  File "/config/custom_components/philips_airpurifier_coap/philips.py", line 151, in __init__
    self._serialNumber = coordinator.status["DeviceId"]
TypeError: tuple indices must be integers or slices, not str

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/philips_airpurifier_coap/config_flow.py:94
Integration: Philips AirPurifier (documentation, issues)
First occurred: 1:24:46 PM (1 occurrences)
Last logged: 1:24:46 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 222, in async_init
    flow, result = await task
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 249, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data, init_done)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/philips_airpurifier_coap/config_flow.py", line 94, in async_step_dhcp
    self._model = status['type']
TypeError: tuple indices must be integers or slices, not str
kongo09 commented 2 years ago

TypeError: tuple indices must be integers or slices, not str

This looks like a new error. I've never seen this before. Did you change anything in the last few days before it broke? Update of HA core maybe? Please file a new bug report for this.

kine90 commented 2 years ago

Yes, the update of HA core to version 2022.8.4 - August 12 seems to coincide with the moment I´ve lost the purifier. I´ve started a new issue. Thanks!

kine90 commented 1 year ago

The issue seems to be solved updating to the last version for AC1214/10. After one week of successful testing I made a pull request to merge it to the main branch. #52