async def async_set_percentage(self, percentage: int) -> None: """Set the percentage of the fan. This method is a coroutine. """ percentage_payload = math.ceil( percentage_to_ranged_value(self._speed_range, percentage)) mqtt_payload = self._command_templates[ATTR_PERCENTAGE]( percentage_payload) # Legacy are deprecated in the schema, support will be removed after a quarter (2021.7) if self._feature_legacy_speeds: if percentage: await self.async_set_speed( percentage_to_ordered_list_item( self._legacy_speeds_list_no_off, percentage, )) elif SPEED_OFF in self._legacy_speeds_list: await self.async_set_speed(SPEED_OFF) if self._feature_percentage: mqtt.async_publish( self.hass, self._topic[CONF_PERCENTAGE_COMMAND_TOPIC], mqtt_payload, self._config[CONF_QOS], self._config[CONF_RETAIN], ) if self._optimistic_percentage: self._percentage = percentage self.async_write_ha_state()
async def async_set_percentage(self, percentage: int | None) -> None: """Set the speed percenage of the fan.""" if percentage is None: percentage = 0 fan_mode = math.ceil( percentage_to_ranged_value(IKEA_SPEED_RANGE, percentage)) await self._async_set_fan_mode(fan_mode)
async def async_set_percentage(self, percentage: Optional[int]) -> None: """Set the speed percentage of the pump.""" if percentage is None: setto = self._speed_range[0] else: setto = math.ceil(percentage_to_ranged_value(self._speed_range, percentage)) await self._client.change_pump(self._num - 1, setto)
async def async_set_percentage(self, percentage: int) -> None: """Set the speed of the fan, as a percentage.""" if self._step_range: step = math.ceil(percentage_to_ranged_value(self._step_range, percentage)) await self._device.set_speed(step) else: await self._device.set_speed(percentage)
def brightness(self) -> int | None: """Return the brightness of this light between 1..255.""" return round( percentage_to_ranged_value( BRIGHTNESS_RANGE, self.coordinator.data.state.light_brightness ) )
async def async_set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan.""" if percentage == 0: await self.async_turn_off() return on_level = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage)) await self._insteon_device.async_on(group=2, on_level=on_level)
def turn_on(self, percentage: Optional[int] = None, **kwargs) -> None: """Turn on the fan.""" value_in_range = math.ceil( percentage_to_ranged_value(SPEED_RANGE, percentage)) if percentage == "0": self.turn_off() client = self._hass.data[MIELE_DOMAIN][DATA_CLIENT] client.action(device_id=self.device_id, body={"powerOn": True})
def set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan.""" if percentage == 0: self.turn_off() return dyson_speed = INT_VALUE_TO_DYSON_SPEED[math.ceil( percentage_to_ranged_value(SPEED_RANGE, percentage))] self.set_dyson_speed(dyson_speed)
async def async_set_percentage(self, percentage: int) -> None: """Set node to speed percentage for the ISY994 fan device.""" if percentage == 0: await self._node.turn_off() return isy_speed = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage)) await self._node.turn_on(val=isy_speed)
async def async_set_percentage(self, percentage: int) -> None: """Set the speed of the fan.""" if percentage == 0: return await self.async_turn_off() await self.async_put_characteristics({ CharacteristicsTypes.ROTATION_SPEED: round(percentage_to_ranged_value(self._speed_range, percentage)) })
def translate_humidity(self, humidity): """Translate the target humidity to the first valid step.""" return ( math.ceil(percentage_to_ranged_value((1, self._humidity_steps), humidity)) * 100 / self._humidity_steps if 0 < humidity <= 100 else None )
async def async_set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan.""" # value_in_range = math.ceil( percentage_to_ranged_value(SPEED_RANGE, percentage)) self._current_speed = value_in_range _LOGGER.debug("Setting speed to : {}".format(value_in_range)) client = self._hass.data[MIELE_DOMAIN][DATA_CLIENT] await client.action(device_id=self.device_id, body={"ventilationStep": value_in_range})
def set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan.""" if percentage == 0: self._device.turn_off() return dyson_speed = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage)) self._device.set_speed(dyson_speed) self._device.disable_auto_mode()
async def async_set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan.""" if percentage == 0: zwave_speed = 0 else: zwave_speed = math.ceil( percentage_to_ranged_value(DEFAULT_SPEED_RANGE, percentage)) await self.info.node.async_set_value(self._target_value, zwave_speed)
async def async_set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan.""" if percentage == 0: zwave_speed = 0 else: zwave_speed = math.ceil( percentage_to_ranged_value(DEFAULT_SPEED_RANGE, percentage)) if (target_value := self._target_value) is None: raise HomeAssistantError("Missing target value on device.")
async def async_set_percentage(self, percentage: int) -> None: """Set the speed of the fan, as a percentage.""" if percentage == 0: self._fan.set_state_off() return if not self._fan.state == 'on': self._fan.set_state_on() self._fan.set_speed( math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage))) self.async_write_ha_state()
def _set_percentage(self, percentage: int | None) -> None: if percentage is None: named_speed = self._last_fan_on_mode elif percentage == 0: named_speed = FanMode.Off else: named_speed = FanMode( math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage))) with self._wemo_call_wrapper("set speed"): self.wemo.set_state(named_speed)
def set_percentage(self, percentage): """Set the speed percentage of the fan.""" if percentage is None: # Value 255 tells device to return to previous value zwave_speed = 255 elif percentage == 0: zwave_speed = 0 else: zwave_speed = math.ceil( percentage_to_ranged_value(SPEED_RANGE, percentage)) self.node.set_dimmer(self.values.primary.value_id, zwave_speed)
def set_percentage(self, percentage: int): """Set the speed of the fan.""" if not bool(percentage): self._fan.is_on = False try: self._fan.speed = math.ceil( percentage_to_ranged_value( (self._minimum_speed, self._fan.max_speed), percentage)) except (airscape.exceptions.ConnectionError, airscape.exceptions.Timeout): self._available = False
def set_percentage(self, percentage: int) -> None: """Set fan speed percentage.""" _LOGGER.debug("Changing fan speed percentage to %s", percentage) if percentage == 0: cmd = CMD_FAN_MODE_AWAY else: speed = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage)) cmd = CMD_MAPPING[speed] self._ccb.comfoconnect.cmd_rmi_request(cmd)
async def async_set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan.""" if percentage is None: await self._device.switch_on(set_status=True) elif percentage == 0: await self._device.switch_off(set_status=True) else: value = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage)) await self._device.set_fan_speed(value, set_status=True) # State is set optimistically in the command above, therefore update # the entity state ahead of receiving the confirming push updates self.async_write_ha_state()
async def async_set_percentage(self, percentage: int) -> None: """Set the percentage of the fan. This method is a coroutine. """ fan_level = math.ceil(percentage_to_ranged_value((1, 3), percentage)) if fan_level: await self._try_command( "Setting fan level of the miio device failed.", self._device.set_fan_level, fan_level, )
def set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan.""" _LOGGER.debug("Changing fan speed percentage to %s", percentage) if percentage == 0 or percentage == None: self.device.powerOff() else: speed = math.ceil( percentage_to_ranged_value(SPEED_RANGE, percentage)) self.device.setSpeed(speed) dispatcher_send(self.hass, SIGNAL_UPDATE_PRANA + self.device.mac)
def set_percentage(self, percentage: int) -> None: """Set the fan_mode of the Humidifier.""" if percentage is None: named_speed = self._last_fan_on_mode elif percentage == 0: named_speed = WEMO_FAN_OFF else: named_speed = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage)) with self._wemo_exception_handler("set speed"): self.wemo.set_state(named_speed) self.schedule_update_ha_state()
async def async_turn_on( self, percentage: int | None = None, preset_mode: int | None = None, **kwargs: Any, ) -> None: """Turn on the fan.""" data = {OPT_ON: FAN_POWER_ON} if percentage: data[OPT_SPEED] = round( percentage_to_ranged_value(self.SPEED_RANGE, percentage)) await self.coordinator.modern_forms.fan(**data)
async def async_set_percentage(self, percentage: int) -> None: """Set the percentage of the fan. This method is a coroutine. """ speed_mode = math.ceil( percentage_to_ranged_value((1, self._speed_count), percentage)) if speed_mode: await self._try_command( "Setting operation mode of the miio device failed.", self._device.set_mode, AirpurifierOperationMode(self.SPEED_MODE_MAPPING[speed_mode]), )
async def async_set_percentage(self, percentage: int | None) -> None: """Set the speed percentage of the fan.""" target_value = self.get_zwave_value("targetValue") if percentage is None: # Value 255 tells device to return to previous value zwave_speed = 255 elif percentage == 0: zwave_speed = 0 else: zwave_speed = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage)) await self.info.node.async_set_value(target_value, zwave_speed)
def set_percentage(self, percentage): """Set the speed of the device.""" if percentage == 0: self.smartfan.turn_off() return if not self.smartfan.is_on: self.smartfan.turn_on() self.smartfan.manual_mode() self.smartfan.change_fan_speed( math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage))) self.schedule_update_ha_state()
async def async_set_percentage(self, percentage): """Set the speed of the fan.""" _LOGGER.debug("Fan async_set_percentage: %s", percentage) if percentage is not None: if percentage == 0: return await self.async_turn_off() if not self.is_on: await self.async_turn_on() if self._use_ordered_list: await self._device.set_dp( str( percentage_to_ordered_list_item( self._ordered_list, percentage)), self._config.get(CONF_FAN_SPEED_CONTROL), ) _LOGGER.debug( "Fan async_set_percentage: %s > %s", percentage, percentage_to_ordered_list_item(self._ordered_list, percentage), ) else: await self._device.set_dp( str( math.ceil( percentage_to_ranged_value(self._speed_range, percentage))), self._config.get(CONF_FAN_SPEED_CONTROL), ) _LOGGER.debug( "Fan async_set_percentage: %s > %s", percentage, percentage_to_ranged_value(self._speed_range, percentage), ) self.schedule_update_ha_state()
def set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan.""" _LOGGER.debug("Set the fan percentage to %s", percentage) if percentage == 0: self.turn_off() return fan_speed = math.ceil( percentage_to_ranged_value(SPEED_RANGE, percentage)) if not self._smarty.set_fan_speed(fan_speed): raise HomeAssistantError( f"Failed to set the fan speed percentage to {percentage}") self._smarty_fan_speed = fan_speed self.schedule_update_ha_state()