mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix Quickmode handling in ViCare integration (#142561)
* only check quickmode if supported * update snapshot * revert
This commit is contained in:
parent
816edb66c7
commit
76015740f8
@ -127,6 +127,7 @@ class ViCareFan(ViCareEntity, FanEntity):
|
|||||||
|
|
||||||
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
||||||
_attr_translation_key = "ventilation"
|
_attr_translation_key = "ventilation"
|
||||||
|
_attributes: dict[str, Any] = {}
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -155,7 +156,7 @@ class ViCareFan(ViCareEntity, FanEntity):
|
|||||||
self._attr_supported_features |= FanEntityFeature.SET_SPEED
|
self._attr_supported_features |= FanEntityFeature.SET_SPEED
|
||||||
|
|
||||||
# evaluate quickmodes
|
# evaluate quickmodes
|
||||||
quickmodes: list[str] = (
|
self._attributes["vicare_quickmodes"] = quickmodes = list[str](
|
||||||
device.getVentilationQuickmodes()
|
device.getVentilationQuickmodes()
|
||||||
if is_supported(
|
if is_supported(
|
||||||
"getVentilationQuickmodes",
|
"getVentilationQuickmodes",
|
||||||
@ -196,26 +197,23 @@ class ViCareFan(ViCareEntity, FanEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self) -> bool | None:
|
def is_on(self) -> bool | None:
|
||||||
"""Return true if the entity is on."""
|
"""Return true if the entity is on."""
|
||||||
if (
|
if VentilationQuickmode.STANDBY in self._attributes[
|
||||||
self._attr_supported_features & FanEntityFeature.TURN_OFF
|
"vicare_quickmodes"
|
||||||
and self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY)
|
] and self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY):
|
||||||
):
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return self.percentage is not None and self.percentage > 0
|
return self.percentage is not None and self.percentage > 0
|
||||||
|
|
||||||
def turn_off(self, **kwargs: Any) -> None:
|
def turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the entity off."""
|
"""Turn the entity off."""
|
||||||
|
|
||||||
self._api.activateVentilationQuickmode(str(VentilationQuickmode.STANDBY))
|
self._api.activateVentilationQuickmode(str(VentilationQuickmode.STANDBY))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str | None:
|
def icon(self) -> str | None:
|
||||||
"""Return the icon to use in the frontend."""
|
"""Return the icon to use in the frontend."""
|
||||||
if (
|
if VentilationQuickmode.STANDBY in self._attributes[
|
||||||
self._attr_supported_features & FanEntityFeature.TURN_OFF
|
"vicare_quickmodes"
|
||||||
and self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY)
|
] and self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY):
|
||||||
):
|
|
||||||
return "mdi:fan-off"
|
return "mdi:fan-off"
|
||||||
if hasattr(self, "_attr_preset_mode"):
|
if hasattr(self, "_attr_preset_mode"):
|
||||||
if self._attr_preset_mode == VentilationMode.VENTILATION:
|
if self._attr_preset_mode == VentilationMode.VENTILATION:
|
||||||
@ -242,7 +240,9 @@ class ViCareFan(ViCareEntity, FanEntity):
|
|||||||
"""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):
|
||||||
self.set_preset_mode(VentilationMode.PERMANENT)
|
self.set_preset_mode(VentilationMode.PERMANENT)
|
||||||
elif self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY):
|
elif VentilationQuickmode.STANDBY in self._attributes[
|
||||||
|
"vicare_quickmodes"
|
||||||
|
] and self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY):
|
||||||
self._api.deactivateVentilationQuickmode(str(VentilationQuickmode.STANDBY))
|
self._api.deactivateVentilationQuickmode(str(VentilationQuickmode.STANDBY))
|
||||||
|
|
||||||
level = percentage_to_ordered_list_item(ORDERED_NAMED_FAN_SPEEDS, percentage)
|
level = percentage_to_ordered_list_item(ORDERED_NAMED_FAN_SPEEDS, percentage)
|
||||||
@ -254,3 +254,8 @@ class ViCareFan(ViCareEntity, FanEntity):
|
|||||||
target_mode = VentilationMode.to_vicare_mode(preset_mode)
|
target_mode = VentilationMode.to_vicare_mode(preset_mode)
|
||||||
_LOGGER.debug("changing ventilation mode to %s", target_mode)
|
_LOGGER.debug("changing ventilation mode to %s", target_mode)
|
||||||
self._api.activateVentilationMode(target_mode)
|
self._api.activateVentilationMode(target_mode)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
|
"""Show Device Attributes."""
|
||||||
|
return self._attributes
|
||||||
|
@ -55,6 +55,11 @@
|
|||||||
<VentilationMode.SENSOR_OVERRIDE: 'sensor_override'>,
|
<VentilationMode.SENSOR_OVERRIDE: 'sensor_override'>,
|
||||||
]),
|
]),
|
||||||
'supported_features': <FanEntityFeature: 9>,
|
'supported_features': <FanEntityFeature: 9>,
|
||||||
|
'vicare_quickmodes': list([
|
||||||
|
'comfort',
|
||||||
|
'eco',
|
||||||
|
'holiday',
|
||||||
|
]),
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'fan.model0_ventilation',
|
'entity_id': 'fan.model0_ventilation',
|
||||||
@ -94,7 +99,7 @@
|
|||||||
'options': dict({
|
'options': dict({
|
||||||
}),
|
}),
|
||||||
'original_device_class': None,
|
'original_device_class': None,
|
||||||
'original_icon': 'mdi:fan-off',
|
'original_icon': 'mdi:fan',
|
||||||
'original_name': 'Ventilation',
|
'original_name': 'Ventilation',
|
||||||
'platform': 'vicare',
|
'platform': 'vicare',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
@ -108,7 +113,7 @@
|
|||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'model1 Ventilation',
|
'friendly_name': 'model1 Ventilation',
|
||||||
'icon': 'mdi:fan-off',
|
'icon': 'mdi:fan',
|
||||||
'percentage': 0,
|
'percentage': 0,
|
||||||
'percentage_step': 25.0,
|
'percentage_step': 25.0,
|
||||||
'preset_mode': None,
|
'preset_mode': None,
|
||||||
@ -118,6 +123,11 @@
|
|||||||
<VentilationMode.SENSOR_DRIVEN: 'sensor_driven'>,
|
<VentilationMode.SENSOR_DRIVEN: 'sensor_driven'>,
|
||||||
]),
|
]),
|
||||||
'supported_features': <FanEntityFeature: 25>,
|
'supported_features': <FanEntityFeature: 25>,
|
||||||
|
'vicare_quickmodes': list([
|
||||||
|
'comfort',
|
||||||
|
'eco',
|
||||||
|
'holiday',
|
||||||
|
]),
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'fan.model1_ventilation',
|
'entity_id': 'fan.model1_ventilation',
|
||||||
@ -179,6 +189,11 @@
|
|||||||
<VentilationMode.STANDARD: 'standard'>,
|
<VentilationMode.STANDARD: 'standard'>,
|
||||||
]),
|
]),
|
||||||
'supported_features': <FanEntityFeature: 8>,
|
'supported_features': <FanEntityFeature: 8>,
|
||||||
|
'vicare_quickmodes': list([
|
||||||
|
'comfort',
|
||||||
|
'eco',
|
||||||
|
'holiday',
|
||||||
|
]),
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'fan.model2_ventilation',
|
'entity_id': 'fan.model2_ventilation',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user