From 7f5a71d281d9e8d9aa9d785307207e8656ca10e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ethem=20Cem=20=C3=96zkan?= Date: Fri, 21 Jun 2024 16:01:57 +0200 Subject: [PATCH] Tado water heater code quality changes (#119811) Co-authored-by: Martin Hjelmare --- homeassistant/components/tado/repairs.py | 13 ++++++------- homeassistant/components/tado/water_heater.py | 4 ++-- tests/components/tado/test_repairs.py | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/tado/repairs.py b/homeassistant/components/tado/repairs.py index 5ffc3c76bf7..90e20c615f2 100644 --- a/homeassistant/components/tado/repairs.py +++ b/homeassistant/components/tado/repairs.py @@ -13,20 +13,19 @@ from .const import ( def manage_water_heater_fallback_issue( hass: HomeAssistant, - water_heater_entities: list, + water_heater_names: list[str], integration_overlay_fallback: str | None, ) -> None: """Notify users about water heater respecting fallback setting.""" - if ( - integration_overlay_fallback - in [CONST_OVERLAY_TADO_DEFAULT, CONST_OVERLAY_MANUAL] - and len(water_heater_entities) > 0 + if integration_overlay_fallback in ( + CONST_OVERLAY_TADO_DEFAULT, + CONST_OVERLAY_MANUAL, ): - for water_heater_entity in water_heater_entities: + for water_heater_name in water_heater_names: ir.async_create_issue( hass=hass, domain=DOMAIN, - issue_id=f"{WATER_HEATER_FALLBACK_REPAIR}_{water_heater_entity.zone_name}", + issue_id=f"{WATER_HEATER_FALLBACK_REPAIR}_{water_heater_name}", is_fixable=False, is_persistent=False, severity=ir.IssueSeverity.WARNING, diff --git a/homeassistant/components/tado/water_heater.py b/homeassistant/components/tado/water_heater.py index a31b70a8f9a..1b3b811d231 100644 --- a/homeassistant/components/tado/water_heater.py +++ b/homeassistant/components/tado/water_heater.py @@ -83,12 +83,12 @@ async def async_setup_entry( manage_water_heater_fallback_issue( hass=hass, - water_heater_entities=entities, + water_heater_names=[e.zone_name for e in entities], integration_overlay_fallback=tado.fallback, ) -def _generate_entities(tado: TadoConnector) -> list[WaterHeaterEntity]: +def _generate_entities(tado: TadoConnector) -> list: """Create all water heater entities.""" entities = [] diff --git a/tests/components/tado/test_repairs.py b/tests/components/tado/test_repairs.py index 2e055884272..9b7a010e359 100644 --- a/tests/components/tado/test_repairs.py +++ b/tests/components/tado/test_repairs.py @@ -29,9 +29,9 @@ async def test_manage_water_heater_fallback_issue_not_created( """Test water heater fallback issue is not needed.""" zone_name = "Hot Water" expected_issue_id = f"{WATER_HEATER_FALLBACK_REPAIR}_{zone_name}" - water_heater_entities = [MockWaterHeater(zone_name)] + water_heater_names = [zone_name] manage_water_heater_fallback_issue( - water_heater_entities=water_heater_entities, + water_heater_names=water_heater_names, integration_overlay_fallback=CONST_OVERLAY_TADO_MODE, hass=hass, ) @@ -52,9 +52,9 @@ async def test_manage_water_heater_fallback_issue_created( """Test water heater fallback issue created cases.""" zone_name = "Hot Water" expected_issue_id = f"{WATER_HEATER_FALLBACK_REPAIR}_{zone_name}" - water_heater_entities = [MockWaterHeater(zone_name)] + water_heater_names = [zone_name] manage_water_heater_fallback_issue( - water_heater_entities=water_heater_entities, + water_heater_names=water_heater_names, integration_overlay_fallback=integration_overlay_fallback, hass=hass, )