diff --git a/custom_components/plugwise/const.py b/custom_components/plugwise/const.py index 99f66b67b..0c741b718 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,11 @@ "regulation_modes", "zone_profiles", ] +type WaterHeaterType = Literal[ + "boiler_temperature", + "dhw_temperature", +] +type WaterHeaterOptionsType = Literal[ + "boiler_modes", + "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..0c7687071 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,14 +293,11 @@ } }, "water_heater": { - "plugwise": { - "state": { - "auto": "Auto", - "boost": "Boost", - "comfort": "Comfort", - "eco": "Eco", - "off": "Off" - } + "boiler_temperature": { + "name": "Boiler temperatuur" + }, + "dhw_temperature": { + "name": "SWW temperatuur" } } }, diff --git a/custom_components/plugwise/water_heater.py b/custom_components/plugwise/water_heater.py index 8b3beade2..41907023d 100644 --- a/custom_components/plugwise/water_heater.py +++ b/custom_components/plugwise/water_heater.py @@ -1,38 +1,61 @@ """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 ( 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 +@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, entry: PlugwiseConfigEntry, @@ -50,9 +73,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,61 +91,67 @@ 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) - self._attr_unique_id = f"{device_id}-water_heater" - - 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}" @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]: - """Return the list of available operation modes.""" - if (op_list := self.device.get(DHW_MODES, [])): - return op_list - return [STATE_OFF] # pragma: no cover + """Return the list of available operation modes. + + When no list is available the water_heater only has an "on" mode. + """ + if self.entity_description.options_key is not None: + op_list = self.device.get(self.entity_description.options_key) + if op_list is not None: + return cast(list[str], op_list) + + return [STATE_ON] @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.""" + if self.entity_description.options_key is None: + return list_type: int = len(self.operation_list) await self.coordinator.api.set_dhw_mode(DHW_MODE, self._dev_id, list_type, operation_mode) @@ -125,4 +160,8 @@ async def async_set_operation_mode(self, operation_mode: str) -> None: 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_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 634cca64c..0d4c3a827 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-water_heater', + '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_v4_dhw][water_heater.opentherm_boiler_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : 100.0, + : 0.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': 'cd0e6156b1f04d5f952349ffbe397481-boiler_temperature', + 'unit_of_measurement': None, + }) +# --- +# name: test_anna_water_heater_snapshot[platforms0-False-anna_v4_dhw][water_heater.opentherm_boiler_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 45.0, + : 'OpenTherm Boiler temperature', + : 100.0, + : 0.0, + : , + : None, + : None, + : 70.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_v4_dhw][water_heater.opentherm_dhw_temperature-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ None, @@ -79,7 +199,7 @@ : 30.0, : list([ 'comfort', - 'off', + 'eco', ]), }), 'config_entry_id': , @@ -88,8 +208,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 +217,43 @@ '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-water_heater', + 'translation_key': 'dhw_temperature', + 'unique_id': 'cd0e6156b1f04d5f952349ffbe397481-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_v4_dhw][water_heater.opentherm_dhw_temperature-state] StateSnapshot({ 'attributes': ReadOnlyDict({ : 45.0, - : 'OpenTherm', + : 'OpenTherm DHW temperature', : 60.0, : 30.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': 'off', + 'state': 'eco', }) # --- diff --git a/tests/components/plugwise/test_init.py b/tests/components/plugwise/test_init.py index bd5dbf89f..1369f0ac1 100644 --- a/tests/components/plugwise/test_init.py +++ b/tests/components/plugwise/test_init.py @@ -287,7 +287,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)) @@ -311,7 +311,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)) @@ -338,7 +338,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..974b16a07 100644 --- a/tests/components/plugwise/test_water_heater.py +++ b/tests/components/plugwise/test_water_heater.py @@ -42,23 +42,23 @@ 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, ) 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" )