betaboon / philips-airpurifier-coap

💨 Philips AirPurifier custom component for Home Assistant. With support for new Devices with CoAP protocol. Tested on AC2729/10 (bought early 2020)
70 stars 31 forks source link

Setting preset not working for non numeric preset on ac1214 #41

Open SgtZapper opened 3 years ago

SgtZapper commented 3 years ago

Noticed that setting speed 1,2,3 works but no other preset on the AC1214/10.

I'm running on: Home Assistant OS 5.13 supervisor-2021.04.0 core-2021.4.5

Got it to work by crudely changing the async_set_preset_mode method in fan.py to the code below so that it sets the data individually. I looked in the client and see no real reason the original commented code should not work. (I'm bad with python just fyi).

async def async_set_preset_mode(self, preset_mode: str) -> None:
        """Set the preset mode of the fan."""
        status_pattern = self._available_preset_modes.get(preset_mode)
        if status_pattern:
             """Set the values one by one."""
            await self._client.set_control_value(PHILIPS_POWER, "1")
            await self._client.set_control_value(PHILIPS_MODE, status_pattern.get(PHILIPS_MODE))
            if status_pattern.get(PHILIPS_SPEED):
                await self._client.set_control_value(PHILIPS_SPEED, status_pattern.get(PHILIPS_SPEED))

#original code            await self._client.set_control_values(data=status_pattern)

It works but it doesn't report back turbo when setting it to turbo mode the attribute just becomes blank.

SamJongenelen commented 3 years ago

I have the same model and same issue; setting int value works but string doesn't

MSOHD commented 3 years ago

I also have that problem. But sadly your fix doesn't help me at all. Do I have to pay attention to something special? Can you please show your whole fan.py ? That would help me a lot :)

SgtZapper commented 2 years ago

I might have ran HACS and deleted my changes and my purifier is in for service atm (it started showing high values then it was dead) so I have nothing to test against. Will test when I get it back. But I'm sure my solution was a permanent one.

kongo09 commented 2 years ago

I've tried my hand at a rewrite. Please let me know if that works for you.