diff --git a/custom_components/plugwise/climate.py b/custom_components/plugwise/climate.py index a7395a662..3e355d133 100644 --- a/custom_components/plugwise/climate.py +++ b/custom_components/plugwise/climate.py @@ -89,9 +89,9 @@ def _add_entities() -> None: entry.async_on_unload(coordinator.async_add_listener(_add_entities)) -def _check_for_schedule(active: bool, last_active: str | None) -> None: +def _check_for_schedule(active: bool, last_active: str) -> None: """Raise a HAError when no thermostat schedule has been set.""" - if not active and last_active is None: + if not active and last_active == STATE_OFF: raise HomeAssistantError( translation_domain=DOMAIN, translation_key=ERROR_NO_SCHEDULE, @@ -131,7 +131,7 @@ def __init__( self._api = coordinator.api gateway_id: str = self._api.gateway_id self._gateway_data = coordinator.data[gateway_id] - self._last_active_schedule: str | None = None + self._last_active_schedule = STATE_OFF self._location = device_id if (location := self.device.get(LOCATION)) is not None: self._location = location @@ -170,7 +170,7 @@ async def async_added_to_hass(self) -> None: extra_data = await self.async_get_last_extra_data() if extra_data is not None: data = extra_data.as_dict() - self._last_active_schedule = data.get("last_active_schedule") + self._last_active_schedule = data.get("last_active_schedule") or STATE_OFF self._previous_action_mode = ( data.get("previous_action_mode") or HVACAction.HEATING.value ) @@ -244,7 +244,7 @@ def hvac_modes(self) -> list[HVACMode]: if REGULATION_MODES in self._gateway_data: hvac_modes.append(HVACMode.OFF) - if self.device.get(AVAILABLE_SCHEDULES, []): + if self.device[AVAILABLE_SCHEDULES] != [STATE_OFF]: hvac_modes.append(HVACMode.AUTO) if self._api.cooling_present: @@ -329,8 +329,8 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: await self._api.set_regulation_mode(hvac_mode.value) return - current_schedule = self.device.get("select_schedule") - schedule_is_active = current_schedule not in (None, "off") + current_schedule = self.device["select_schedule"] + schedule_is_active = current_schedule != STATE_OFF desired_schedule = ( current_schedule if schedule_is_active else self._last_active_schedule ) @@ -339,7 +339,7 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: if hvac_mode == HVACMode.AUTO: _check_for_schedule(schedule_is_active, self._last_active_schedule) await self._api.set_schedule_state( - self._location, STATE_ON, desired_schedule + self._location, desired_schedule, STATE_ON ) await self._api.set_regulation_mode(self._previous_action_mode) return @@ -347,7 +347,7 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: # Transition to manual mode if schedule_is_active: await self._api.set_schedule_state( - self._location, STATE_OFF, current_schedule + self._location, current_schedule, STATE_OFF, ) self._last_active_schedule = current_schedule regulation = self._regulation_mode_for_hvac(hvac_mode) @@ -357,14 +357,14 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: # Common - transition from auto = schedule off if self.hvac_mode == HVACMode.AUTO: await self._api.set_schedule_state( - self._location, STATE_OFF, current_schedule + self._location, current_schedule, STATE_OFF, ) self._last_active_schedule = current_schedule return # Common - transition to auto = schedule on _check_for_schedule(schedule_is_active, self._last_active_schedule) - await self._api.set_schedule_state(self._location, STATE_ON, desired_schedule) + await self._api.set_schedule_state(self._location, desired_schedule, STATE_ON) @plugwise_command @override diff --git a/custom_components/plugwise/const.py b/custom_components/plugwise/const.py index 99f66b67b..90554e7d5 100644 --- a/custom_components/plugwise/const.py +++ b/custom_components/plugwise/const.py @@ -77,15 +77,12 @@ VENDOR: Final = "vendor" # Number constants -MAX_BOILER_TEMP: Final = "maximum_boiler_temperature" -MAX_DHW_TEMP: Final = "max_dhw_temperature" LOWER_BOUND: Final = "lower_bound" RESOLUTION: Final = "resolution" TEMPERATURE_OFFSET: Final = "temperature_offset" UPPER_BOUND: Final = "upper_bound" # Sensor constants -DHW_TEMP: Final = "dhw_temperature" DHW_SETPOINT: Final = "domestic_hot_water_setpoint" EL_CONSUMED: Final = "electricity_consumed" EL_CONS_INTERVAL: Final = "electricity_consumed_interval" @@ -150,6 +147,10 @@ COOLING_ENA_SWITCH: Final ="cooling_ena_switch" SWITCHES: Final = "switches" +# Water_heater constants +BOILER_TEMP: Final = "boiler_temperature" +DHW_TEMP: Final = "dhw_temperature" + # Default directives DEFAULT_PORT: Final[int] = 80 DEFAULT_TIMEOUT: Final[int] = 30 @@ -188,11 +189,8 @@ } type NumberType = Literal[ - "maximum_boiler_temperature", - "max_dhw_temperature", "temperature_offset", ] - type SelectType = Literal[ "select_dhw_mode", "select_gateway_mode", @@ -207,3 +205,8 @@ "regulation_modes", "zone_profiles", ] +type WaterHeaterType = Literal[ + "boiler_temperature", + "dhw_temperature", +] +type WaterHeaterOptionsType = Literal["dhw_modes"] diff --git a/custom_components/plugwise/manifest.json b/custom_components/plugwise/manifest.json index 09f91d310..74ce43628 100644 --- a/custom_components/plugwise/manifest.json +++ b/custom_components/plugwise/manifest.json @@ -7,7 +7,7 @@ "integration_type": "hub", "iot_class": "local_polling", "loggers": ["plugwise"], - "requirements": ["plugwise==1.12.0"], - "version": "0.65.0", + "requirements": ["plugwise==1.14.5"], + "version": "0.65.1", "zeroconf": ["_plugwise._tcp.local."] } diff --git a/custom_components/plugwise/number.py b/custom_components/plugwise/number.py index 5f88a80a3..39a71179a 100644 --- a/custom_components/plugwise/number.py +++ b/custom_components/plugwise/number.py @@ -16,7 +16,6 @@ from .const import ( LOGGER, LOWER_BOUND, - MAX_BOILER_TEMP, RESOLUTION, TEMPERATURE_OFFSET, UPPER_BOUND, @@ -40,13 +39,6 @@ class PlugwiseNumberEntityDescription(NumberEntityDescription): # Upstream + is there a reason we didn't rename this one prefixed? NUMBER_TYPES = ( - PlugwiseNumberEntityDescription( - key=MAX_BOILER_TEMP, - translation_key=MAX_BOILER_TEMP, - device_class=NumberDeviceClass.TEMPERATURE, - entity_category=EntityCategory.CONFIG, - native_unit_of_measurement=UnitOfTemperature.CELSIUS, - ), PlugwiseNumberEntityDescription( key=TEMPERATURE_OFFSET, translation_key=TEMPERATURE_OFFSET, @@ -121,8 +113,6 @@ def __init__( self._attr_native_min_value = ctrl.get(LOWER_BOUND, 0.0) # Upstream const native_step = ctrl.get(RESOLUTION, 0.5) # Upstream const - if description.key != TEMPERATURE_OFFSET: # Upstream const - native_step = max(native_step, 0.5) self._attr_native_step = native_step @property diff --git a/custom_components/plugwise/select.py b/custom_components/plugwise/select.py index 329e42ae4..6bef99bf4 100644 --- a/custom_components/plugwise/select.py +++ b/custom_components/plugwise/select.py @@ -101,7 +101,7 @@ def _add_entities() -> None: for device_id in coordinator.new_devices: device = coordinator.data[device_id] for description in SELECT_TYPES: - if device.get(description.options_key): + if device.get(description.key) is not None: entities.append( PlugwiseSelectEntity(coordinator, device_id, description) ) diff --git a/custom_components/plugwise/translations/en.json b/custom_components/plugwise/translations/en.json index 0015e95e4..88caca2e6 100644 --- a/custom_components/plugwise/translations/en.json +++ b/custom_components/plugwise/translations/en.json @@ -93,12 +93,6 @@ } }, "number": { - "max_dhw_temperature": { - "name": "Domestic hot water setpoint" - }, - "maximum_boiler_temperature": { - "name": "Maximum boiler temperature setpoint" - }, "temperature_offset": { "name": "Temperature offset" } @@ -108,7 +102,7 @@ "name": "DHW mode", "state": { "comfort": "Comfort", - "off": "Off" + "eco": "Eco" } }, "select_gateway_mode": { @@ -299,13 +293,21 @@ } }, "water_heater": { - "plugwise": { - "state": { - "auto": "Auto", - "boost": "Boost", - "comfort": "Comfort", - "eco": "Eco", - "off": "Off" + "boiler_temperature": { + "name": "Boiler" + }, + "dhw_temperature": { + "name": "Domestic hot water", + "state_attributes": { + "dhw_modes": { + "state": { + "auto": "Auto", + "boost": "Boost", + "comfort": "Comfort", + "eco": "Eco", + "off": "Off" + } + } } } } diff --git a/custom_components/plugwise/translations/nl.json b/custom_components/plugwise/translations/nl.json index b76c57143..327de0716 100644 --- a/custom_components/plugwise/translations/nl.json +++ b/custom_components/plugwise/translations/nl.json @@ -93,12 +93,6 @@ } }, "number": { - "max_dhw_temperature": { - "name": "Instelpunt sanitair warm water" - }, - "maximum_boiler_temperature": { - "name": "Instelpunt maximale boiler temperatuur" - }, "temperature_offset": { "name": "Temperatuurcompensatie" } @@ -108,7 +102,7 @@ "name": "SWW modus", "state": { "comfort": "Comfort", - "off": "Uit" + "eco": "Eco" } }, "select_gateway_mode": { @@ -299,13 +293,21 @@ } }, "water_heater": { - "plugwise": { - "state": { - "auto": "Auto", - "boost": "Boost", - "comfort": "Comfort", - "eco": "Eco", - "off": "Off" + "boiler_temperature": { + "name": "Boiler" + }, + "dhw_temperature": { + "name": "Sanitair warm water", + "state_attributes": { + "dhw_modes": { + "state": { + "auto": "Auto", + "boost": "Boost", + "comfort": "Comfort", + "eco": "Eco", + "off": "Uit" + } + } } } } diff --git a/custom_components/plugwise/water_heater.py b/custom_components/plugwise/water_heater.py index d7758a242..282c59b71 100644 --- a/custom_components/plugwise/water_heater.py +++ b/custom_components/plugwise/water_heater.py @@ -1,37 +1,63 @@ """Plugwise water heater component for HomeAssistant.""" -from typing import Any, override +from dataclasses import dataclass +from typing import Any, cast, override from homeassistant.components.water_heater import ( + STATE_ECO, WaterHeaterEntity, + WaterHeaterEntityDescription, WaterHeaterEntityFeature, ) from homeassistant.const import ( - ATTR_NAME, ATTR_TEMPERATURE, STATE_OFF, + STATE_ON, + EntityCategory, UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from .const import ( + BOILER_TEMP, DHW_MODE, DHW_MODES, - DHW_SETPOINT, DHW_TEMP, LOGGER, LOWER_BOUND, - MAX_DHW_TEMP, - SENSORS, - TARGET_TEMP, UPPER_BOUND, - WATER_TEMP, + WaterHeaterOptionsType, + WaterHeaterType, ) from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity from .util import plugwise_command +PARALLEL_UPDATES = 0 + +@dataclass(frozen=True, kw_only=True) +class PlugwiseWaterHeaterEntityDescription(WaterHeaterEntityDescription): + """Class describing Plugwise WaterHeater entities.""" + + key: WaterHeaterType + options_key: WaterHeaterOptionsType | None + +# Upstream + is there a reason we didn't rename this one prefixed? +WATERHEATER_TYPES = ( + PlugwiseWaterHeaterEntityDescription( + key=BOILER_TEMP, + translation_key=BOILER_TEMP, + entity_category=EntityCategory.CONFIG, + options_key=None, + ), + PlugwiseWaterHeaterEntityDescription( + key=DHW_TEMP, + translation_key=DHW_TEMP, + entity_category=EntityCategory.CONFIG, + options_key=DHW_MODES, + ), +) async def async_setup_entry( _hass: HomeAssistant, @@ -50,9 +76,15 @@ def _add_entities() -> None: entities: list[PlugwiseWaterHeaterEntity] = [] for device_id in coordinator.new_devices: device = coordinator.data[device_id] - if device.get(MAX_DHW_TEMP) is not None: - entities.append(PlugwiseWaterHeaterEntity(coordinator, device_id)) - LOGGER.debug("Add %s water_heater", device[ATTR_NAME]) + for description in WATERHEATER_TYPES: + if description.key in device: + entities.append( + PlugwiseWaterHeaterEntity(coordinator, device_id, description) + ) + LOGGER.debug( + "Add %s %s water_heater", device["name"], description.translation_key + ) + async_add_entities(entities) _add_entities() @@ -62,69 +94,90 @@ def _add_entities() -> None: class PlugwiseWaterHeaterEntity(PlugwiseEntity, WaterHeaterEntity): """Representation of a Plugwise water heater.""" - _attr_name = None - _attr_temperature_unit = UnitOfTemperature.CELSIUS + entity_description: PlugwiseWaterHeaterEntityDescription def __init__( self, coordinator: PlugwiseDataUpdateCoordinator, device_id: str, + description: PlugwiseWaterHeaterEntityDescription, ) -> None: """Initialise the water_heater.""" super().__init__(coordinator, device_id) - - entity_name = f"{self.device[ATTR_NAME]}".lower() - self._attr_unique_id = f"{device_id}-{entity_name}" - - max_dhw_temp_bounds = self.device.get(MAX_DHW_TEMP, {}) - if max_dhw_temp_bounds: - self._attr_max_temp = max_dhw_temp_bounds.get(UPPER_BOUND, 75.0) - self._attr_min_temp = max_dhw_temp_bounds.get(LOWER_BOUND, 40.0) - self._attr_supported_features = WaterHeaterEntityFeature.OPERATION_MODE - self._attr_supported_features |= WaterHeaterEntityFeature.TARGET_TEMPERATURE - + self.entity_description = description + self._attr_max_temp = self.device[description.key][UPPER_BOUND] + self._attr_min_temp = self.device[description.key][LOWER_BOUND] + self._attr_supported_features = WaterHeaterEntityFeature.TARGET_TEMPERATURE + if description.options_key is not None: + self._attr_supported_features |= WaterHeaterEntityFeature.OPERATION_MODE + self._attr_target_temperature_step = max( + self.device[description.key]["resolution"], 0.5 + ) + self._attr_temperature_unit = UnitOfTemperature.CELSIUS + self._attr_unique_id = f"{device_id}-{description.key}" + dhw_modes = self.device.get(DHW_MODES, []) + self._dhw_modes_count = len(dhw_modes) + if description.options_key is not None and STATE_OFF in dhw_modes: + self._attr_supported_features |= WaterHeaterEntityFeature.ON_OFF @property @override def current_operation(self) -> str | None: """Return current readable operation mode.""" + if self.entity_description.options_key is None: + return STATE_ON return self.device.get(DHW_MODE) @property @override def current_temperature(self) -> float | None: """Return the current water temperature.""" - boiler_temperature = self.device.get(SENSORS, {}).get(WATER_TEMP) - dhw_temperature = self.device.get(SENSORS, {}).get(DHW_TEMP) - return dhw_temperature or boiler_temperature + return self.device[self.entity_description.key].get("current") @property @override - def operation_list(self) -> list[str]: + def operation_list(self) -> list[str] | None: """Return the list of available operation modes.""" - if (op_list := self.device.get(DHW_MODES, [])): - return op_list - return [STATE_OFF] # pragma: no cover + if (key := self.entity_description.options_key) is not None: + return self.device.get(key, []) + + return None # pragma: no cover @property @override def target_temperature(self) -> float | None: """Return the water temperature we try to reach.""" - return ( - self.device.get(MAX_DHW_TEMP, {}).get(TARGET_TEMP) - or self.device.get(SENSORS, {}).get(DHW_SETPOINT) - ) + return self.device[self.entity_description.key].get("setpoint") @plugwise_command @override async def async_set_operation_mode(self, operation_mode: str) -> None: """Set the operation mode.""" - list_type: int = len(self.operation_list) - await self.coordinator.api.set_dhw_mode(DHW_MODE, self._dev_id, list_type, operation_mode) + await self.coordinator.api.set_dhw_mode(DHW_MODE, self._dev_id, operation_mode, self._dhw_modes_count,) + + @plugwise_command + @override + async def async_turn_off(self, **kwargs: Any) -> None: + """Turn the water_heater off.""" + await self.coordinator.api.set_dhw_mode( + DHW_MODE, self._dev_id, STATE_OFF, self._dhw_modes_count, + ) + + @plugwise_command + @override + async def async_turn_on(self, **kwargs: Any) -> None: + """Turn the water_heater on and set the operation mode.""" + await self.coordinator.api.set_dhw_mode( + DHW_MODE, self._dev_id, STATE_ECO, self._dhw_modes_count, + ) @plugwise_command @override async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" - if (temperature := kwargs.get(ATTR_TEMPERATURE)) is not None: - await self.coordinator.api.set_number(self._dev_id, MAX_DHW_TEMP, float(temperature)) + temperature = cast(float, kwargs.get(ATTR_TEMPERATURE)) + await self.coordinator.api.set_number( + self._dev_id, + self.entity_description.key, + temperature, + ) diff --git a/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json b/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json index 56c7ffbb0..b8a9161c0 100644 --- a/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json +++ b/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json @@ -6,24 +6,28 @@ "flame_state": true, "heating_state": true }, - "dev_class": "heater_central", - "dhw_modes": [ - "comfort", - "off" - ], - "location": "bc93488efab249e5bc54fd7e175a6f91", - "maximum_boiler_temperature": { + "boiler_temperature": { + "current": 43.0, "lower_bound": 25.0, "resolution": 0.01, "setpoint": 50.0, "upper_bound": 95.0 }, + "dev_class": "heater_central", + "dhw_modes": [ + "comfort", + "eco" + ], + "location": "bc93488efab249e5bc54fd7e175a6f91", "model": "Generic heater", "name": "OpenTherm", - "select_dhw_mode": "off", + "select_dhw_mode": "eco", "sensors": { "intended_boiler_temperature": 22.5, "water_temperature": 43.0 + }, + "switches": { + "dhw_cm_switch": false } }, "10016900610d4c7481df78c89606ef22": { @@ -298,11 +302,11 @@ "f2bf9048bef64cc5b6d5110154e33c81": { "active_preset": "home", "available_schedules": [ + "off", "Badkamer", "Vakantie", "Weekschema", - "Test", - "off" + "Test" ], "climate_mode": "auto", "control_state": "heating", @@ -347,11 +351,11 @@ "f871b8c4d63549319221e294e4f88074": { "active_preset": "vacation", "available_schedules": [ + "off", "Badkamer", "Vakantie", "Weekschema", - "Test", - "off" + "Test" ], "climate_mode": "heat", "control_state": "idle", diff --git a/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json b/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json index 54a045273..c63972711 100644 --- a/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json +++ b/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json @@ -28,25 +28,27 @@ "heating_state": true, "secondary_boiler_state": false }, + "boiler_temperature": { + "current": 29.1, + "lower_bound": 0.0, + "resolution": 1.0, + "setpoint": 60.0, + "upper_bound": 100.0 + }, "dev_class": "heater_central", - "dhw_mode": "off", + "dhw_mode": "eco", "dhw_modes": [ "comfort", - "off" + "eco" ], - "location": "a57efe5f145f498c9be62a9b63626fbf", - "max_dhw_temperature": { + "dhw_temperature": { + "current": 46.3, "lower_bound": 35.0, "resolution": 0.01, "setpoint": 53.0, "upper_bound": 60.0 }, - "maximum_boiler_temperature": { - "lower_bound": 0.0, - "resolution": 1.0, - "setpoint": 60.0, - "upper_bound": 100.0 - }, + "location": "a57efe5f145f498c9be62a9b63626fbf", "model": "Generic heater/cooler", "name": "OpenTherm", "sensors": { @@ -58,13 +60,16 @@ "water_pressure": 1.57, "water_temperature": 29.1 }, + "switches": { + "dhw_cm_switch": false + }, "vendor": "Techneco" }, "3cb70739631c4d17a86b8b12e8a5161b": { "active_preset": "home", "available_schedules": [ - "standaard", - "off" + "off", + "standaard" ], "climate_mode": "auto", "control_state": "heating", diff --git a/tests/components/plugwise/fixtures/anna_loria_cooling_active/data.json b/tests/components/plugwise/fixtures/anna_loria_cooling_active/data.json new file mode 100644 index 000000000..1dadad338 --- /dev/null +++ b/tests/components/plugwise/fixtures/anna_loria_cooling_active/data.json @@ -0,0 +1,114 @@ +{ + "582dfbdace4d4aeb832923ce7d1ddda0": { + "active_preset": "home", + "available_schedules": [ + "off", + "Winter", + "Test " + ], + "climate_mode": "auto", + "control_state": "cooling", + "dev_class": "thermostat", + "firmware": "2018-02-08T11:15:53+01:00", + "hardware": "6539-1301-5002", + "location": "15da035090b847e7a21f93e08c015ebc", + "model": "ThermoTouch", + "name": "Anna", + "preset_modes": [ + "away", + "vacation", + "no_frost", + "home", + "asleep" + ], + "select_schedule": "Winter", + "sensors": { + "illuminance": 45.0, + "setpoint_high": 23.5, + "setpoint_low": 4.0, + "temperature": 24.1 + }, + "temperature_offset": { + "lower_bound": -2.0, + "resolution": 0.1, + "setpoint": 0.0, + "upper_bound": 2.0 + }, + "thermostat": { + "lower_bound": 4.0, + "resolution": 0.1, + "setpoint_high": 23.5, + "setpoint_low": 4.0, + "upper_bound": 30.0 + }, + "vendor": "Plugwise" + }, + "9ff0569b4984459fb243af64c0901894": { + "binary_sensors": { + "plugwise_notification": false + }, + "dev_class": "gateway", + "firmware": "4.3.8", + "hardware": "AME Smile 2.0 board", + "location": "674b657c138a41a291d315d7471deb06", + "mac_address": "C493000278E2", + "model": "Gateway", + "model_id": "smile_thermo", + "name": "Smile Anna", + "notifications": {}, + "sensors": { + "outdoor_temperature": 15.5 + }, + "vendor": "Plugwise" + }, + "bfb5ee0a88e14e5f97bfa725a760cc49": { + "available": true, + "binary_sensors": { + "cooling_enabled": true, + "cooling_state": true, + "dhw_state": false, + "flame_state": false, + "heating_state": false + }, + "boiler_temperature": { + "current": 25.3, + "lower_bound": 25.0, + "resolution": 0.01, + "setpoint": 40.0, + "upper_bound": 45.0 + }, + "dev_class": "heater_central", + "dhw_mode": "auto", + "dhw_modes": [ + "off", + "auto", + "boost", + "eco", + "comfort" + ], + "dhw_temperature": { + "current": 52.9, + "lower_bound": 35.0, + "resolution": 0.01, + "setpoint": 53.0, + "upper_bound": 60.0 + }, + "location": "674b657c138a41a291d315d7471deb06", + "model": "Generic heater/cooler", + "model_id": "173", + "name": "OpenTherm", + "sensors": { + "dhw_temperature": 52.9, + "intended_boiler_temperature": 0.0, + "modulation_level": 100, + "outdoor_air_temperature": 17.2, + "return_temperature": 26.3, + "water_temperature": 25.3 + }, + "switches": { + "cooling_ena_switch": true, + "dhw_cm_switch": true + }, + "vendor": "Atlantic" + } +} diff --git a/tests/components/plugwise/fixtures/anna_p1/data.json b/tests/components/plugwise/fixtures/anna_p1/data.json index 6ee72b54c..cd637d48e 100644 --- a/tests/components/plugwise/fixtures/anna_p1/data.json +++ b/tests/components/plugwise/fixtures/anna_p1/data.json @@ -2,8 +2,8 @@ "1e5e55b958ac445583602f767cb45942": { "active_preset": "home", "available_schedules": [ - "Thermostat schedule", - "off" + "off", + "Thermostat schedule" ], "climate_mode": "heat", "control_state": "idle", @@ -50,7 +50,7 @@ "dev_class": "heater_central", "dhw_modes": [ "comfort", - "off" + "eco" ], "location": "da7be222ab3b420c927f3e49fade0304", "model": "Generic heater", @@ -63,6 +63,9 @@ "water_pressure": 6.0, "water_temperature": 35.0 }, + "switches": { + "dhw_cm_switch": true + }, "vendor": "Intergas" }, "53130847be2f436cb946b78dedb9053a": { diff --git a/tests/components/plugwise/fixtures/anna_v4/data.json b/tests/components/plugwise/fixtures/anna_v4/data.json index 563560b49..e2c75ed6c 100644 --- a/tests/components/plugwise/fixtures/anna_v4/data.json +++ b/tests/components/plugwise/fixtures/anna_v4/data.json @@ -2,9 +2,9 @@ "01b85360fdd243d0aaad4d6ac2a5ba7e": { "active_preset": "home", "available_schedules": [ + "off", "Standaard", - "Thuiswerken", - "off" + "Thuiswerken" ], "climate_mode": "heat", "control_state": "heating", @@ -66,25 +66,27 @@ "flame_state": false, "heating_state": true }, + "boiler_temperature": { + "current": 45.0, + "lower_bound": 0.0, + "resolution": 1.0, + "setpoint": 70.0, + "upper_bound": 100.0 + }, "dev_class": "heater_central", - "dhw_mode": "off", + "dhw_mode": "eco", "dhw_modes": [ "comfort", - "off" + "eco" ], - "location": "94c107dc6ac84ed98e9f68c0dd06bf71", - "max_dhw_temperature": { + "dhw_temperature": { + "current": 45.0, "lower_bound": 30.0, "resolution": 0.01, "setpoint": 60.0, "upper_bound": 60.0 }, - "maximum_boiler_temperature": { - "lower_bound": 0.0, - "resolution": 1.0, - "setpoint": 70.0, - "upper_bound": 100.0 - }, + "location": "94c107dc6ac84ed98e9f68c0dd06bf71", "model": "Generic heater", "model_id": "2.32", "name": "OpenTherm", @@ -95,6 +97,9 @@ "water_pressure": 2.2, "water_temperature": 45.0 }, + "switches": { + "dhw_cm_switch": false + }, "vendor": "Bosch Thermotechniek B.V." } } diff --git a/tests/components/plugwise/fixtures/anna_v4_dhw/data.json b/tests/components/plugwise/fixtures/anna_v4_dhw/data.json index 9c1f13360..0a8fb6035 100644 --- a/tests/components/plugwise/fixtures/anna_v4_dhw/data.json +++ b/tests/components/plugwise/fixtures/anna_v4_dhw/data.json @@ -2,9 +2,9 @@ "01b85360fdd243d0aaad4d6ac2a5ba7e": { "active_preset": "home", "available_schedules": [ + "off", "Standaard", - "Thuiswerken", - "off" + "Thuiswerken" ], "climate_mode": "heat", "control_state": "idle", @@ -66,25 +66,27 @@ "flame_state": true, "heating_state": false }, + "boiler_temperature": { + "current": 45.0, + "lower_bound": 0.0, + "resolution": 1.0, + "setpoint": 70.0, + "upper_bound": 100.0 + }, "dev_class": "heater_central", - "dhw_mode": "off", + "dhw_mode": "eco", "dhw_modes": [ "comfort", - "off" + "eco" ], - "location": "94c107dc6ac84ed98e9f68c0dd06bf71", - "max_dhw_temperature": { + "dhw_temperature": { + "current": 45.0, "lower_bound": 30.0, "resolution": 0.01, "setpoint": 60.0, "upper_bound": 60.0 }, - "maximum_boiler_temperature": { - "lower_bound": 0.0, - "resolution": 1.0, - "setpoint": 70.0, - "upper_bound": 100.0 - }, + "location": "94c107dc6ac84ed98e9f68c0dd06bf71", "model": "Generic heater", "model_id": "2.32", "name": "OpenTherm", @@ -95,6 +97,9 @@ "water_pressure": 2.2, "water_temperature": 45.0 }, + "switches": { + "dhw_cm_switch": false + }, "vendor": "Bosch Thermotechniek B.V." } } diff --git a/tests/components/plugwise/fixtures/legacy_anna/data.json b/tests/components/plugwise/fixtures/legacy_anna/data.json index f4a30b8fa..0947da8c0 100644 --- a/tests/components/plugwise/fixtures/legacy_anna/data.json +++ b/tests/components/plugwise/fixtures/legacy_anna/data.json @@ -13,14 +13,15 @@ "flame_state": true, "heating_state": true }, - "dev_class": "heater_central", - "location": "0000aaaa0000aaaa0000aaaa0000aa00", - "maximum_boiler_temperature": { + "boiler_temperature": { + "current": 23.6, "lower_bound": 50.0, "resolution": 1.0, "setpoint": 50.0, "upper_bound": 90.0 }, + "dev_class": "heater_central", + "location": "0000aaaa0000aaaa0000aaaa0000aa00", "model": "Generic heater", "name": "OpenTherm", "sensors": { @@ -35,7 +36,9 @@ }, "0d266432d64443e283b5d708ae98b455": { "active_preset": "home", - "available_schedules": [], + "available_schedules": [ + "off" + ], "climate_mode": "heat", "control_state": "heating", "dev_class": "thermostat", @@ -51,7 +54,7 @@ "home", "no_frost" ], - "select_schedule": null, + "select_schedule": "off", "sensors": { "illuminance": 150.8, "setpoint": 20.5, diff --git a/tests/components/plugwise/fixtures/m_adam_cooling/data.json b/tests/components/plugwise/fixtures/m_adam_cooling/data.json index c5b321660..539853029 100644 --- a/tests/components/plugwise/fixtures/m_adam_cooling/data.json +++ b/tests/components/plugwise/fixtures/m_adam_cooling/data.json @@ -7,24 +7,28 @@ "flame_state": false, "heating_state": false }, - "dev_class": "heater_central", - "dhw_modes": [ - "comfort", - "off" - ], - "location": "bc93488efab249e5bc54fd7e175a6f91", - "maximum_boiler_temperature": { + "boiler_temperature": { + "current": 19.0, "lower_bound": 25.0, "resolution": 0.01, "setpoint": 50.0, "upper_bound": 95.0 }, + "dev_class": "heater_central", + "dhw_modes": [ + "comfort", + "eco" + ], + "location": "bc93488efab249e5bc54fd7e175a6f91", "model": "Generic heater", "name": "OpenTherm", - "select_dhw_mode": "off", + "select_dhw_mode": "eco", "sensors": { "intended_boiler_temperature": 17.5, "water_temperature": 19.0 + }, + "switches": { + "dhw_cm_switch": false } }, "14df5c4dc8cb4ba69f9d1ac0eaf7c5c6": { @@ -209,11 +213,11 @@ "f2bf9048bef64cc5b6d5110154e33c81": { "active_preset": "home", "available_schedules": [ + "off", "Badkamer", "Vakantie", "Weekschema", - "Test", - "off" + "Test" ], "climate_mode": "cool", "control_state": "cooling", @@ -258,11 +262,11 @@ "f871b8c4d63549319221e294e4f88074": { "active_preset": "vacation", "available_schedules": [ + "off", "Badkamer", "Vakantie", "Weekschema", - "Test", - "off" + "Test" ], "climate_mode": "auto", "control_state": "cooling", diff --git a/tests/components/plugwise/fixtures/m_adam_heating/data.json b/tests/components/plugwise/fixtures/m_adam_heating/data.json index f29aa84c7..2f9688f9c 100644 --- a/tests/components/plugwise/fixtures/m_adam_heating/data.json +++ b/tests/components/plugwise/fixtures/m_adam_heating/data.json @@ -6,30 +6,35 @@ "flame_state": false, "heating_state": true }, + "boiler_temperature": { + "current": 37.0, + "lower_bound": 25.0, + "resolution": 0.01, + "setpoint": 50.0, + "upper_bound": 95.0 + }, "dev_class": "heater_central", + "dhw_mode": "eco", "dhw_modes": [ "comfort", - "off" + "eco" ], - "location": "bc93488efab249e5bc54fd7e175a6f91", - "max_dhw_temperature": { + "dhw_temperature": { + "current": 37.0, "lower_bound": 40.0, "resolution": 0.01, "setpoint": 60.0, "upper_bound": 60.0 }, - "maximum_boiler_temperature": { - "lower_bound": 25.0, - "resolution": 0.01, - "setpoint": 50.0, - "upper_bound": 95.0 - }, + "location": "bc93488efab249e5bc54fd7e175a6f91", "model": "Generic heater", "name": "OpenTherm", - "select_dhw_mode": "off", "sensors": { "intended_boiler_temperature": 38.1, "water_temperature": 37.0 + }, + "switches": { + "dhw_cm_switch": false } }, "14df5c4dc8cb4ba69f9d1ac0eaf7c5c6": { @@ -213,11 +218,11 @@ "f2bf9048bef64cc5b6d5110154e33c81": { "active_preset": "home", "available_schedules": [ + "off", "Badkamer", "Vakantie", "Weekschema", - "Test", - "off" + "Test" ], "climate_mode": "heat", "control_state": "preheating", @@ -262,11 +267,11 @@ "f871b8c4d63549319221e294e4f88074": { "active_preset": "vacation", "available_schedules": [ + "off", "Badkamer", "Vakantie", "Weekschema", - "Test", - "off" + "Test" ], "climate_mode": "auto", "control_state": "idle", diff --git a/tests/components/plugwise/fixtures/m_adam_heating_off_schedule/data.json b/tests/components/plugwise/fixtures/m_adam_heating_off_schedule/data.json index aaabc1495..9e034f415 100644 --- a/tests/components/plugwise/fixtures/m_adam_heating_off_schedule/data.json +++ b/tests/components/plugwise/fixtures/m_adam_heating_off_schedule/data.json @@ -6,30 +6,35 @@ "flame_state": false, "heating_state": false }, + "boiler_temperature": { + "current": 37.0, + "lower_bound": 25.0, + "resolution": 0.01, + "setpoint": 50.0, + "upper_bound": 95.0 + }, "dev_class": "heater_central", + "dhw_mode": "eco", "dhw_modes": [ "comfort", - "off" + "eco" ], - "location": "bc93488efab249e5bc54fd7e175a6f91", - "max_dhw_temperature": { + "dhw_temperature": { + "current": 37.0, "lower_bound": 40.0, "resolution": 0.01, "setpoint": 60.0, "upper_bound": 60.0 }, - "maximum_boiler_temperature": { - "lower_bound": 25.0, - "resolution": 0.01, - "setpoint": 50.0, - "upper_bound": 95.0 - }, + "location": "bc93488efab249e5bc54fd7e175a6f91", "model": "Generic heater", "name": "OpenTherm", - "select_dhw_mode": "off", "sensors": { "intended_boiler_temperature": 0.0, "water_temperature": 37.0 + }, + "switches": { + "dhw_cm_switch": false } }, "14df5c4dc8cb4ba69f9d1ac0eaf7c5c6": { @@ -213,11 +218,11 @@ "f2bf9048bef64cc5b6d5110154e33c81": { "active_preset": "home", "available_schedules": [ + "off", "Badkamer", "Vakantie", "Weekschema", - "Test", - "off" + "Test" ], "climate_mode": "off", "control_state": "idle", @@ -262,11 +267,11 @@ "f871b8c4d63549319221e294e4f88074": { "active_preset": "vacation", "available_schedules": [ + "off", "Badkamer", "Vakantie", "Weekschema", - "Test", - "off" + "Test" ], "climate_mode": "off", "control_state": "idle", diff --git a/tests/components/plugwise/fixtures/m_adam_jip/data.json b/tests/components/plugwise/fixtures/m_adam_jip/data.json index ff33d77c2..793498bb1 100644 --- a/tests/components/plugwise/fixtures/m_adam_jip/data.json +++ b/tests/components/plugwise/fixtures/m_adam_jip/data.json @@ -1,7 +1,9 @@ { "06aecb3d00354375924f50c47af36bd2": { "active_preset": "no_frost", - "available_schedules": [], + "available_schedules": [ + "off" + ], "climate_mode": "off", "dev_class": "climate", "model": "ThermoZone", @@ -13,7 +15,7 @@ "vacation", "no_frost" ], - "select_schedule": null, + "select_schedule": "off", "select_zone_profile": "active", "sensors": { "temperature": 24.2 @@ -41,7 +43,9 @@ }, "13228dab8ce04617af318a2888b3c548": { "active_preset": "home", - "available_schedules": [], + "available_schedules": [ + "off" + ], "climate_mode": "heat", "control_state": "idle", "dev_class": "climate", @@ -54,7 +58,7 @@ "vacation", "no_frost" ], - "select_schedule": null, + "select_schedule": "off", "select_zone_profile": "active", "sensors": { "temperature": 27.4 @@ -281,7 +285,9 @@ }, "d27aede973b54be484f6842d1b2802ad": { "active_preset": "home", - "available_schedules": [], + "available_schedules": [ + "off" + ], "climate_mode": "heat", "control_state": "idle", "dev_class": "climate", @@ -294,7 +300,7 @@ "vacation", "no_frost" ], - "select_schedule": null, + "select_schedule": "off", "select_zone_profile": "active", "sensors": { "temperature": 30.0 @@ -346,7 +352,9 @@ }, "d58fec52899f4f1c92e4f8fad6d8c48c": { "active_preset": "home", - "available_schedules": [], + "available_schedules": [ + "off" + ], "climate_mode": "heat", "control_state": "idle", "dev_class": "climate", @@ -359,7 +367,7 @@ "vacation", "no_frost" ], - "select_schedule": null, + "select_schedule": "off", "select_zone_profile": "active", "sensors": { "temperature": 30.0 @@ -392,25 +400,27 @@ "flame_state": false, "heating_state": false }, + "boiler_temperature": { + "current": 37.3, + "lower_bound": 20.0, + "resolution": 0.01, + "setpoint": 90.0, + "upper_bound": 90.0 + }, "dev_class": "heater_central", - "dhw_mode": "off", + "dhw_mode": "eco", "dhw_modes": [ "comfort", - "off" + "eco" ], - "location": "9e4433a9d69f40b3aefd15e74395eaec", - "max_dhw_temperature": { + "dhw_temperature": { + "current": 37.3, "lower_bound": 40.0, "resolution": 0.01, "setpoint": 60.0, "upper_bound": 60.0 }, - "maximum_boiler_temperature": { - "lower_bound": 20.0, - "resolution": 0.01, - "setpoint": 90.0, - "upper_bound": 90.0 - }, + "location": "9e4433a9d69f40b3aefd15e74395eaec", "model": "Generic heater", "model_id": "10.20", "name": "OpenTherm", @@ -421,6 +431,9 @@ "water_pressure": 1.4, "water_temperature": 37.3 }, + "switches": { + "dhw_cm_switch": false + }, "vendor": "Remeha B.V." }, "f61f1a2535f54f52ad006a3d18e459ca": { diff --git a/tests/components/plugwise/fixtures/m_adam_multiple_devices_per_zone/data.json b/tests/components/plugwise/fixtures/m_adam_multiple_devices_per_zone/data.json index dff7c2466..096a42917 100644 --- a/tests/components/plugwise/fixtures/m_adam_multiple_devices_per_zone/data.json +++ b/tests/components/plugwise/fixtures/m_adam_multiple_devices_per_zone/data.json @@ -23,12 +23,12 @@ "08963fec7c53423ca5680aa4cb502c63": { "active_preset": "away", "available_schedules": [ + "off", "CV Roan", "Bios Schema met Film Avond", "GF7 Woonkamer", "Badkamer Schema", - "CV Jessie", - "off" + "CV Jessie" ], "climate_mode": "auto", "control_state": "idle", @@ -64,12 +64,12 @@ "12493538af164a409c6a1c79e38afe1c": { "active_preset": "away", "available_schedules": [ + "off", "CV Roan", "Bios Schema met Film Avond", "GF7 Woonkamer", "Badkamer Schema", - "CV Jessie", - "off" + "CV Jessie" ], "climate_mode": "heat", "control_state": "idle", @@ -128,7 +128,7 @@ }, "446ac08dd04d4eff8ac57489757b7314": { "active_preset": "no_frost", - "available_schedules": [], + "available_schedules": ["off"], "climate_mode": "heat", "control_state": "idle", "dev_class": "climate", @@ -141,7 +141,7 @@ "vacation", "no_frost" ], - "select_schedule": null, + "select_schedule": "off", "sensors": { "temperature": 15.6 }, @@ -278,12 +278,12 @@ "82fa13f017d240daa0d0ea1775420f24": { "active_preset": "asleep", "available_schedules": [ + "off", "CV Roan", "Bios Schema met Film Avond", "GF7 Woonkamer", "Badkamer Schema", - "CV Jessie", - "off" + "CV Jessie" ], "climate_mode": "auto", "control_state": "idle", @@ -433,12 +433,12 @@ "c50f167537524366a5af7aa3942feb1e": { "active_preset": "home", "available_schedules": [ + "off", "CV Roan", "Bios Schema met Film Avond", "GF7 Woonkamer", "Badkamer Schema", - "CV Jessie", - "off" + "CV Jessie" ], "climate_mode": "auto", "control_state": "heating", diff --git a/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json b/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json index fb4085270..9b421f792 100644 --- a/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json +++ b/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json @@ -28,25 +28,27 @@ "heating_state": false, "secondary_boiler_state": false }, + "boiler_temperature": { + "current": 22.7, + "lower_bound": 0.0, + "resolution": 1.0, + "setpoint": 60.0, + "upper_bound": 100.0 + }, "dev_class": "heater_central", - "dhw_mode": "off", + "dhw_mode": "eco", "dhw_modes": [ "comfort", - "off" + "eco" ], - "location": "a57efe5f145f498c9be62a9b63626fbf", - "max_dhw_temperature": { + "dhw_temperature": { + "current": 41.5, "lower_bound": 35.0, "resolution": 0.01, "setpoint": 53.0, "upper_bound": 60.0 }, - "maximum_boiler_temperature": { - "lower_bound": 0.0, - "resolution": 1.0, - "setpoint": 60.0, - "upper_bound": 100.0 - }, + "location": "a57efe5f145f498c9be62a9b63626fbf", "model": "Generic heater/cooler", "name": "OpenTherm", "sensors": { @@ -58,13 +60,16 @@ "water_pressure": 1.57, "water_temperature": 22.7 }, + "switches": { + "dhw_cm_switch": false + }, "vendor": "Techneco" }, "3cb70739631c4d17a86b8b12e8a5161b": { "active_preset": "home", "available_schedules": [ - "standaard", - "off" + "off", + "standaard" ], "climate_mode": "auto", "control_state": "cooling", diff --git a/tests/components/plugwise/snapshots/test_diagnostics.ambr b/tests/components/plugwise/snapshots/test_diagnostics.ambr index c37b77e23..fa79f8117 100644 --- a/tests/components/plugwise/snapshots/test_diagnostics.ambr +++ b/tests/components/plugwise/snapshots/test_diagnostics.ambr @@ -25,12 +25,12 @@ '08963fec7c53423ca5680aa4cb502c63': dict({ 'active_preset': 'away', 'available_schedules': list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), 'climate_mode': 'auto', 'control_state': 'idle', @@ -67,12 +67,12 @@ '12493538af164a409c6a1c79e38afe1c': dict({ 'active_preset': 'away', 'available_schedules': list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), 'climate_mode': 'heat', 'control_state': 'idle', @@ -132,6 +132,7 @@ '446ac08dd04d4eff8ac57489757b7314': dict({ 'active_preset': 'no_frost', 'available_schedules': list([ + 'off', ]), 'climate_mode': 'heat', 'control_state': 'idle', @@ -145,7 +146,7 @@ 'vacation', 'no_frost', ]), - 'select_schedule': None, + 'select_schedule': 'off', 'sensors': dict({ 'temperature': 15.6, }), @@ -283,12 +284,12 @@ '82fa13f017d240daa0d0ea1775420f24': dict({ 'active_preset': 'asleep', 'available_schedules': list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), 'climate_mode': 'auto', 'control_state': 'idle', @@ -438,12 +439,12 @@ 'c50f167537524366a5af7aa3942feb1e': dict({ 'active_preset': 'home', 'available_schedules': list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), 'climate_mode': 'auto', 'control_state': 'heating', diff --git a/tests/components/plugwise/snapshots/test_number.ambr b/tests/components/plugwise/snapshots/test_number.ambr index 1fdd2ea6e..ed8383fff 100644 --- a/tests/components/plugwise/snapshots/test_number.ambr +++ b/tests/components/plugwise/snapshots/test_number.ambr @@ -609,64 +609,3 @@ 'state': '-0.5', }) # --- -# name: test_anna_number_entities[platforms0-True-anna_heatpump_heating][number.opentherm_maximum_boiler_temperature_setpoint-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': dict({ - : 100.0, - : 0.0, - : , - : 1.0, - }), - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': , - 'entity_id': 'number.opentherm_maximum_boiler_temperature_setpoint', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': 'Maximum boiler temperature setpoint', - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Maximum boiler temperature setpoint', - 'platform': 'plugwise', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': 'maximum_boiler_temperature', - 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-maximum_boiler_temperature', - 'unit_of_measurement': , - }) -# --- -# name: test_anna_number_entities[platforms0-True-anna_heatpump_heating][number.opentherm_maximum_boiler_temperature_setpoint-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - : 'temperature', - : 'OpenTherm Maximum boiler temperature setpoint', - : 100.0, - : 0.0, - : , - : 1.0, - : , - }), - 'context': , - 'entity_id': 'number.opentherm_maximum_boiler_temperature_setpoint', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': '60.0', - }) -# --- diff --git a/tests/components/plugwise/snapshots/test_select.ambr b/tests/components/plugwise/snapshots/test_select.ambr index 1b6804115..4e31d6aa9 100644 --- a/tests/components/plugwise/snapshots/test_select.ambr +++ b/tests/components/plugwise/snapshots/test_select.ambr @@ -133,11 +133,11 @@ 'area_id': None, 'capabilities': dict({ : list([ + 'off', 'Badkamer', 'Vakantie', 'Weekschema', 'Test', - 'off', ]), }), 'config_entry_id': , @@ -175,11 +175,11 @@ 'attributes': ReadOnlyDict({ : 'Bathroom Thermostat schedule', : list([ + 'off', 'Badkamer', 'Vakantie', 'Weekschema', 'Test', - 'off', ]), }), 'context': , @@ -259,11 +259,11 @@ 'area_id': None, 'capabilities': dict({ : list([ + 'off', 'Badkamer', 'Vakantie', 'Weekschema', 'Test', - 'off', ]), }), 'config_entry_id': , @@ -301,11 +301,11 @@ 'attributes': ReadOnlyDict({ : 'Living room Thermostat schedule', : list([ + 'off', 'Badkamer', 'Vakantie', 'Weekschema', 'Test', - 'off', ]), }), 'context': , @@ -386,7 +386,7 @@ 'capabilities': dict({ : list([ 'comfort', - 'off', + 'eco', ]), }), 'config_entry_id': , @@ -425,7 +425,7 @@ : 'OpenTherm DHW mode', : list([ 'comfort', - 'off', + 'eco', ]), }), 'context': , @@ -433,7 +433,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'off', + 'state': 'eco', }) # --- # name: test_adam_select_entities[platforms0][select.badkamer_thermostat_schedule-entry] @@ -444,12 +444,12 @@ 'area_id': None, 'capabilities': dict({ : list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), }), 'config_entry_id': , @@ -487,12 +487,12 @@ 'attributes': ReadOnlyDict({ : 'Badkamer Thermostat schedule', : list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), }), 'context': , @@ -511,12 +511,12 @@ 'area_id': None, 'capabilities': dict({ : list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), }), 'config_entry_id': , @@ -554,12 +554,12 @@ 'attributes': ReadOnlyDict({ : 'Bios Thermostat schedule', : list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), }), 'context': , @@ -570,6 +570,63 @@ 'state': 'off', }) # --- +# name: test_adam_select_entities[platforms0][select.garage_thermostat_schedule-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + 'off', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'select', + 'entity_category': None, + 'entity_id': 'select.garage_thermostat_schedule', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Thermostat schedule', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Thermostat schedule', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'select_schedule', + 'unique_id': '446ac08dd04d4eff8ac57489757b7314-select_schedule', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_select_entities[platforms0][select.garage_thermostat_schedule-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'Garage Thermostat schedule', + : list([ + 'off', + ]), + }), + 'context': , + 'entity_id': 'select.garage_thermostat_schedule', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_adam_select_entities[platforms0][select.jessie_thermostat_schedule-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ @@ -578,12 +635,12 @@ 'area_id': None, 'capabilities': dict({ : list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), }), 'config_entry_id': , @@ -621,12 +678,12 @@ 'attributes': ReadOnlyDict({ : 'Jessie Thermostat schedule', : list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), }), 'context': , @@ -645,12 +702,12 @@ 'area_id': None, 'capabilities': dict({ : list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), }), 'config_entry_id': , @@ -688,12 +745,12 @@ 'attributes': ReadOnlyDict({ : 'Woonkamer Thermostat schedule', : list([ + 'off', 'CV Roan', 'Bios Schema met Film Avond', 'GF7 Woonkamer', 'Badkamer Schema', 'CV Jessie', - 'off', ]), }), 'context': , diff --git a/tests/components/plugwise/snapshots/test_water_heater.ambr b/tests/components/plugwise/snapshots/test_water_heater.ambr index 2f3ef30d5..8ed967085 100644 --- a/tests/components/plugwise/snapshots/test_water_heater.ambr +++ b/tests/components/plugwise/snapshots/test_water_heater.ambr @@ -1,5 +1,67 @@ # serializer version: 1 -# name: test_adam_water_heater_snapshot[platforms0][water_heater.opentherm-entry] +# name: test_adam_water_heater_snapshot[platforms0][water_heater.opentherm_boiler-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : 90.0, + : 20.0, + : 0.5, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'water_heater', + 'entity_category': , + 'entity_id': 'water_heater.opentherm_boiler', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Boiler', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Boiler', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': 'boiler_temperature', + 'unique_id': 'e4684553153b44afbef2200885f379dc-boiler_temperature', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_water_heater_snapshot[platforms0][water_heater.opentherm_boiler-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 37.3, + : 'OpenTherm Boiler', + : 90.0, + : 20.0, + : , + : None, + : None, + : 0.5, + : 90.0, + }), + 'context': , + 'entity_id': 'water_heater.opentherm_boiler', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_adam_water_heater_snapshot[platforms0][water_heater.opentherm_domestic_hot_water-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ None, @@ -10,8 +72,9 @@ : 40.0, : list([ 'comfort', - 'off', + 'eco', ]), + : 0.5, }), 'config_entry_id': , 'config_subentry_id': , @@ -19,8 +82,8 @@ 'device_id': , 'disabled_by': None, 'domain': 'water_heater', - 'entity_category': None, - 'entity_id': 'water_heater.opentherm', + 'entity_category': , + 'entity_id': 'water_heater.opentherm_domestic_hot_water', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -28,47 +91,110 @@ 'labels': set({ }), 'name': None, - 'object_id_base': None, + 'object_id_base': 'Domestic hot water', 'options': dict({ }), 'original_device_class': None, 'original_icon': None, - 'original_name': None, + 'original_name': 'Domestic hot water', 'platform': 'plugwise', 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': , - 'translation_key': None, - 'unique_id': 'e4684553153b44afbef2200885f379dc-opentherm', + 'translation_key': 'dhw_temperature', + 'unique_id': 'e4684553153b44afbef2200885f379dc-dhw_temperature', 'unit_of_measurement': None, }) # --- -# name: test_adam_water_heater_snapshot[platforms0][water_heater.opentherm-state] +# name: test_adam_water_heater_snapshot[platforms0][water_heater.opentherm_domestic_hot_water-state] StateSnapshot({ 'attributes': ReadOnlyDict({ : 37.3, - : 'OpenTherm', + : 'OpenTherm Domestic hot water', : 60.0, : 40.0, : list([ 'comfort', - 'off', + 'eco', ]), - : 'off', + : 'eco', : , : None, : None, + : 0.5, : 60.0, }), 'context': , - 'entity_id': 'water_heater.opentherm', + 'entity_id': 'water_heater.opentherm_domestic_hot_water', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'eco', + }) +# --- +# name: test_anna_water_heater_snapshot[platforms0-False-anna_loria_cooling_active][water_heater.opentherm_boiler-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : 45.0, + : 25.0, + : 0.5, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'water_heater', + 'entity_category': , + 'entity_id': 'water_heater.opentherm_boiler', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Boiler', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Boiler', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': 'boiler_temperature', + 'unique_id': 'bfb5ee0a88e14e5f97bfa725a760cc49-boiler_temperature', + 'unit_of_measurement': None, + }) +# --- +# name: test_anna_water_heater_snapshot[platforms0-False-anna_loria_cooling_active][water_heater.opentherm_boiler-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 25.3, + : 'OpenTherm Boiler', + : 45.0, + : 25.0, + : , + : None, + : None, + : 0.5, + : 40.0, + }), + 'context': , + 'entity_id': 'water_heater.opentherm_boiler', 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'off', + 'state': 'on', }) # --- -# name: test_anna_water_heater_snapshot[platforms0-False-anna_v4_dhw][water_heater.opentherm-entry] +# name: test_anna_water_heater_snapshot[platforms0-False-anna_loria_cooling_active][water_heater.opentherm_domestic_hot_water-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ None, @@ -76,11 +202,15 @@ 'area_id': None, 'capabilities': dict({ : 60.0, - : 30.0, + : 35.0, : list([ - 'comfort', 'off', + 'auto', + 'boost', + 'eco', + 'comfort', ]), + : 0.5, }), 'config_entry_id': , 'config_subentry_id': , @@ -88,8 +218,8 @@ 'device_id': , 'disabled_by': None, 'domain': 'water_heater', - 'entity_category': None, - 'entity_id': 'water_heater.opentherm', + 'entity_category': , + 'entity_id': 'water_heater.opentherm_domestic_hot_water', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -97,43 +227,47 @@ 'labels': set({ }), 'name': None, - 'object_id_base': None, + 'object_id_base': 'Domestic hot water', 'options': dict({ }), 'original_device_class': None, 'original_icon': None, - 'original_name': None, + 'original_name': 'Domestic hot water', 'platform': 'plugwise', 'previous_unique_id': None, 'suggested_object_id': None, - 'supported_features': , - 'translation_key': None, - 'unique_id': 'cd0e6156b1f04d5f952349ffbe397481-opentherm', + 'supported_features': , + 'translation_key': 'dhw_temperature', + 'unique_id': 'bfb5ee0a88e14e5f97bfa725a760cc49-dhw_temperature', 'unit_of_measurement': None, }) # --- -# name: test_anna_water_heater_snapshot[platforms0-False-anna_v4_dhw][water_heater.opentherm-state] +# name: test_anna_water_heater_snapshot[platforms0-False-anna_loria_cooling_active][water_heater.opentherm_domestic_hot_water-state] StateSnapshot({ 'attributes': ReadOnlyDict({ - : 45.0, - : 'OpenTherm', + : 52.9, + : 'OpenTherm Domestic hot water', : 60.0, - : 30.0, + : 35.0, : list([ - 'comfort', 'off', + 'auto', + 'boost', + 'eco', + 'comfort', ]), - : 'off', - : , + : 'auto', + : , : None, : None, - : 60.0, + : 0.5, + : 53.0, }), 'context': , - 'entity_id': 'water_heater.opentherm', + 'entity_id': 'water_heater.opentherm_domestic_hot_water', 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'off', + 'state': 'auto', }) # --- diff --git a/tests/components/plugwise/test_climate.py b/tests/components/plugwise/test_climate.py index 05020fd1f..764e23b12 100644 --- a/tests/components/plugwise/test_climate.py +++ b/tests/components/plugwise/test_climate.py @@ -111,7 +111,7 @@ async def test_adam_climate_entity_climate_changes( ) assert mock_smile_adam.set_schedule_state.call_count == 2 mock_smile_adam.set_schedule_state.assert_called_with( - "c50f167537524366a5af7aa3942feb1e", STATE_OFF, "GF7 Woonkamer", + "c50f167537524366a5af7aa3942feb1e", "GF7 Woonkamer", STATE_OFF, ) with pytest.raises( @@ -159,7 +159,7 @@ async def test_adam_restore_state_climate( ( State("climate.living_room", "heat"), PlugwiseClimateExtraStoredData( - last_active_schedule=None, + last_active_schedule=STATE_OFF, previous_action_mode="heating", ).as_dict(), ), @@ -231,7 +231,7 @@ async def test_adam_restore_state_climate( ) # Verify set_schedule_state was called with the restored schedule mock_smile_adam_heat_cool.set_schedule_state.assert_called_with( - "f871b8c4d63549319221e294e4f88074", STATE_ON, "Badkamer" + "f871b8c4d63549319221e294e4f88074", "Badkamer", STATE_ON ) assert mock_smile_adam_heat_cool.set_schedule_state.call_count == 1 @@ -327,7 +327,7 @@ async def test_adam_off_regulation_mode_change( blocking=True, ) mock_smile_adam_heat_cool.set_schedule_state.assert_called_with( - "f871b8c4d63549319221e294e4f88074", STATE_OFF, "Badkamer" + "f871b8c4d63549319221e294e4f88074", "Badkamer", STATE_OFF ) @@ -462,7 +462,7 @@ async def test_adam_3_climate_entity_attributes( ) # And set_schedule_state was called with the restored last_active_schedule mock_smile_adam_heat_cool.set_schedule_state.assert_called_with( - "f871b8c4d63549319221e294e4f88074", STATE_ON, "Badkamer", + "f871b8c4d63549319221e294e4f88074", "Badkamer", STATE_ON, ) async def test_adam_climate_off_mode_change( @@ -587,7 +587,7 @@ async def test_anna_climate_entity_climate_changes( ) assert mock_smile_anna.set_schedule_state.call_count == 1 mock_smile_anna.set_schedule_state.assert_called_with( - "c784ee9fdab44e1395b8dee7d7a497d5", STATE_OFF, "standaard", + "c784ee9fdab44e1395b8dee7d7a497d5", "standaard", STATE_OFF, ) data = mock_smile_anna.async_update.return_value @@ -605,13 +605,13 @@ async def test_anna_climate_entity_climate_changes( ) assert mock_smile_anna.set_schedule_state.call_count == 2 mock_smile_anna.set_schedule_state.assert_called_with( - "c784ee9fdab44e1395b8dee7d7a497d5", STATE_ON, "standaard", + "c784ee9fdab44e1395b8dee7d7a497d5", "standaard", STATE_ON, ) # Mock user deleting last schedule from app or browser data = mock_smile_anna.async_update.return_value - data["3cb70739631c4d17a86b8b12e8a5161b"]["available_schedules"] = [] - data["3cb70739631c4d17a86b8b12e8a5161b"]["select_schedule"] = None + data["3cb70739631c4d17a86b8b12e8a5161b"]["available_schedules"] = [STATE_OFF] + data["3cb70739631c4d17a86b8b12e8a5161b"]["select_schedule"] = STATE_OFF data["3cb70739631c4d17a86b8b12e8a5161b"]["climate_mode"] = "heat_cool" with patch(HA_PLUGWISE_SMILE_ASYNC_UPDATE, return_value=data): freezer.tick(timedelta(minutes=1)) diff --git a/tests/components/plugwise/test_init.py b/tests/components/plugwise/test_init.py index 427d0e2de..1eeebf2eb 100644 --- a/tests/components/plugwise/test_init.py +++ b/tests/components/plugwise/test_init.py @@ -318,7 +318,7 @@ async def test_update_device( assert ( len(er.async_entries_for_config_entry(entity_registry, mock_config_entry.entry_id)) - == 53 + == 52 ) assert ( len(dr.async_entries_for_config_entry(device_registry, mock_config_entry.entry_id)) @@ -342,7 +342,7 @@ async def test_update_device( assert ( len(er.async_entries_for_config_entry(entity_registry, mock_config_entry.entry_id)) - == 60 + == 59 ) assert ( len(dr.async_entries_for_config_entry(device_registry, mock_config_entry.entry_id)) @@ -369,7 +369,7 @@ async def test_update_device( assert ( len(er.async_entries_for_config_entry(entity_registry, mock_config_entry.entry_id)) - == 53 + == 52 ) assert ( len(dr.async_entries_for_config_entry(device_registry, mock_config_entry.entry_id)) diff --git a/tests/components/plugwise/test_number.py b/tests/components/plugwise/test_number.py index 9acf82fb4..a7fa5caaa 100644 --- a/tests/components/plugwise/test_number.py +++ b/tests/components/plugwise/test_number.py @@ -81,25 +81,3 @@ async def test_anna_number_entities( ) -> None: """Test Anna number snapshot.""" await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) - - -@pytest.mark.parametrize("chosen_env", ["anna_heatpump_heating"], indirect=True) -@pytest.mark.parametrize("cooling_present", [True], indirect=True) -async def test_anna_max_boiler_temp_change( - hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry -) -> None: - """Test changing of number entities.""" - await hass.services.async_call( - NUMBER_DOMAIN, - SERVICE_SET_VALUE, - { - ATTR_ENTITY_ID: "number.opentherm_maximum_boiler_temperature_setpoint", - ATTR_VALUE: 65, - }, - blocking=True, - ) - - assert mock_smile_anna.set_number.call_count == 1 - mock_smile_anna.set_number.assert_called_with( - "1cbf783bb11e4a7c8a6843dee3a86927", "maximum_boiler_temperature", 65.0 - ) diff --git a/tests/components/plugwise/test_select.py b/tests/components/plugwise/test_select.py index 29d43c337..4ca25fda0 100644 --- a/tests/components/plugwise/test_select.py +++ b/tests/components/plugwise/test_select.py @@ -129,7 +129,8 @@ async def test_legacy_anna_select_entities( init_integration: MockConfigEntry, ) -> None: """Test no select-entity for a legacy Anna without schedule.""" - assert not hass.states.get("select.anna_thermostat_schedule") + assert (state := hass.states.get("select.anna_thermostat_schedule")) + assert state.state == "off" @pytest.mark.usefixtures("mock_smile_anna") diff --git a/tests/components/plugwise/test_water_heater.py b/tests/components/plugwise/test_water_heater.py index 3f2446637..a4eddb7b1 100644 --- a/tests/components/plugwise/test_water_heater.py +++ b/tests/components/plugwise/test_water_heater.py @@ -1,32 +1,37 @@ """Tests for the Plugwise water_heater platform.""" -from unittest.mock import MagicMock +from datetime import timedelta +from unittest.mock import MagicMock, patch import pytest +from freezegun.api import FrozenDateTimeFactory from homeassistant.components.water_heater import ( ATTR_OPERATION_MODE, DOMAIN as WATER_HEATER_DOMAIN, SERVICE_SET_OPERATION_MODE, SERVICE_SET_TEMPERATURE, + SERVICE_TURN_OFF, + SERVICE_TURN_ON, ) from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE from homeassistant.core import HomeAssistant +from homeassistant.exceptions import ServiceNotSupported from homeassistant.helpers import entity_registry as er from syrupy.assertion import SnapshotAssertion -from tests.common import MockConfigEntry, snapshot_platform +from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform HA_PLUGWISE_SMILE_ASYNC_UPDATE = ( "homeassistant.components.plugwise.coordinator.Smile.async_update" ) -@pytest.mark.usefixtures("mock_smile_adam_jip") @pytest.mark.parametrize("platforms", [(WATER_HEATER_DOMAIN,)]) @pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_adam_water_heater_snapshot( hass: HomeAssistant, + mock_smile_adam_jip: MagicMock, snapshot: SnapshotAssertion, entity_registry: er.EntityRegistry, setup_platform: MockConfigEntry, @@ -36,41 +41,141 @@ async def test_adam_water_heater_snapshot( async def test_adam_water_heater_setpoint_change( - hass: HomeAssistant, mock_smile_adam_jip: MagicMock, init_integration: MockConfigEntry + hass: HomeAssistant, + mock_smile_adam_jip: MagicMock, + init_integration: MockConfigEntry, ) -> None: """Test Adam water_heater setpoint-change.""" await hass.services.async_call( WATER_HEATER_DOMAIN, SERVICE_SET_TEMPERATURE, - {ATTR_ENTITY_ID: "water_heater.opentherm", ATTR_TEMPERATURE: 65}, + { + ATTR_ENTITY_ID: "water_heater.opentherm_domestic_hot_water", + ATTR_TEMPERATURE: 65, + }, blocking=True, ) assert mock_smile_adam_jip.set_number.call_count == 1 mock_smile_adam_jip.set_number.assert_called_with( - "e4684553153b44afbef2200885f379dc", "max_dhw_temperature", 65.0, + "e4684553153b44afbef2200885f379dc", + "dhw_temperature", + 65.0, ) + await hass.services.async_call( + WATER_HEATER_DOMAIN, + SERVICE_SET_TEMPERATURE, + { + ATTR_ENTITY_ID: "water_heater.opentherm_boiler", + ATTR_TEMPERATURE: 85, + }, + blocking=True, + ) + assert mock_smile_adam_jip.set_number.call_count == 2 + mock_smile_adam_jip.set_number.assert_called_with( + "e4684553153b44afbef2200885f379dc", + "boiler_temperature", + 85.0, + ) + + with pytest.raises(ServiceNotSupported): + await hass.services.async_call( + WATER_HEATER_DOMAIN, + SERVICE_SET_OPERATION_MODE, + { + ATTR_ENTITY_ID: "water_heater.opentherm_boiler", + ATTR_OPERATION_MODE: "eco", + }, + blocking=True, + ) + assert mock_smile_adam_jip.set_dhw_mode.call_count == 0 + await hass.services.async_call( WATER_HEATER_DOMAIN, SERVICE_SET_OPERATION_MODE, - {ATTR_ENTITY_ID: "water_heater.opentherm", ATTR_OPERATION_MODE: "off"}, + { + ATTR_ENTITY_ID: "water_heater.opentherm_domestic_hot_water", + ATTR_OPERATION_MODE: "eco", + }, blocking=True, ) assert mock_smile_adam_jip.set_dhw_mode.call_count == 1 mock_smile_adam_jip.set_dhw_mode.assert_called_with( - "dhw_mode", "e4684553153b44afbef2200885f379dc", 2, "off" + "dhw_mode", "e4684553153b44afbef2200885f379dc", "eco", 2, ) -@pytest.mark.usefixtures("mock_smile_anna") -@pytest.mark.parametrize("chosen_env", ["anna_v4_dhw"], indirect=True) + +@pytest.mark.parametrize("chosen_env", ["anna_loria_cooling_active"], indirect=True) @pytest.mark.parametrize("cooling_present", [False], indirect=True) @pytest.mark.parametrize("platforms", [(WATER_HEATER_DOMAIN,)]) @pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_anna_water_heater_snapshot( hass: HomeAssistant, + mock_smile_anna: MagicMock, snapshot: SnapshotAssertion, entity_registry: er.EntityRegistry, setup_platform: MockConfigEntry, ) -> None: """Test Anna water_heater snapshot with dhw_state on.""" await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) + + +@pytest.mark.parametrize("chosen_env", ["anna_loria_cooling_active"], indirect=True) +@pytest.mark.parametrize("cooling_present", [False], indirect=True) +async def test_anna_water_heater_mode_change( + hass: HomeAssistant, + mock_smile_anna: MagicMock, + init_integration: MockConfigEntry, + freezer: FrozenDateTimeFactory, +) -> None: + """Test Anna water_heater dhw_mode changes.""" + await hass.services.async_call( + WATER_HEATER_DOMAIN, + SERVICE_TURN_OFF, + { + ATTR_ENTITY_ID: "water_heater.opentherm_domestic_hot_water", + }, + blocking=True, + ) + assert mock_smile_anna.set_dhw_mode.call_count == 1 + mock_smile_anna.set_dhw_mode.assert_called_with( + "dhw_mode", "bfb5ee0a88e14e5f97bfa725a760cc49", "off", 5, + ) + + data = mock_smile_anna.async_update.return_value + data["bfb5ee0a88e14e5f97bfa725a760cc49"]["dhw_mode"] = "off" + with patch(HA_PLUGWISE_SMILE_ASYNC_UPDATE, return_value=data): + freezer.tick(timedelta(minutes=1)) + async_fire_time_changed(hass) + await hass.async_block_till_done() + + await hass.services.async_call( + WATER_HEATER_DOMAIN, + SERVICE_TURN_ON, + { + ATTR_ENTITY_ID: "water_heater.opentherm_domestic_hot_water", + }, + blocking=True, + ) + assert mock_smile_anna.set_dhw_mode.call_count == 2 + mock_smile_anna.set_dhw_mode.assert_called_with( + "dhw_mode", "bfb5ee0a88e14e5f97bfa725a760cc49", "eco", 5, + ) + + await hass.services.async_call( + WATER_HEATER_DOMAIN, + SERVICE_SET_OPERATION_MODE, + { + ATTR_ENTITY_ID: "water_heater.opentherm_domestic_hot_water", + ATTR_OPERATION_MODE: "boost", + }, + blocking=True, + ) + assert mock_smile_anna.set_dhw_mode.call_count == 3 + mock_smile_anna.set_dhw_mode.assert_called_with( + "dhw_mode", + "bfb5ee0a88e14e5f97bfa725a760cc49", + "boost", + 5, + ) +