JohNan / homeassistant-wellbeing

Get the status from your Electrolux devices connected to Wellbeing
MIT License
83 stars 23 forks source link

Pure 500 “Auto” does not work although it has smart mode also #120

Open andrecunha-sb opened 2 months ago

andrecunha-sb commented 2 months ago

image

JohNan commented 2 months ago

Thank you. I'm working on different Workmodes depending on the model. I'll let you know when I have something ready.

andrebcunha commented 2 months ago

If you need more info, just as :) Thanks for your good work

JohNan commented 2 months ago

If you need more info, just as :) Thanks for your good work

Yes please, logs would be great to have. Enabled debug logs and post them here.

andrebcunha commented 2 months ago

API RESPONSE FOR PURE500

{"applianceInfo":{"serialNumber":"32000570","pnc":"950011631","brand":"ELECTROLUX","deviceType":"AIR_PURIFIER","model":"PURE500","variant":"TM5","colour":"SHELL_WHITE"},"capabilities":{"ErrCommSensorDisplayBrd":{"access":"read","type":"string","values":{"active":{},"not active":{},"was active":{}}},"ErrImpellerStuck":{"access":"read","type":"string","values":{"active":{},"not active":{},"was active":{}}},"ErrPmNotResp":{"access":"read","type":"string","values":{"active":{},"not active":{},"was active":{}}},"Fanspeed":{"access":"readwrite","max":3,"min":1,"schedulable":true,"step":1,"type":"int"},"FilterLife_1":{"access":"read","max":100,"min":0,"type":"int"},"SafetyLock":{"access":"readwrite","default":false,"type":"boolean","values":{"False":{},"True":{}}},"SchedulingState":{"access":"read","type":"string","values":{"aborted":{},"done":{},"not set":{},"ongoing":{}}},"SignalStrength":{"access":"read","type":"string","values":{"EXCELLENT":{},"FAIR":{},"GOOD":{},"WEAK":{}}},"UILight":{"access":"readwrite","default":true,"schedulable":true,"type":"boolean","values":{"False":{},"True":{}}},"Workmode":{"access":"readwrite","schedulable":true,"triggers":[{"action":{"Fanspeed":{"access":"readwrite","disabled":true,"max":3,"min":1,"step":1,"type":"int"}},"condition":{"operand_1":"value","operand_2":"Smart","operator":"eq"}},{"action":{"Fanspeed":{"access":"readwrite","max":3,"min":1,"step":1,"type":"int"}},"condition":{"operand_1":"value","operand_2":"Manual","operator":"eq"}},{"action":{"Fanspeed":{"access":"readwrite","disabled":true,"max":2,"min":1,"step":1,"type":"int"}},"condition":{"operand_1":"value","operand_2":"Quiet","operator":"eq"}},{"action":{"Fanspeed":{"access":"readwrite","disabled":true,"type":"int"},"SafetyLock":{"access":"readwrite","default":false,"disabled":true,"type":"boolean","values":{"False":{},"True":{}}},"UILight":{"access":"readwrite","default":false,"disabled":true,"type":"boolean","values":{"False":{},"True":{}}}},"condition":{"operand_1":"value","operand_2":"PowerOff","operator":"eq"}}],"type":"string","values":{"Manual":{},"PowerOff":{},"Quiet":{},"Smart":{}}}}}%

andrebcunha commented 2 months ago

For comparison, the A9:

