Exemple #1
0
 async def async_set_preset_mode(self, preset_mode: str) -> None:
     """Set the preset mode for the fan."""
     if preset_mode not in self.preset_modes:
         raise NotValidPresetModeError(
             f"The preset_mode {preset_mode} is not a valid preset_mode: {self.preset_modes}"
         )
     await self._async_set_fan_mode(IKEA_NAME_TO_PRESET_MODE[preset_mode])
Exemple #2
0
 def set_preset_mode(self, preset_mode: Optional[str]) -> None:
     """Configure the preset mode."""
     if preset_mode is None:
         self._device.disable_auto_mode()
     elif preset_mode == PRESET_MODE_AUTO:
         self._device.enable_auto_mode()
     else:
         raise NotValidPresetModeError(
             f"Invalid preset mode: {preset_mode}")
Exemple #3
0
    async def async_set_preset_mode(self, preset_mode: str) -> None:
        """Set new preset mode."""
        for zwave_value, mapped_preset_mode in self.fan_value_mapping.presets.items(
        ):
            if preset_mode == mapped_preset_mode:
                await self.info.node.async_set_value(self._target_value,
                                                     zwave_value)
                return

        raise NotValidPresetModeError(
            f"The preset_mode {preset_mode} is not a valid preset_mode: {self.preset_modes}"
        )
Exemple #4
0
            raise HomeAssistantError("Missing target value on device.")
        zwave_speed = self.percentage_to_zwave_speed(percentage)
        await self.info.node.async_set_value(target_value, zwave_speed)

    async def async_set_preset_mode(self, preset_mode: str) -> None:
        """Set new preset mode."""
        if (target_value := self._target_value) is None:
            raise HomeAssistantError("Missing target value on device.")
        for zwave_value, mapped_preset_mode in self.fan_value_mapping.presets.items(
        ):
            if preset_mode == mapped_preset_mode:
                await self.info.node.async_set_value(target_value, zwave_value)
                return

        raise NotValidPresetModeError(
            f"The preset_mode {preset_mode} is not a valid preset_mode: {self.preset_modes}"
        )

    @property
    def available(self) -> bool:
        """Return whether the entity is available."""
        return super().available and self.has_fan_value_mapping

    @property
    def percentage(self) -> int | None:
        """Return the current speed percentage."""
        if self.info.primary_value.value is None:
            # guard missing value
            return None

        if self.preset_mode is not None: