mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Fix vicare exception for specific ventilation device type (#138343)
* fix for exception for specific ventilation device type + tests * fix for exception for specific ventilation device type + tests * New Testset just for fan * update test_sensor.ambr
This commit is contained in:
parent
c0dc83cbc0
commit
50aefc3653
@ -196,7 +196,10 @@ class ViCareFan(ViCareEntity, FanEntity):
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
"""Return true if the entity is on."""
|
||||
if self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY):
|
||||
if (
|
||||
self._attr_supported_features & FanEntityFeature.TURN_OFF
|
||||
and self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY)
|
||||
):
|
||||
return False
|
||||
|
||||
return self.percentage is not None and self.percentage > 0
|
||||
@ -209,7 +212,10 @@ class ViCareFan(ViCareEntity, FanEntity):
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
"""Return the icon to use in the frontend."""
|
||||
if self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY):
|
||||
if (
|
||||
self._attr_supported_features & FanEntityFeature.TURN_OFF
|
||||
and self._api.getVentilationQuickmode(VentilationQuickmode.STANDBY)
|
||||
):
|
||||
return "mdi:fan-off"
|
||||
if hasattr(self, "_attr_preset_mode"):
|
||||
if self._attr_preset_mode == VentilationMode.VENTILATION:
|
||||
|
3019
tests/components/vicare/fixtures/Vitocal222G_Vitovent300W.json
Normal file
3019
tests/components/vicare/fixtures/Vitocal222G_Vitovent300W.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,69 @@
|
||||
# serializer version: 1
|
||||
# name: test_all_entities[fan.model0_ventilation-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'preset_modes': list([
|
||||
<VentilationMode.PERMANENT: 'permanent'>,
|
||||
<VentilationMode.VENTILATION: 'ventilation'>,
|
||||
<VentilationMode.SENSOR_DRIVEN: 'sensor_driven'>,
|
||||
<VentilationMode.SENSOR_OVERRIDE: 'sensor_override'>,
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'fan',
|
||||
'entity_category': None,
|
||||
'entity_id': 'fan.model0_ventilation',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': 'mdi:fan',
|
||||
'original_name': 'Ventilation',
|
||||
'platform': 'vicare',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <FanEntityFeature: 9>,
|
||||
'translation_key': 'ventilation',
|
||||
'unique_id': 'gateway0_deviceSerialViAir300F-ventilation',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[fan.model0_ventilation-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'model0 Ventilation',
|
||||
'icon': 'mdi:fan',
|
||||
'percentage': 0,
|
||||
'percentage_step': 25.0,
|
||||
'preset_mode': None,
|
||||
'preset_modes': list([
|
||||
<VentilationMode.PERMANENT: 'permanent'>,
|
||||
<VentilationMode.VENTILATION: 'ventilation'>,
|
||||
<VentilationMode.SENSOR_DRIVEN: 'sensor_driven'>,
|
||||
<VentilationMode.SENSOR_OVERRIDE: 'sensor_override'>,
|
||||
]),
|
||||
'supported_features': <FanEntityFeature: 9>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'fan.model0_ventilation',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[fan.model1_ventilation-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
@ -62,3 +127,64 @@
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[fan.model2_ventilation-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'preset_modes': list([
|
||||
<VentilationMode.VENTILATION: 'ventilation'>,
|
||||
<VentilationMode.STANDBY: 'standby'>,
|
||||
<VentilationMode.STANDARD: 'standard'>,
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'fan',
|
||||
'entity_category': None,
|
||||
'entity_id': 'fan.model2_ventilation',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': 'mdi:fan',
|
||||
'original_name': 'Ventilation',
|
||||
'platform': 'vicare',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <FanEntityFeature: 8>,
|
||||
'translation_key': 'ventilation',
|
||||
'unique_id': 'gateway2_################-ventilation',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[fan.model2_ventilation-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'model2 Ventilation',
|
||||
'icon': 'mdi:fan',
|
||||
'preset_mode': None,
|
||||
'preset_modes': list([
|
||||
<VentilationMode.VENTILATION: 'ventilation'>,
|
||||
<VentilationMode.STANDBY: 'standby'>,
|
||||
<VentilationMode.STANDARD: 'standard'>,
|
||||
]),
|
||||
'supported_features': <FanEntityFeature: 8>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'fan.model2_ventilation',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
|
@ -23,7 +23,9 @@ async def test_all_entities(
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test all entities."""
|
||||
fixtures: list[Fixture] = [Fixture({"type:boiler"}, "vicare/Vitodens300W.json")]
|
||||
fixtures: list[Fixture] = [
|
||||
Fixture({"type:boiler"}, "vicare/Vitodens300W.json"),
|
||||
]
|
||||
with (
|
||||
patch(f"{MODULE}.login", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.CLIMATE]),
|
||||
|
@ -26,6 +26,7 @@ async def test_all_entities(
|
||||
fixtures: list[Fixture] = [
|
||||
Fixture({"type:ventilation"}, "vicare/ViAir300F.json"),
|
||||
Fixture({"type:ventilation"}, "vicare/VitoPure.json"),
|
||||
Fixture({"type:heatpump"}, "vicare/Vitocal222G_Vitovent300W.json"),
|
||||
]
|
||||
with (
|
||||
patch(f"{MODULE}.login", return_value=MockPyViCare(fixtures)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user