mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Adjust the fan entity icon to it's state in ViCare integration (#131553)
This commit is contained in:
parent
d587e71f8d
commit
0b7fbe1d17
@ -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):
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user