1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-14 23:28:42 +00:00

Use direct DHW status for ViCare water heater state (#162591)

This commit is contained in:
Christian Lackas
2026-02-11 23:07:56 +01:00
committed by GitHub
parent fd78e35a86
commit b8e63b7ef6
2 changed files with 27 additions and 0 deletions

View File

@@ -102,6 +102,7 @@ class ViCareWater(ViCareEntity, WaterHeaterEntity):
_attr_operation_list = list(HA_TO_VICARE_HVAC_DHW)
_attr_translation_key = "domestic_hot_water"
_current_mode: str | None = None
_dhw_active: bool | None = None
def __init__(
self,
@@ -131,6 +132,9 @@ class ViCareWater(ViCareEntity, WaterHeaterEntity):
with suppress(PyViCareNotSupportedFeatureError):
self._current_mode = self._circuit.getActiveMode()
with suppress(PyViCareNotSupportedFeatureError):
self._dhw_active = self._api.getDomesticHotWaterActive()
except requests.exceptions.ConnectionError:
_LOGGER.error("Unable to retrieve data from ViCare server")
except PyViCareRateLimitError as limit_exception:
@@ -149,6 +153,8 @@ class ViCareWater(ViCareEntity, WaterHeaterEntity):
@property
def current_operation(self) -> str | None:
"""Return current operation ie. heat, cool, idle."""
if self._dhw_active is not None:
return OPERATION_MODE_ON if self._dhw_active else OPERATION_MODE_OFF
if self._current_mode is None:
return None
return VICARE_TO_HA_HVAC_DHW.get(self._current_mode)

View File

@@ -8,12 +8,15 @@ from syrupy.assertion import SnapshotAssertion
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.entity_component import async_update_entity
from . import MODULE, setup_integration
from .conftest import Fixture, MockPyViCare
from tests.common import MockConfigEntry, snapshot_platform
ENTITY_WATER_HEATER = "water_heater.model0_domestic_hot_water"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_all_entities(
@@ -31,3 +34,21 @@ async def test_all_entities(
await setup_integration(hass, mock_config_entry)
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_dhw_active_state(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test water heater uses direct DHW status for on/off state."""
fixtures: list[Fixture] = [Fixture({"type:boiler"}, "vicare/Vitodens300W.json")]
with (
patch(f"{MODULE}.login", return_value=MockPyViCare(fixtures)),
patch(f"{MODULE}.PLATFORMS", [Platform.WATER_HEATER]),
):
await setup_integration(hass, mock_config_entry)
await async_update_entity(hass, ENTITY_WATER_HEATER)
state = hass.states.get(ENTITY_WATER_HEATER)
assert state.state == "on"