Adjust the fan entity icon to it's state in ViCare integration (#131553)

This commit is contained in:
Christopher Fenner 2024-11-26 10:46:12 +01:00 committed by GitHub
parent d587e71f8d
commit 0b7fbe1d17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View File

@ -173,6 +173,30 @@ class ViCareFan(ViCareEntity, FanEntity):
# Viessmann ventilation unit cannot be turned off
return True
@property
def icon(self) -> str | None:
"""Return the icon to use in the frontend."""
if hasattr(self, "_attr_preset_mode"):
if self._attr_preset_mode == VentilationMode.VENTILATION:
return "mdi:fan-clock"
if self._attr_preset_mode in [
VentilationMode.SENSOR_DRIVEN,
VentilationMode.SENSOR_OVERRIDE,
]:
return "mdi:fan-auto"
if self._attr_preset_mode == VentilationMode.PERMANENT:
if self._attr_percentage == 0:
return "mdi:fan-off"
if self._attr_percentage is not None:
level = 1 + ORDERED_NAMED_FAN_SPEEDS.index(
percentage_to_ordered_list_item(
ORDERED_NAMED_FAN_SPEEDS, self._attr_percentage
)
)
if level < 4: # fan-speed- only supports 1-3
return f"mdi:fan-speed-{level}"
return "mdi:fan"
def set_percentage(self, percentage: int) -> None:
"""Set the speed of the fan, as a percentage."""
if self._attr_preset_mode != str(VentilationMode.PERMANENT):

View File

@ -29,7 +29,7 @@
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_icon': 'mdi:fan',
'original_name': 'Ventilation',
'platform': 'vicare',
'previous_unique_id': None,
@ -43,6 +43,7 @@
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'model0 Ventilation',
'icon': 'mdi:fan',
'percentage': 0,
'percentage_step': 25.0,
'preset_mode': None,