{"applianceInfo":{"serialNumber":"11100498","pnc":"950011384","brand":"ELECTROLUX","deviceType":"AIR_PURIFIER","model":"A9","variant":"CADR400","colour":"DARKGREY"},"capabilities":{"PM1":{"access":"read","max":65535,"min":0,"step":1,"type":"number"},"PM10":{"access":"read","max":65535,"min":0,"step":1,"type":"number"},"PM2_5":{"access":"read","max":65535,"min":0,"step":1,"type":"number"},"TVOC":{"access":"read","max":4295,"min":0,"step":1,"type":"number"},"Fanspeed":{"access":"readwrite","max":9,"min":1,"schedulable":true,"step":1,"type":"int"},"Workmode":{"access":"readwrite","schedulable":true,"triggers":[{"action":{"Fanspeed":{"access":"readwrite","disabled":true,"max":9,"min":1,"step":1,"type":"int"}},"condition":{"operand_1":"value","operand_2":"Auto","operator":"eq"}},{"action":{"Fanspeed":{"access":"readwrite","max":9,"min":1,"step":1,"type":"int"}},"condition":{"operand_1":"value","operand_2":"Manual","operator":"eq"}},{"action":{"Fanspeed":{"access":"readwrite","disabled":true,"type":"int"}},"condition":{"operand_1":"value","operand_2":"PowerOff","operator":"eq"}}],"type":"string","values":{"Manual":{},"PowerOff":{},"Auto":{}}}}}%

andrebcunha commented 2 months ago

I can provide a bit of context here. As of now, the fan control is shaky and the modes do not seem to work well in the HA integration. The Pure 500 (Muju) has only 3(4 if you count off) speeds (low, medium, high) at around 33, 66 and 100%. The quiet mode is actually an option of the smart mode. The difference is, quiet mode limits smart mode to speed 2. Speed 3 is very noisy compared to higher end models.

andrebcunha commented 2 months ago
def speed_range(self) -> tuple[int, int]:
    ## Electrolux Devices:
    if self.model == Model.Muju:
        if self.mode is WorkMode.QUITE:
            return 1, 2
        return 1, 5

This should be

def speed_range(self) -> tuple[int, int]:
    ## Electrolux Devices:
    if self.model == Model.Muju:
        if self.mode is WorkMode.QUITE:
            return 1, 2
        return 1, 3

I think :)

andrebcunha commented 2 months ago
def percentage(self):
    """Return the current speed percentage."""
    if self._preset_mode == WorkMode.OFF:
        return 0  # If the fan is off, return 0%

    speed = self._speed if self.get_entity.state is None else self.get_entity.state

    # Custom mapping for devices with speed range 1 to 3
    if self._speed_range == (1, 3):
        if speed == 1:
            percentage = 33
        elif speed == 2:
            percentage = 66
        elif speed == 3:
            percentage = 100
        else:
            percentage = 0  # Default to 0 if the speed is outside the known range
    else:
        # Use old method for other devices
        percentage = ranged_value_to_percentage(self._speed_range, speed)

    _LOGGER.debug(f"percentage - speed: {speed} percentage: {percentage}")
    return percentage

async def async_set_percentage(self, percentage: int) -> None:
    """Set the speed percentage of the fan."""

    if self._speed_range == (1, 3):
        # Custom mapping for devices with speed range 1 to 3
        if percentage <= 33:
            self._speed = 1
        elif percentage <= 66:
            self._speed = 2
        else:
            self._speed = 3
    else:
        # Use old method for other devices
        self._speed = math.floor(percentage_to_ranged_value(self._speed_range, percentage))

    self.get_entity.clear_state()
    self.async_write_ha_state()

    _LOGGER.debug(f"async_set_percentage - speed: {self._speed} percentage: {percentage}")

    if percentage == 0:
        await self.async_turn_off()
        return

    # If not in manual mode, switch to manual before setting speed
    if self._preset_mode != WorkMode.MANUAL:
        _LOGGER.info("Switching to Manual mode due to user speed change.")
        await self.async_set_preset_mode(WorkMode.MANUAL.value)

    await self.api.set_fan_speed(self.pnc_id, self._speed)

    self.async_write_ha_state()
    await asyncio.sleep(10)
    await self.coordinator.async_request_refresh()
andrebcunha commented 2 months ago

After my own testing, something might be wrong with their side regarding the smart mode. For now, I just use quiet mode as it implicitly enables smart mode.