mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 19:27: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
|
# Viessmann ventilation unit cannot be turned off
|
||||||
return True
|
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:
|
def set_percentage(self, percentage: int) -> None:
|
||||||
"""Set the speed of the fan, as a percentage."""
|
"""Set the speed of the fan, as a percentage."""
|
||||||
if self._attr_preset_mode != str(VentilationMode.PERMANENT):
|
if self._attr_preset_mode != str(VentilationMode.PERMANENT):
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
'options': dict({
|
'options': dict({
|
||||||
}),
|
}),
|
||||||
'original_device_class': None,
|
'original_device_class': None,
|
||||||
'original_icon': None,
|
'original_icon': 'mdi:fan',
|
||||||
'original_name': 'Ventilation',
|
'original_name': 'Ventilation',
|
||||||
'platform': 'vicare',
|
'platform': 'vicare',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
@ -43,6 +43,7 @@
|
|||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'model0 Ventilation',
|
'friendly_name': 'model0 Ventilation',
|
||||||
|
'icon': 'mdi:fan',
|
||||||
'percentage': 0,
|
'percentage': 0,
|
||||||
'percentage_step': 25.0,
|
'percentage_step': 25.0,
|
||||||
'preset_mode': None,
|
'preset_mode': None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user