Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions homeassistant/components/xiaomi_miio/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
FEATURE_SET_FAN_LEVEL,
FEATURE_SET_FAVORITE_LEVEL,
FEATURE_SET_FAVORITE_RPM,
FEATURE_SET_LED_BRIGHTNESS,
FEATURE_SET_LED_BRIGHTNESS_LEVEL,
FEATURE_SET_MOTOR_SPEED,
FEATURE_SET_OSCILLATION_ANGLE,
Expand Down Expand Up @@ -70,6 +71,7 @@
ATTR_FAN_LEVEL = "fan_level"
ATTR_FAVORITE_LEVEL = "favorite_level"
ATTR_FAVORITE_RPM = "favorite_rpm"
ATTR_LED_BRIGHTNESS = "led_brightness"
ATTR_LED_BRIGHTNESS_LEVEL = "led_brightness_level"
ATTR_MOTOR_SPEED = "motor_speed"
ATTR_OSCILLATION_ANGLE = "angle"
Expand Down Expand Up @@ -161,6 +163,16 @@ class OscillationAngleValues:
method="async_set_delay_off_countdown",
entity_category=ENTITY_CATEGORY_CONFIG,
),
FEATURE_SET_LED_BRIGHTNESS: XiaomiMiioNumberDescription(
key=ATTR_LED_BRIGHTNESS,
name="Led Brightness",
icon="mdi:brightness-6",
min_value=0,
max_value=100,
step=1,
method="async_set_led_brightness",
entity_category=ENTITY_CATEGORY_CONFIG,
),
FEATURE_SET_LED_BRIGHTNESS_LEVEL: XiaomiMiioNumberDescription(
key=ATTR_LED_BRIGHTNESS_LEVEL,
name="Led Brightness",
Expand Down Expand Up @@ -244,6 +256,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
description.max_value = OSCILLATION_ANGLE_VALUES[model].max_value
description.min_value = OSCILLATION_ANGLE_VALUES[model].min_value
description.step = OSCILLATION_ANGLE_VALUES[model].step

entities.append(
XiaomiNumberEntity(
f"{config_entry.title} {description.name}",
Expand Down Expand Up @@ -354,6 +367,14 @@ async def async_set_led_brightness_level(self, level: int):
level,
)

async def async_set_led_brightness(self, level: int):
"""Set the led brightness level."""
return await self._try_command(
"Setting the led brightness level of the miio device failed.",
self._device.set_led_brightness,
level,
)

async def async_set_favorite_rpm(self, rpm: int):
"""Set the target motor speed."""
return await self._try_command(
Expand Down