diff --git a/CHANGELOG.md b/CHANGELOG.md index ad06f595a..97f359555 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,9 @@ Versions from 0.40 and up -## Ongoing +## v0.65.0 +- Replace DHW_comfort_mode switch by a select or a water_heater, bump plugwise to [v1.12.0](https://github.com/plugwise/python-plugwise/releases/tag/v1.12.0) via PR [#1085](https://github.com/plugwise/plugwise-beta/pull/1085) - Downstream Core updates via PR [#1084](https://github.com/plugwise/plugwise-beta/pull/1084) ## v0.64.4 diff --git a/custom_components/plugwise/const.py b/custom_components/plugwise/const.py index d4e25a26f..99f66b67b 100644 --- a/custom_components/plugwise/const.py +++ b/custom_components/plugwise/const.py @@ -131,6 +131,7 @@ # Select constants AVAILABLE_SCHEDULES: Final = "available_schedules" +DHW_MODE: Final = "dhw_mode" DHW_MODES: Final = "dhw_modes" GATEWAY_MODES: Final = "gateway_modes" REGULATION_MODES: Final = "regulation_modes" @@ -165,6 +166,7 @@ Platform.SELECT, Platform.SENSOR, Platform.SWITCH, + Platform.WATER_HEATER, ] SERVICE_DELETE: Final = "delete_notification" SEVERITIES: Final[list[str]] = ["other", "info", "message", "warning", "error"] diff --git a/custom_components/plugwise/manifest.json b/custom_components/plugwise/manifest.json index eccee39a2..09f91d310 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.11.4"], - "version": "0.64.4", + "requirements": ["plugwise==1.12.0"], + "version": "0.65.0", "zeroconf": ["_plugwise._tcp.local."] } diff --git a/custom_components/plugwise/number.py b/custom_components/plugwise/number.py index cc3f79242..29122649e 100644 --- a/custom_components/plugwise/number.py +++ b/custom_components/plugwise/number.py @@ -16,7 +16,6 @@ LOGGER, LOWER_BOUND, MAX_BOILER_TEMP, - MAX_DHW_TEMP, RESOLUTION, TEMPERATURE_OFFSET, UPPER_BOUND, @@ -47,13 +46,6 @@ class PlugwiseNumberEntityDescription(NumberEntityDescription): entity_category=EntityCategory.CONFIG, native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), - PlugwiseNumberEntityDescription( - key=MAX_DHW_TEMP, - translation_key=MAX_DHW_TEMP, - device_class=NumberDeviceClass.TEMPERATURE, - entity_category=EntityCategory.CONFIG, - native_unit_of_measurement=UnitOfTemperature.CELSIUS, - ), PlugwiseNumberEntityDescription( key=TEMPERATURE_OFFSET, translation_key=TEMPERATURE_OFFSET, diff --git a/custom_components/plugwise/select.py b/custom_components/plugwise/select.py index fa4b0bb49..5fae768e5 100644 --- a/custom_components/plugwise/select.py +++ b/custom_components/plugwise/select.py @@ -130,9 +130,12 @@ def __init__( self._attr_unique_id = f"{device_id}-{entity_description.key}" self.entity_description = entity_description - self._location = device_id - if (location := self.device.get(LOCATION)) is not None: - self._location = location + self._device_or_location = device_id + if ( + self.entity_description.key in (SELECT_SCHEDULE, SELECT_ZONE_PROFILE) + and (location := self.device.get(LOCATION)) is not None + ): + self._device_or_location = location @property def current_option(self) -> str | None: @@ -148,10 +151,12 @@ def options(self) -> list[str]: async def async_select_option(self, option: str) -> None: """Change to the selected entity option. - Location ID and STATE_ON are required for the thermostat-schedule select. + Appliance ID (= device_id) is required for the dhw_mode select + Locattion ID is required for the thermostat-schedule and zone_profile selects. + STATE_ON is required for the thermostat-schedule select. """ await self.coordinator.api.set_select( - self.entity_description.key, self._location, option, STATE_ON + self.entity_description.key, self._device_or_location, option, STATE_ON ) LOGGER.debug( "Set %s to %s was successful", diff --git a/custom_components/plugwise/strings.json b/custom_components/plugwise/strings.json deleted file mode 100644 index 7616000b7..000000000 --- a/custom_components/plugwise/strings.json +++ /dev/null @@ -1,352 +0,0 @@ -{ - "config": { - "abort": { - "already_configured": "Device is already configured", - "anna_with_adam": "Both Anna and Adam detected. Add your Adam instead of your Anna", - "not_the_same_smile": "The provided Smile-ID does not match your device", - "reconfigure_successful": "Reconfiguration was successful" - }, - "error": { - "cannot_connect": "Failed to connect", - "invalid_auth": "Invalid authentication", - "invalid_setup": "Add your Adam instead of your Anna, see the documentation", - "response_error": "Invalid XML-data or error indication received", - "unknown": "Unexpected error", - "unsupported": "Device with unsupported firmware" - }, - "step": { - "reconfigure": { - "data": { - "host": "IP address" - }, - "data_description": { - "host": "The hostname or IP address of your Smile. You can find it in your router or the Plugwise app." - }, - "description": "Update configuration for {title}." - }, - "user": { - "data": { - "host": "IP address", - "password": "Smile-ID", - "port": "Port", - "username": "Smile username" - }, - "data_description": { - "host": "The hostname or IP address of your Smile. You can find it in your router or the Plugwise app.", - "password": "The Smile-ID printed on the label on the back of your Adam, P1, Smile-T, or Stretch.", - "port": "By default your Smile uses port 80, normally you should not have to change this.", - "username": "Default is `smile`, or `stretch` for the legacy Stretch." - }, - "description": "Enter your Plugwise device data: (setup can take up to 90s)", - "title": "Set up Plugwise Adam/Smile/Stretch" - } - } - }, - "entity": { - "binary_sensor": { - "compressor_state": { - "name": "Compressor state" - }, - "cooling_enabled": { - "name": "Cooling enabled" - }, - "cooling_state": { - "name": "Cooling" - }, - "dhw_state": { - "name": "DHW state" - }, - "flame_state": { - "name": "Flame state" - }, - "heating_state": { - "name": "Heating" - }, - "low_battery": { - "name": "Battery status" - }, - "plugwise_notification": { - "name": "Plugwise notification" - }, - "secondary_boiler_state": { - "name": "Secondary boiler state" - } - }, - "button": { - "reboot": { - "name": "Reboot" - } - }, - "climate": { - "plugwise": { - "state_attributes": { - "preset_mode": { - "state": { - "asleep": "Night", - "away": "Away", - "home": "Home", - "no_frost": "Anti-frost", - "vacation": "Vacation" - } - } - } - } - }, - "number": { - "max_dhw_temperature": { - "name": "Domestic hot water setpoint" - }, - "maximum_boiler_temperature": { - "name": "Maximum boiler temperature setpoint" - }, - "temperature_offset": { - "name": "Temperature offset" - } - }, - "select": { - "select_dhw_mode": { - "name": "DHW mode", - "state": { - "auto": "Auto", - "boost": "Boost", - "comfort": "Comfort", - "off": "Off" - } - }, - "select_gateway_mode": { - "name": "Gateway mode", - "state": { - "away": "Pause", - "full": "Normal", - "vacation": "Vacation" - } - }, - "select_regulation_mode": { - "name": "Regulation mode", - "state": { - "bleeding_cold": "Bleeding cold", - "bleeding_hot": "Bleeding hot", - "cooling": "Cooling", - "heating": "Heating", - "off": "Off" - } - }, - "select_schedule": { - "name": "Thermostat schedule", - "state": { - "off": "Off" - } - }, - "select_zone_profile": { - "name": "Zone profile", - "state": { - "active": "Active", - "off": "Off", - "passive": "Passive" - } - } - }, - "sensor": { - "cooling_setpoint": { - "name": "Cooling setpoint" - }, - "dhw_temperature": { - "name": "DHW temperature" - }, - "domestic_hot_water_setpoint": { - "name": "DHW setpoint" - }, - "electricity_consumed": { - "name": "Electricity consumed" - }, - "electricity_consumed_interval": { - "name": "Electricity consumed interval" - }, - "electricity_consumed_off_peak_cumulative": { - "name": "Electricity consumed off-peak cumulative" - }, - "electricity_consumed_off_peak_interval": { - "name": "Electricity consumed off-peak interval" - }, - "electricity_consumed_off_peak_point": { - "name": "Electricity consumed off-peak point" - }, - "electricity_consumed_peak_cumulative": { - "name": "Electricity consumed peak cumulative" - }, - "electricity_consumed_peak_interval": { - "name": "Electricity consumed peak interval" - }, - "electricity_consumed_peak_point": { - "name": "Electricity consumed peak point" - }, - "electricity_consumed_point": { - "name": "Electricity consumed point" - }, - "electricity_phase_one_consumed": { - "name": "Electricity phase one consumed" - }, - "electricity_phase_one_produced": { - "name": "Electricity phase one produced" - }, - "electricity_phase_three_consumed": { - "name": "Electricity phase three consumed" - }, - "electricity_phase_three_produced": { - "name": "Electricity phase three produced" - }, - "electricity_phase_two_consumed": { - "name": "Electricity phase two consumed" - }, - "electricity_phase_two_produced": { - "name": "Electricity phase two produced" - }, - "electricity_produced": { - "name": "Electricity produced" - }, - "electricity_produced_interval": { - "name": "Electricity produced interval" - }, - "electricity_produced_off_peak_cumulative": { - "name": "Electricity produced off-peak cumulative" - }, - "electricity_produced_off_peak_interval": { - "name": "Electricity produced off-peak interval" - }, - "electricity_produced_off_peak_point": { - "name": "Electricity produced off-peak point" - }, - "electricity_produced_peak_cumulative": { - "name": "Electricity produced peak cumulative" - }, - "electricity_produced_peak_interval": { - "name": "Electricity produced peak interval" - }, - "electricity_produced_peak_point": { - "name": "Electricity produced peak point" - }, - "electricity_produced_point": { - "name": "Electricity produced point" - }, - "gas_consumed_cumulative": { - "name": "Gas consumed cumulative" - }, - "gas_consumed_interval": { - "name": "Gas consumed interval" - }, - "heating_setpoint": { - "name": "Heating setpoint" - }, - "intended_boiler_temperature": { - "name": "Intended boiler temperature" - }, - "maximum_boiler_temperature": { - "name": "Maximum boiler temperature" - }, - "modulation_level": { - "name": "Modulation level" - }, - "net_electricity_cumulative": { - "name": "Net electricity cumulative" - }, - "net_electricity_point": { - "name": "Net electricity point" - }, - "outdoor_air_temperature": { - "name": "Outdoor air temperature" - }, - "outdoor_temperature": { - "name": "Outdoor temperature" - }, - "return_temperature": { - "name": "Return temperature" - }, - "setpoint": { - "name": "Setpoint" - }, - "temperature_difference": { - "name": "Temperature difference" - }, - "valve_position": { - "name": "Valve position" - }, - "voltage_phase_one": { - "name": "Voltage phase one" - }, - "voltage_phase_three": { - "name": "Voltage phase three" - }, - "voltage_phase_two": { - "name": "Voltage phase two" - }, - "water_pressure": { - "name": "Water pressure" - }, - "water_temperature": { - "name": "Water temperature" - } - }, - "switch": { - "cooling_ena_switch": { - "name": "Cooling" - }, - "dhw_cm_switch": { - "name": "DHW comfort mode" - }, - "lock": { - "name": "Lock" - }, - "relay": { - "name": "Relay" - } - } - }, - "exceptions": { - "authentication_failed": { - "message": "Invalid authentication" - }, - "data_incomplete_or_missing": { - "message": "Data incomplete or missing" - }, - "error_communicating_with_api": { - "message": "Error communicating with API: {error}" - }, - "failed_to_connect": { - "message": "Failed to connect" - }, - "invalid_setup": { - "message": "Add your Adam instead of your Anna, see the documentation" - }, - "response_error": { - "message": "Invalid XML-data or error indication received" - }, - "set_schedule_first": { - "message": "Failed setting HVACMode, set a schedule first" - }, - "unsupported_firmware": { - "message": "Device with unsupported firmware" - } - }, - "options": { - "step": { - "init": { - "data": { - "cooling_on": "Anna: cooling-mode is on", - "refresh_interval": "Frontend refresh-time (1.5 - 5 seconds) *) beta-only option", - "scan_interval": "Scan interval (seconds) *) beta-only option" - }, - "description": "Adjust Adam/Smile/Stretch options" - }, - "none": { - "description": "This integration does not provide any options", - "title": "No options available" - } - } - }, - "services": { - "delete_notification": { - "description": "Deletes a Plugwise notification", - "name": "Delete Plugwise notification" - } - } -} diff --git a/custom_components/plugwise/switch.py b/custom_components/plugwise/switch.py index 2edfb7842..2a4b25382 100644 --- a/custom_components/plugwise/switch.py +++ b/custom_components/plugwise/switch.py @@ -16,7 +16,6 @@ from .const import ( COOLING_ENA_SWITCH, - DHW_CM_SWITCH, LOCK, LOGGER, # pw-beta MEMBERS, @@ -41,12 +40,6 @@ class PlugwiseSwitchEntityDescription(SwitchEntityDescription): # Upstream consts PLUGWISE_SWITCHES: tuple[PlugwiseSwitchEntityDescription, ...] = ( - PlugwiseSwitchEntityDescription( - key=DHW_CM_SWITCH, - translation_key=DHW_CM_SWITCH, - device_class=SwitchDeviceClass.SWITCH, - entity_category=EntityCategory.CONFIG, - ), PlugwiseSwitchEntityDescription( key=LOCK, translation_key=LOCK, diff --git a/custom_components/plugwise/translations/en.json b/custom_components/plugwise/translations/en.json index 7616000b7..0015e95e4 100644 --- a/custom_components/plugwise/translations/en.json +++ b/custom_components/plugwise/translations/en.json @@ -107,8 +107,6 @@ "select_dhw_mode": { "name": "DHW mode", "state": { - "auto": "Auto", - "boost": "Boost", "comfort": "Comfort", "off": "Off" } @@ -299,6 +297,17 @@ "relay": { "name": "Relay" } + }, + "water_heater": { + "plugwise": { + "state": { + "auto": "Auto", + "boost": "Boost", + "comfort": "Comfort", + "eco": "Eco", + "off": "Off" + } + } } }, "exceptions": { diff --git a/custom_components/plugwise/translations/nl.json b/custom_components/plugwise/translations/nl.json index d358f55f5..b76c57143 100644 --- a/custom_components/plugwise/translations/nl.json +++ b/custom_components/plugwise/translations/nl.json @@ -107,8 +107,6 @@ "select_dhw_mode": { "name": "SWW modus", "state": { - "auto": "Automatisch", - "boost": "Boost", "comfort": "Comfort", "off": "Uit" } @@ -299,6 +297,17 @@ "relay": { "name": "Schakelaar" } + }, + "water_heater": { + "plugwise": { + "state": { + "auto": "Auto", + "boost": "Boost", + "comfort": "Comfort", + "eco": "Eco", + "off": "Off" + } + } } }, "exceptions": { diff --git a/custom_components/plugwise/water_heater.py b/custom_components/plugwise/water_heater.py new file mode 100644 index 000000000..915dd2ab3 --- /dev/null +++ b/custom_components/plugwise/water_heater.py @@ -0,0 +1,122 @@ +"""Plugwise water heater component for HomeAssistant.""" + +from typing import Any + +from homeassistant.components.water_heater import ( + WaterHeaterEntity, + WaterHeaterEntityFeature, +) +from homeassistant.const import ( + ATTR_NAME, + ATTR_TEMPERATURE, + STATE_OFF, + UnitOfTemperature, +) +from homeassistant.core import HomeAssistant, callback +from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback + +from .const import ( + DHW_MODE, + DHW_MODES, + DHW_SETPOINT, + DHW_TEMP, + LOGGER, + LOWER_BOUND, + MAX_DHW_TEMP, + SENSORS, + TARGET_TEMP, + UPPER_BOUND, + WATER_TEMP, +) +from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator +from .entity import PlugwiseEntity +from .util import plugwise_command + + +async def async_setup_entry( + _hass: HomeAssistant, + entry: PlugwiseConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, +) -> None: + """Set up Plugwise water_heater from a config entry.""" + coordinator = entry.runtime_data + + @callback + def _add_entities() -> None: + """Add Entities.""" + if not coordinator.new_devices: + return + + 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]) + async_add_entities(entities) + + _add_entities() + entry.async_on_unload(coordinator.async_add_listener(_add_entities)) + + +class PlugwiseWaterHeaterEntity(PlugwiseEntity, WaterHeaterEntity): + """Representation of a Plugwise water heater.""" + + _attr_name = None + _attr_temperature_unit = UnitOfTemperature.CELSIUS + + def __init__( + self, + coordinator: PlugwiseDataUpdateCoordinator, + device_id: str, + ) -> 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 + + + @property + def current_operation(self) -> str | None: + """Return current readable operation mode.""" + return self.device.get(DHW_MODE) + + @property + 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 + + @property + 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 + + @property + 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) + ) + + @plugwise_command + 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) + + @plugwise_command + 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)) diff --git a/pyproject.toml b/pyproject.toml index 7bf136ae4..55a37b2af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "plugwise-beta" -version = "0.64.4" +version = "0.65.0" description = "Plugwise beta custom-component" readme = "README.md" requires-python = ">=3.14" 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 0c1057afc..56c7ffbb0 100644 --- a/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json +++ b/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json @@ -7,6 +7,10 @@ "heating_state": true }, "dev_class": "heater_central", + "dhw_modes": [ + "comfort", + "off" + ], "location": "bc93488efab249e5bc54fd7e175a6f91", "maximum_boiler_temperature": { "lower_bound": 25.0, @@ -16,12 +20,10 @@ }, "model": "Generic heater", "name": "OpenTherm", + "select_dhw_mode": "off", "sensors": { "intended_boiler_temperature": 22.5, "water_temperature": 43.0 - }, - "switches": { - "dhw_cm_switch": false } }, "10016900610d4c7481df78c89606ef22": { diff --git a/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json b/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json index 2d90b6f12..54a045273 100644 --- a/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json +++ b/tests/components/plugwise/fixtures/anna_heatpump_heating/data.json @@ -29,6 +29,11 @@ "secondary_boiler_state": false }, "dev_class": "heater_central", + "dhw_mode": "off", + "dhw_modes": [ + "comfort", + "off" + ], "location": "a57efe5f145f498c9be62a9b63626fbf", "max_dhw_temperature": { "lower_bound": 35.0, @@ -53,9 +58,6 @@ "water_pressure": 1.57, "water_temperature": 29.1 }, - "switches": { - "dhw_cm_switch": false - }, "vendor": "Techneco" }, "3cb70739631c4d17a86b8b12e8a5161b": { diff --git a/tests/components/plugwise/fixtures/anna_p1/data.json b/tests/components/plugwise/fixtures/anna_p1/data.json index 5918dc8fb..6ee72b54c 100644 --- a/tests/components/plugwise/fixtures/anna_p1/data.json +++ b/tests/components/plugwise/fixtures/anna_p1/data.json @@ -48,19 +48,21 @@ "heating_state": false }, "dev_class": "heater_central", + "dhw_modes": [ + "comfort", + "off" + ], "location": "da7be222ab3b420c927f3e49fade0304", "model": "Generic heater", "model_id": "HR24", "name": "OpenTherm", + "select_dhw_mode": "comfort", "sensors": { "intended_boiler_temperature": 0.0, "modulation_level": 0.0, "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 a64605171..563560b49 100644 --- a/tests/components/plugwise/fixtures/anna_v4/data.json +++ b/tests/components/plugwise/fixtures/anna_v4/data.json @@ -67,6 +67,11 @@ "heating_state": true }, "dev_class": "heater_central", + "dhw_mode": "off", + "dhw_modes": [ + "comfort", + "off" + ], "location": "94c107dc6ac84ed98e9f68c0dd06bf71", "max_dhw_temperature": { "lower_bound": 30.0, @@ -90,9 +95,6 @@ "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 new file mode 100644 index 000000000..9c1f13360 --- /dev/null +++ b/tests/components/plugwise/fixtures/anna_v4_dhw/data.json @@ -0,0 +1,100 @@ +{ + "01b85360fdd243d0aaad4d6ac2a5ba7e": { + "active_preset": "home", + "available_schedules": [ + "Standaard", + "Thuiswerken", + "off" + ], + "climate_mode": "heat", + "control_state": "idle", + "dev_class": "thermostat", + "firmware": "2018-02-08T11:15:53+01:00", + "hardware": "6539-1301-5002", + "location": "eb5309212bf5407bb143e5bfa3b18aee", + "model": "ThermoTouch", + "name": "Anna", + "preset_modes": [ + "vacation", + "no_frost", + "away", + "asleep", + "home" + ], + "select_schedule": "off", + "sensors": { + "illuminance": 60.0, + "setpoint": 20.5, + "temperature": 20.6 + }, + "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": 20.5, + "upper_bound": 30.0 + }, + "vendor": "Plugwise" + }, + "0466eae8520144c78afb29628384edeb": { + "binary_sensors": { + "plugwise_notification": false + }, + "dev_class": "gateway", + "firmware": "4.0.15", + "hardware": "AME Smile 2.0 board", + "location": "94c107dc6ac84ed98e9f68c0dd06bf71", + "mac_address": "012345670001", + "model": "Gateway", + "model_id": "smile_thermo", + "name": "Smile Anna", + "notifications": {}, + "sensors": { + "outdoor_temperature": 7.44 + }, + "vendor": "Plugwise" + }, + "cd0e6156b1f04d5f952349ffbe397481": { + "available": true, + "binary_sensors": { + "dhw_state": true, + "flame_state": true, + "heating_state": false + }, + "dev_class": "heater_central", + "dhw_mode": "off", + "dhw_modes": [ + "comfort", + "off" + ], + "location": "94c107dc6ac84ed98e9f68c0dd06bf71", + "max_dhw_temperature": { + "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 + }, + "model": "Generic heater", + "model_id": "2.32", + "name": "OpenTherm", + "sensors": { + "intended_boiler_temperature": 39.9, + "modulation_level": 0.0, + "return_temperature": 32.0, + "water_pressure": 2.2, + "water_temperature": 45.0 + }, + "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 d1b3753ea..c5b321660 100644 --- a/tests/components/plugwise/fixtures/m_adam_cooling/data.json +++ b/tests/components/plugwise/fixtures/m_adam_cooling/data.json @@ -8,6 +8,10 @@ "heating_state": false }, "dev_class": "heater_central", + "dhw_modes": [ + "comfort", + "off" + ], "location": "bc93488efab249e5bc54fd7e175a6f91", "maximum_boiler_temperature": { "lower_bound": 25.0, @@ -17,12 +21,10 @@ }, "model": "Generic heater", "name": "OpenTherm", + "select_dhw_mode": "off", "sensors": { "intended_boiler_temperature": 17.5, "water_temperature": 19.0 - }, - "switches": { - "dhw_cm_switch": false } }, "14df5c4dc8cb4ba69f9d1ac0eaf7c5c6": { diff --git a/tests/components/plugwise/fixtures/m_adam_heating/data.json b/tests/components/plugwise/fixtures/m_adam_heating/data.json index 208b6df84..f29aa84c7 100644 --- a/tests/components/plugwise/fixtures/m_adam_heating/data.json +++ b/tests/components/plugwise/fixtures/m_adam_heating/data.json @@ -7,6 +7,10 @@ "heating_state": true }, "dev_class": "heater_central", + "dhw_modes": [ + "comfort", + "off" + ], "location": "bc93488efab249e5bc54fd7e175a6f91", "max_dhw_temperature": { "lower_bound": 40.0, @@ -22,12 +26,10 @@ }, "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": { 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 3aeb08f30..aaabc1495 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 @@ -7,6 +7,10 @@ "heating_state": false }, "dev_class": "heater_central", + "dhw_modes": [ + "comfort", + "off" + ], "location": "bc93488efab249e5bc54fd7e175a6f91", "max_dhw_temperature": { "lower_bound": 40.0, @@ -22,12 +26,10 @@ }, "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": { diff --git a/tests/components/plugwise/fixtures/m_adam_jip/data.json b/tests/components/plugwise/fixtures/m_adam_jip/data.json index a473c7748..ff33d77c2 100644 --- a/tests/components/plugwise/fixtures/m_adam_jip/data.json +++ b/tests/components/plugwise/fixtures/m_adam_jip/data.json @@ -393,6 +393,11 @@ "heating_state": false }, "dev_class": "heater_central", + "dhw_mode": "off", + "dhw_modes": [ + "comfort", + "off" + ], "location": "9e4433a9d69f40b3aefd15e74395eaec", "max_dhw_temperature": { "lower_bound": 40.0, @@ -416,9 +421,6 @@ "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_anna_heatpump_cooling/data.json b/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json index e12f137bd..fb4085270 100644 --- a/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json +++ b/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json @@ -29,6 +29,11 @@ "secondary_boiler_state": false }, "dev_class": "heater_central", + "dhw_mode": "off", + "dhw_modes": [ + "comfort", + "off" + ], "location": "a57efe5f145f498c9be62a9b63626fbf", "max_dhw_temperature": { "lower_bound": 35.0, @@ -53,9 +58,6 @@ "water_pressure": 1.57, "water_temperature": 22.7 }, - "switches": { - "dhw_cm_switch": false - }, "vendor": "Techneco" }, "3cb70739631c4d17a86b8b12e8a5161b": { diff --git a/tests/components/plugwise/snapshots/test_number.ambr b/tests/components/plugwise/snapshots/test_number.ambr index b033751e2..0026ef47c 100644 --- a/tests/components/plugwise/snapshots/test_number.ambr +++ b/tests/components/plugwise/snapshots/test_number.ambr @@ -609,67 +609,6 @@ 'state': '-0.5', }) # --- -# name: test_anna_number_entities[platforms0-True-anna_heatpump_heating][number.opentherm_domestic_hot_water_setpoint-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': dict({ - 'max': 60.0, - 'min': 35.0, - 'mode': , - 'step': 0.5, - }), - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': , - 'entity_id': 'number.opentherm_domestic_hot_water_setpoint', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': 'Domestic hot water setpoint', - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Domestic hot water setpoint', - 'platform': 'plugwise', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': 'max_dhw_temperature', - 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-max_dhw_temperature', - 'unit_of_measurement': , - }) -# --- -# name: test_anna_number_entities[platforms0-True-anna_heatpump_heating][number.opentherm_domestic_hot_water_setpoint-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'temperature', - 'friendly_name': 'OpenTherm Domestic hot water setpoint', - 'max': 60.0, - 'min': 35.0, - 'mode': , - 'step': 0.5, - 'unit_of_measurement': , - }), - 'context': , - 'entity_id': 'number.opentherm_domestic_hot_water_setpoint', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': '53.0', - }) -# --- # name: test_anna_number_entities[platforms0-True-anna_heatpump_heating][number.opentherm_maximum_boiler_temperature_setpoint-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/plugwise/snapshots/test_select.ambr b/tests/components/plugwise/snapshots/test_select.ambr index cc1df1a73..3b87ac33b 100644 --- a/tests/components/plugwise/snapshots/test_select.ambr +++ b/tests/components/plugwise/snapshots/test_select.ambr @@ -377,6 +377,65 @@ 'state': 'active', }) # --- +# name: test_adam_2_select_entities[platforms0-True-m_adam_cooling][select.opentherm_dhw_mode-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + 'options': list([ + 'comfort', + 'off', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'select', + 'entity_category': , + 'entity_id': 'select.opentherm_dhw_mode', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'DHW mode', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'DHW mode', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'select_dhw_mode', + 'unique_id': '056ee145a816487eaa69243c3280f8bf-select_dhw_mode', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_2_select_entities[platforms0-True-m_adam_cooling][select.opentherm_dhw_mode-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'OpenTherm DHW mode', + 'options': list([ + 'comfort', + 'off', + ]), + }), + 'context': , + 'entity_id': 'select.opentherm_dhw_mode', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_adam_select_entities[platforms0][select.badkamer_thermostat_schedule-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/plugwise/snapshots/test_water_heater.ambr b/tests/components/plugwise/snapshots/test_water_heater.ambr new file mode 100644 index 000000000..5e22e905d --- /dev/null +++ b/tests/components/plugwise/snapshots/test_water_heater.ambr @@ -0,0 +1,139 @@ +# serializer version: 1 +# name: test_adam_water_heater_snapshot[platforms0][water_heater.opentherm-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + 'max_temp': 60.0, + 'min_temp': 40.0, + 'operation_list': list([ + 'comfort', + 'off', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'water_heater', + 'entity_category': None, + 'entity_id': 'water_heater.opentherm', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'e4684553153b44afbef2200885f379dc-water_heater', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_water_heater_snapshot[platforms0][water_heater.opentherm-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 37.3, + 'friendly_name': 'OpenTherm', + 'max_temp': 60.0, + 'min_temp': 40.0, + 'operation_list': list([ + 'comfort', + 'off', + ]), + 'operation_mode': 'off', + 'supported_features': , + 'target_temp_high': None, + 'target_temp_low': None, + 'temperature': 60.0, + }), + 'context': , + 'entity_id': 'water_heater.opentherm', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_anna_water_heater_snapshot[platforms0-False-anna_v4_dhw][water_heater.opentherm-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + 'max_temp': 60.0, + 'min_temp': 30.0, + 'operation_list': list([ + 'comfort', + 'off', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'water_heater', + 'entity_category': None, + 'entity_id': 'water_heater.opentherm', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'cd0e6156b1f04d5f952349ffbe397481-water_heater', + 'unit_of_measurement': None, + }) +# --- +# name: test_anna_water_heater_snapshot[platforms0-False-anna_v4_dhw][water_heater.opentherm-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 45.0, + 'friendly_name': 'OpenTherm', + 'max_temp': 60.0, + 'min_temp': 30.0, + 'operation_list': list([ + 'comfort', + 'off', + ]), + 'operation_mode': 'off', + 'supported_features': , + 'target_temp_high': None, + 'target_temp_low': None, + 'temperature': 60.0, + }), + 'context': , + 'entity_id': 'water_heater.opentherm', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- diff --git a/tests/components/plugwise/test_number.py b/tests/components/plugwise/test_number.py index aaf496d2a..87ea6f1f9 100644 --- a/tests/components/plugwise/test_number.py +++ b/tests/components/plugwise/test_number.py @@ -67,34 +67,6 @@ async def test_adam_temperature_offset_out_of_bounds_change( ) -@pytest.mark.parametrize("chosen_env", ["m_adam_heating"], indirect=True) -@pytest.mark.parametrize("cooling_present", [False], indirect=True) -async def test_adam_dhw_setpoint_change( - hass: HomeAssistant, - mock_smile_adam_heat_cool: MagicMock, - init_integration: MockConfigEntry, -) -> None: - """Test changing of number entities.""" - state = hass.states.get("number.opentherm_domestic_hot_water_setpoint") - assert state - assert float(state.state) == 60.0 - - await hass.services.async_call( - NUMBER_DOMAIN, - SERVICE_SET_VALUE, - { - ATTR_ENTITY_ID: "number.opentherm_domestic_hot_water_setpoint", - ATTR_VALUE: 55, - }, - blocking=True, - ) - - assert mock_smile_adam_heat_cool.set_number.call_count == 1 - mock_smile_adam_heat_cool.set_number.assert_called_with( - "056ee145a816487eaa69243c3280f8bf", "max_dhw_temperature", 55.0 - ) - - @pytest.mark.parametrize("chosen_env", ["anna_heatpump_heating"], indirect=True) @pytest.mark.parametrize("cooling_present", [True], indirect=True) @pytest.mark.parametrize("platforms", [(NUMBER_DOMAIN,)]) diff --git a/tests/components/plugwise/test_select.py b/tests/components/plugwise/test_select.py index d9a6ef549..162694f55 100644 --- a/tests/components/plugwise/test_select.py +++ b/tests/components/plugwise/test_select.py @@ -92,7 +92,7 @@ async def test_adam_select_regulation_mode( assert mock_smile_adam_heat_cool.set_select.call_count == 1 mock_smile_adam_heat_cool.set_select.assert_called_with( "select_regulation_mode", - "bc93488efab249e5bc54fd7e175a6f91", + "da224107914542988a88561b4452b0f6", "heating", "on", ) diff --git a/tests/components/plugwise/test_water_heater.py b/tests/components/plugwise/test_water_heater.py new file mode 100644 index 000000000..11bc7af3a --- /dev/null +++ b/tests/components/plugwise/test_water_heater.py @@ -0,0 +1,77 @@ +"""Tests for the Plugwise water_heater platform.""" + +from unittest.mock import MagicMock + +import pytest + +from homeassistant.components.water_heater import ( + ATTR_OPERATION_MODE, + DOMAIN as WATER_HEATER_DOMAIN, + SERVICE_SET_OPERATION_MODE, + SERVICE_SET_TEMPERATURE, +) +from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er +from syrupy.assertion import SnapshotAssertion + +from tests.common import MockConfigEntry, snapshot_platform + +HA_PLUGWISE_SMILE_ASYNC_UPDATE = ( + "homeassistant.components.plugwise.coordinator.Smile.async_update" +) + + +@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, +) -> None: + """Test Adam water_heater snapshot with dhw_state off.""" + await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) + + +async def test_adam_water_heater_setpoint_change( + 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}, + 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, + ) + + await hass.services.async_call( + WATER_HEATER_DOMAIN, + SERVICE_SET_OPERATION_MODE, + {ATTR_ENTITY_ID: "water_heater.opentherm", ATTR_OPERATION_MODE: "off"}, + 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" + ) + + +@pytest.mark.parametrize("chosen_env", ["anna_v4_dhw"], 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)