mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 21:25:13 +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)
|
||||
for device in device_list
|
||||
if isinstance(device.api, PyViCareVentilationDevice)
|
||||
]
|
||||
],
|
||||
True,
|
||||
)
|
||||
|
||||
|
||||
class ViCareFan(ViCareEntity, FanEntity):
|
||||
"""Representation of the ViCare ventilation device."""
|
||||
|
||||
_attr_preset_modes = list[str](
|
||||
[
|
||||
VentilationMode.PERMANENT,
|
||||
VentilationMode.VENTILATION,
|
||||
VentilationMode.SENSOR_DRIVEN,
|
||||
VentilationMode.SENSOR_OVERRIDE,
|
||||
]
|
||||
)
|
||||
_attr_preset_modes: list[str] | None = None
|
||||
_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"
|
||||
_enable_turn_on_off_backwards_compatibility = False
|
||||
|
||||
@@ -137,6 +131,18 @@ class ViCareFan(ViCareEntity, FanEntity):
|
||||
|
||||
def update(self) -> None:
|
||||
"""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:
|
||||
with suppress(PyViCareNotSupportedFeatureError):
|
||||
self._attr_preset_mode = VentilationMode.from_vicare_mode(
|
||||
|
Reference in New Issue
Block a user