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..23e5c8a65 100644 --- a/custom_components/plugwise/manifest.json +++ b/custom_components/plugwise/manifest.json @@ -7,7 +7,9 @@ "integration_type": "hub", "iot_class": "local_polling", "loggers": ["plugwise"], - "requirements": ["plugwise==1.12.0"], + "requirements": [ + "plugwise@git+https://github.com/plugwise/python-plugwise.git@water_heater_2" + ], "version": "0.65.0", "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/translations/en.json b/custom_components/plugwise/translations/en.json index 0015e95e4..d3436c798 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 temperature" + }, + "dhw_temperature": { + "name": "DHW temperature", + "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..2bccdbeae 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 temperatuur" + }, + "dhw_temperature": { + "name": "SWW temperatuur", + "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..424e32cb0 100644 --- a/custom_components/plugwise/water_heater.py +++ b/custom_components/plugwise/water_heater.py @@ -1,37 +1,62 @@ """Plugwise water heater component for HomeAssistant.""" +from dataclasses import dataclass from typing import Any, override from homeassistant.components.water_heater import ( 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 +75,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 +93,103 @@ 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 + temp_data = self.device.get(description.key, {}) + if temp_data: + self._attr_max_temp = temp_data.get(UPPER_BOUND, 75.0) + self._attr_min_temp = temp_data.get(LOWER_BOUND, 40.0) + self._attr_supported_features = WaterHeaterEntityFeature.TARGET_TEMPERATURE + if description.options_key is not None: + self._attr_supported_features |= WaterHeaterEntityFeature.OPERATION_MODE + self._attr_temperature_unit = UnitOfTemperature.CELSIUS + self._attr_unique_id = f"{device_id}-{description.key}" + self._list_type = 0 + self._mode_off = self.device.get(DHW_MODE) == STATE_OFF + self._operation_mode: str = STATE_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.get(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.get(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) + if self.operation_list is None: + return # pragma: no cover + + self._list_type = len(self.operation_list) + self._operation_mode = operation_mode + if self._operation_mode == STATE_OFF and not self._mode_off: + await self.async_turn_off() + return + + if self._mode_off and self._operation_mode != STATE_OFF: + await self.async_turn_on() + return + + await self.coordinator.api.set_dhw_mode(DHW_MODE, self._dev_id, self._list_type, self._operation_mode) + + @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, self._list_type, STATE_OFF + ) + self._mode_off = True + + @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, self._list_type, self._operation_mode + ) + self._mode_off = False @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)) + await self.coordinator.api.set_number( + self._dev_id, + self.entity_description.key, + float(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..1f0aa4196 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,24 @@ "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 + "intended_boiler_temperature": 22.5 } }, "10016900610d4c7481df78c89606ef22": { diff --git a/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json b/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json index 54a045273..53b710551 100644 --- a/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json +++ b/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json @@ -28,35 +28,35 @@ "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": { - "dhw_temperature": 46.3, "intended_boiler_temperature": 35.0, "modulation_level": 52, "outdoor_air_temperature": 3.0, "return_temperature": 25.1, - "water_pressure": 1.57, - "water_temperature": 29.1 + "water_pressure": 1.57 }, "vendor": "Techneco" }, 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..13c3b2432 --- /dev/null +++ b/tests/components/plugwise/fixtures/anna_loria_cooling_active/data.json @@ -0,0 +1,111 @@ +{ + "582dfbdace4d4aeb832923ce7d1ddda0": { + "active_preset": "home", + "available_schedules": [ + "Winter", + "Test ", + "off" + ], + "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": { + "intended_boiler_temperature": 0.0, + "modulation_level": 100, + "outdoor_air_temperature": 17.2, + "return_temperature": 26.3 + }, + "switches": { + "cooling_ena_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..4a7f5aa03 100644 --- a/tests/components/plugwise/fixtures/anna_p1/data.json +++ b/tests/components/plugwise/fixtures/anna_p1/data.json @@ -50,7 +50,7 @@ "dev_class": "heater_central", "dhw_modes": [ "comfort", - "off" + "eco" ], "location": "da7be222ab3b420c927f3e49fade0304", "model": "Generic heater", diff --git a/tests/components/plugwise/fixtures/anna_v4/data.json b/tests/components/plugwise/fixtures/anna_v4/data.json index 563560b49..cecb3e0a8 100644 --- a/tests/components/plugwise/fixtures/anna_v4/data.json +++ b/tests/components/plugwise/fixtures/anna_v4/data.json @@ -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", @@ -92,8 +94,7 @@ "intended_boiler_temperature": 39.9, "modulation_level": 0.0, "return_temperature": 32.0, - "water_pressure": 2.2, - "water_temperature": 45.0 + "water_pressure": 2.2 }, "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..01c6bb25d 100644 --- a/tests/components/plugwise/fixtures/anna_v4_dhw/data.json +++ b/tests/components/plugwise/fixtures/anna_v4_dhw/data.json @@ -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", @@ -92,8 +94,7 @@ "intended_boiler_temperature": 39.9, "modulation_level": 0.0, "return_temperature": 32.0, - "water_pressure": 2.2, - "water_temperature": 45.0 + "water_pressure": 2.2 }, "vendor": "Bosch Thermotechniek B.V." } diff --git a/tests/components/plugwise/fixtures/m_adam_cooling/data.json b/tests/components/plugwise/fixtures/m_adam_cooling/data.json index c5b321660..6aaec3e90 100644 --- a/tests/components/plugwise/fixtures/m_adam_cooling/data.json +++ b/tests/components/plugwise/fixtures/m_adam_cooling/data.json @@ -7,24 +7,24 @@ "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 + "intended_boiler_temperature": 17.5 } }, "14df5c4dc8cb4ba69f9d1ac0eaf7c5c6": { diff --git a/tests/components/plugwise/fixtures/m_adam_heating/data.json b/tests/components/plugwise/fixtures/m_adam_heating/data.json index f29aa84c7..ad2fb4df1 100644 --- a/tests/components/plugwise/fixtures/m_adam_heating/data.json +++ b/tests/components/plugwise/fixtures/m_adam_heating/data.json @@ -6,30 +6,31 @@ "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_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", + "select_dhw_mode": "eco", "sensors": { - "intended_boiler_temperature": 38.1, - "water_temperature": 37.0 + "intended_boiler_temperature": 38.1 } }, "14df5c4dc8cb4ba69f9d1ac0eaf7c5c6": { 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..9b2b1b245 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,31 @@ "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_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", + "select_dhw_mode": "eco", "sensors": { - "intended_boiler_temperature": 0.0, - "water_temperature": 37.0 + "intended_boiler_temperature": 0.0 } }, "14df5c4dc8cb4ba69f9d1ac0eaf7c5c6": { diff --git a/tests/components/plugwise/fixtures/m_adam_jip/data.json b/tests/components/plugwise/fixtures/m_adam_jip/data.json index ff33d77c2..28867a99d 100644 --- a/tests/components/plugwise/fixtures/m_adam_jip/data.json +++ b/tests/components/plugwise/fixtures/m_adam_jip/data.json @@ -392,25 +392,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", @@ -418,8 +420,7 @@ "intended_boiler_temperature": 0.0, "modulation_level": 0.0, "return_temperature": 37.1, - "water_pressure": 1.4, - "water_temperature": 37.3 + "water_pressure": 1.4 }, "vendor": "Remeha B.V." }, 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..018610533 100644 --- a/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json +++ b/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json @@ -28,35 +28,35 @@ "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": { - "dhw_temperature": 41.5, "intended_boiler_temperature": 0.0, "modulation_level": 40, "outdoor_air_temperature": 28.0, "return_temperature": 23.8, - "water_pressure": 1.57, - "water_temperature": 22.7 + "water_pressure": 1.57 }, "vendor": "Techneco" }, 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..f9427f3b9 100644 --- a/tests/components/plugwise/snapshots/test_select.ambr +++ b/tests/components/plugwise/snapshots/test_select.ambr @@ -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] diff --git a/tests/components/plugwise/snapshots/test_sensor.ambr b/tests/components/plugwise/snapshots/test_sensor.ambr index 87fe0b387..8b430581f 100644 --- a/tests/components/plugwise/snapshots/test_sensor.ambr +++ b/tests/components/plugwise/snapshots/test_sensor.ambr @@ -1202,64 +1202,6 @@ 'state': '38.1', }) # --- -# name: test_adam_sensor_snapshot[platforms0-False-m_adam_heating][sensor.opentherm_water_temperature-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': dict({ - : , - }), - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'sensor', - 'entity_category': , - 'entity_id': 'sensor.opentherm_water_temperature', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': 'Water temperature', - 'options': dict({ - 'sensor': dict({ - 'suggested_display_precision': 1, - }), - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Water temperature', - 'platform': 'plugwise', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': 'water_temperature', - 'unique_id': '056ee145a816487eaa69243c3280f8bf-water_temperature', - 'unit_of_measurement': , - }) -# --- -# name: test_adam_sensor_snapshot[platforms0-False-m_adam_heating][sensor.opentherm_water_temperature-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - : 'temperature', - : 'OpenTherm Water temperature', - : , - : , - }), - 'context': , - 'entity_id': 'sensor.opentherm_water_temperature', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': '37.0', - }) -# --- # name: test_adam_sensor_snapshot[platforms0-False-m_adam_heating][sensor.tom_badkamer_battery-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ @@ -3501,64 +3443,6 @@ 'state': '19.3', }) # --- -# name: test_anna_sensor_snapshot[platforms0-True-anna_heatpump_heating][sensor.opentherm_dhw_temperature-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': dict({ - : , - }), - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'sensor', - 'entity_category': , - 'entity_id': 'sensor.opentherm_dhw_temperature', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': 'DHW temperature', - 'options': dict({ - 'sensor': dict({ - 'suggested_display_precision': 1, - }), - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'DHW temperature', - 'platform': 'plugwise', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': 'dhw_temperature', - 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-dhw_temperature', - 'unit_of_measurement': , - }) -# --- -# name: test_anna_sensor_snapshot[platforms0-True-anna_heatpump_heating][sensor.opentherm_dhw_temperature-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - : 'temperature', - : 'OpenTherm DHW temperature', - : , - : , - }), - 'context': , - 'entity_id': 'sensor.opentherm_dhw_temperature', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': '46.3', - }) -# --- # name: test_anna_sensor_snapshot[platforms0-True-anna_heatpump_heating][sensor.opentherm_intended_boiler_temperature-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ @@ -3845,64 +3729,6 @@ 'state': '1.57', }) # --- -# name: test_anna_sensor_snapshot[platforms0-True-anna_heatpump_heating][sensor.opentherm_water_temperature-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': dict({ - : , - }), - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'sensor', - 'entity_category': , - 'entity_id': 'sensor.opentherm_water_temperature', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': 'Water temperature', - 'options': dict({ - 'sensor': dict({ - 'suggested_display_precision': 1, - }), - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Water temperature', - 'platform': 'plugwise', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': 'water_temperature', - 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-water_temperature', - 'unit_of_measurement': , - }) -# --- -# name: test_anna_sensor_snapshot[platforms0-True-anna_heatpump_heating][sensor.opentherm_water_temperature-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - : 'temperature', - : 'OpenTherm Water temperature', - : , - : , - }), - 'context': , - 'entity_id': 'sensor.opentherm_water_temperature', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': '29.1', - }) -# --- # name: test_anna_sensor_snapshot[platforms0-True-anna_heatpump_heating][sensor.smile_anna_outdoor_temperature-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/plugwise/snapshots/test_water_heater.ambr b/tests/components/plugwise/snapshots/test_water_heater.ambr index 2f3ef30d5..0311ec93d 100644 --- a/tests/components/plugwise/snapshots/test_water_heater.ambr +++ b/tests/components/plugwise/snapshots/test_water_heater.ambr @@ -1,5 +1,65 @@ # 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_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : 90.0, + : 20.0, + }), + '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_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Boiler temperature', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Boiler temperature', + '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_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 37.3, + : 'OpenTherm Boiler temperature', + : 90.0, + : 20.0, + : , + : None, + : None, + : 90.0, + }), + 'context': , + 'entity_id': 'water_heater.opentherm_boiler_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_adam_water_heater_snapshot[platforms0][water_heater.opentherm_dhw_temperature-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ None, @@ -10,7 +70,7 @@ : 40.0, : list([ 'comfort', - 'off', + 'eco', ]), }), 'config_entry_id': , @@ -19,8 +79,8 @@ 'device_id': , 'disabled_by': None, 'domain': 'water_heater', - 'entity_category': None, - 'entity_id': 'water_heater.opentherm', + 'entity_category': , + 'entity_id': 'water_heater.opentherm_dhw_temperature', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -28,47 +88,107 @@ 'labels': set({ }), 'name': None, - 'object_id_base': None, + 'object_id_base': 'DHW temperature', 'options': dict({ }), 'original_device_class': None, 'original_icon': None, - 'original_name': None, + 'original_name': 'DHW temperature', '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_dhw_temperature-state] StateSnapshot({ 'attributes': ReadOnlyDict({ : 37.3, - : 'OpenTherm', + : 'OpenTherm DHW temperature', : 60.0, : 40.0, : list([ 'comfort', - 'off', + 'eco', ]), - : 'off', + : 'eco', : , : None, : None, : 60.0, }), 'context': , - 'entity_id': 'water_heater.opentherm', + 'entity_id': 'water_heater.opentherm_dhw_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'eco', + }) +# --- +# name: test_anna_water_heater_snapshot[platforms0-False-anna_loria_cooling_active][water_heater.opentherm_boiler_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : 45.0, + : 25.0, + }), + '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_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Boiler temperature', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Boiler temperature', + '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_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 25.3, + : 'OpenTherm Boiler temperature', + : 45.0, + : 25.0, + : , + : None, + : None, + : 40.0, + }), + 'context': , + 'entity_id': 'water_heater.opentherm_boiler_temperature', '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_dhw_temperature-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ None, @@ -76,10 +196,13 @@ 'area_id': None, 'capabilities': dict({ : 60.0, - : 30.0, + : 35.0, : list([ - 'comfort', 'off', + 'auto', + 'boost', + 'eco', + 'comfort', ]), }), 'config_entry_id': , @@ -88,8 +211,8 @@ 'device_id': , 'disabled_by': None, 'domain': 'water_heater', - 'entity_category': None, - 'entity_id': 'water_heater.opentherm', + 'entity_category': , + 'entity_id': 'water_heater.opentherm_dhw_temperature', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -97,43 +220,46 @@ 'labels': set({ }), 'name': None, - 'object_id_base': None, + 'object_id_base': 'DHW temperature', 'options': dict({ }), 'original_device_class': None, 'original_icon': None, - 'original_name': None, + 'original_name': 'DHW temperature', 'platform': 'plugwise', 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': , - 'translation_key': None, - 'unique_id': 'cd0e6156b1f04d5f952349ffbe397481-opentherm', + '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_dhw_temperature-state] StateSnapshot({ 'attributes': ReadOnlyDict({ - : 45.0, - : 'OpenTherm', + : 52.9, + : 'OpenTherm DHW temperature', : 60.0, - : 30.0, + : 35.0, : list([ - 'comfort', 'off', + 'auto', + 'boost', + 'eco', + 'comfort', ]), - : 'off', + : 'auto', : , : None, : None, - : 60.0, + : 53.0, }), 'context': , - 'entity_id': 'water_heater.opentherm', + 'entity_id': 'water_heater.opentherm_dhw_temperature', 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'off', + 'state': 'auto', }) # --- diff --git a/tests/components/plugwise/test_init.py b/tests/components/plugwise/test_init.py index 5bee97c70..f85c97a59 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 87ea6f1f9..7279276b9 100644 --- a/tests/components/plugwise/test_number.py +++ b/tests/components/plugwise/test_number.py @@ -80,25 +80,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_water_heater.py b/tests/components/plugwise/test_water_heater.py index 11bc7af3a..83bc10deb 100644 --- a/tests/components/plugwise/test_water_heater.py +++ b/tests/components/plugwise/test_water_heater.py @@ -1,9 +1,10 @@ """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, @@ -12,10 +13,11 @@ ) 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" @@ -42,27 +44,36 @@ async def 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_dhw_temperature", 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, ) + with pytest.raises(ServiceNotSupported): + await hass.services.async_call( + WATER_HEATER_DOMAIN, + SERVICE_SET_OPERATION_MODE, + {ATTR_ENTITY_ID: "water_heater.opentherm_boiler_temperature", 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_dhw_temperature", 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", 2, "eco" ) -@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") @@ -75,3 +86,42 @@ async def test_anna_water_heater_snapshot( ) -> 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_SET_OPERATION_MODE, + {ATTR_ENTITY_ID: "water_heater.opentherm_dhw_temperature", ATTR_OPERATION_MODE: "off"}, + blocking=True, + ) + assert mock_smile_anna.set_dhw_mode.call_count == 1 + mock_smile_anna.set_dhw_mode.assert_called_with( + "dhw_mode", "bfb5ee0a88e14e5f97bfa725a760cc49", 5, "off" + ) + + 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_SET_OPERATION_MODE, + {ATTR_ENTITY_ID: "water_heater.opentherm_dhw_temperature", ATTR_OPERATION_MODE: "boost"}, + blocking=True, + ) + assert mock_smile_anna.set_dhw_mode.call_count == 2 + mock_smile_anna.set_dhw_mode.assert_called_with( + "dhw_mode", "bfb5ee0a88e14e5f97bfa725a760cc49", 5, "boost" + )