mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Tado water heater code quality changes (#119811)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
289a54d632
commit
7f5a71d281
@ -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,
|
||||
|
@ -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 = []
|
||||
|
||||
|
@ -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,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user