mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 13:45:12 +02:00
only show supported presets
This commit is contained in:
@@ -104,23 +104,17 @@ async def async_setup_entry(
|
|||||||
ViCareFan(get_device_serial(device.api), device.config, device.api)
|
ViCareFan(get_device_serial(device.api), device.config, device.api)
|
||||||
for device in device_list
|
for device in device_list
|
||||||
if isinstance(device.api, PyViCareVentilationDevice)
|
if isinstance(device.api, PyViCareVentilationDevice)
|
||||||
]
|
],
|
||||||
|
True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ViCareFan(ViCareEntity, FanEntity):
|
class ViCareFan(ViCareEntity, FanEntity):
|
||||||
"""Representation of the ViCare ventilation device."""
|
"""Representation of the ViCare ventilation device."""
|
||||||
|
|
||||||
_attr_preset_modes = list[str](
|
_attr_preset_modes: list[str] | None = None
|
||||||
[
|
|
||||||
VentilationMode.PERMANENT,
|
|
||||||
VentilationMode.VENTILATION,
|
|
||||||
VentilationMode.SENSOR_DRIVEN,
|
|
||||||
VentilationMode.SENSOR_OVERRIDE,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
||||||
_attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE
|
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||||
_attr_translation_key = "ventilation"
|
_attr_translation_key = "ventilation"
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
_enable_turn_on_off_backwards_compatibility = False
|
||||||
|
|
||||||
@@ -137,6 +131,18 @@ class ViCareFan(ViCareEntity, FanEntity):
|
|||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state of fan."""
|
"""Update state of fan."""
|
||||||
|
|
||||||
|
# init presets
|
||||||
|
if self._attr_preset_modes is None:
|
||||||
|
supported_modes = list[str](self._api.getAvailableModes())
|
||||||
|
self._attr_preset_modes = [
|
||||||
|
mode
|
||||||
|
for mode in VentilationMode
|
||||||
|
if VentilationMode.to_vicare_mode(mode) in supported_modes
|
||||||
|
]
|
||||||
|
if len(self._attr_preset_modes) > 0:
|
||||||
|
self._attr_supported_features |= FanEntityFeature.PRESET_MODE
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with suppress(PyViCareNotSupportedFeatureError):
|
with suppress(PyViCareNotSupportedFeatureError):
|
||||||
self._attr_preset_mode = VentilationMode.from_vicare_mode(
|
self._attr_preset_mode = VentilationMode.from_vicare_mode(
|
||||||
|
Reference in New Issue
Block a user