diff --git a/homeassistant/components/plugwise/binary_sensor.py b/homeassistant/components/plugwise/binary_sensor.py index 956dd7f36da..5da82ab4105 100644 --- a/homeassistant/components/plugwise/binary_sensor.py +++ b/homeassistant/components/plugwise/binary_sensor.py @@ -1,11 +1,11 @@ """Plugwise Binary Sensor component for Home Assistant.""" from __future__ import annotations -from collections.abc import Callable, Mapping +from collections.abc import Mapping from dataclasses import dataclass from typing import Any -from plugwise import SmileBinarySensors +from plugwise.constants import BinarySensorType from homeassistant.components.binary_sensor import ( BinarySensorEntity, @@ -24,18 +24,10 @@ SEVERITIES = ["other", "info", "warning", "error"] @dataclass -class PlugwiseBinarySensorMixin: - """Mixin for required Plugwise binary sensor base description keys.""" - - value_fn: Callable[[SmileBinarySensors], bool] - - -@dataclass -class PlugwiseBinarySensorEntityDescription( - BinarySensorEntityDescription, PlugwiseBinarySensorMixin -): +class PlugwiseBinarySensorEntityDescription(BinarySensorEntityDescription): """Describes a Plugwise binary sensor entity.""" + key: BinarySensorType icon_off: str | None = None @@ -46,14 +38,12 @@ BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = ( icon="mdi:hvac", icon_off="mdi:hvac-off", entity_category=EntityCategory.DIAGNOSTIC, - value_fn=lambda data: data["compressor_state"], ), PlugwiseBinarySensorEntityDescription( key="cooling_enabled", translation_key="cooling_enabled", icon="mdi:snowflake-thermometer", entity_category=EntityCategory.DIAGNOSTIC, - value_fn=lambda data: data["cooling_enabled"], ), PlugwiseBinarySensorEntityDescription( key="dhw_state", @@ -61,7 +51,6 @@ BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = ( icon="mdi:water-pump", icon_off="mdi:water-pump-off", entity_category=EntityCategory.DIAGNOSTIC, - value_fn=lambda data: data["dhw_state"], ), PlugwiseBinarySensorEntityDescription( key="flame_state", @@ -70,7 +59,6 @@ BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = ( icon="mdi:fire", icon_off="mdi:fire-off", entity_category=EntityCategory.DIAGNOSTIC, - value_fn=lambda data: data["flame_state"], ), PlugwiseBinarySensorEntityDescription( key="heating_state", @@ -78,7 +66,6 @@ BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = ( icon="mdi:radiator", icon_off="mdi:radiator-off", entity_category=EntityCategory.DIAGNOSTIC, - value_fn=lambda data: data["heating_state"], ), PlugwiseBinarySensorEntityDescription( key="cooling_state", @@ -86,7 +73,6 @@ BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = ( icon="mdi:snowflake", icon_off="mdi:snowflake-off", entity_category=EntityCategory.DIAGNOSTIC, - value_fn=lambda data: data["cooling_state"], ), PlugwiseBinarySensorEntityDescription( key="slave_boiler_state", @@ -94,7 +80,6 @@ BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = ( icon="mdi:fire", icon_off="mdi:circle-off-outline", entity_category=EntityCategory.DIAGNOSTIC, - value_fn=lambda data: data["slave_boiler_state"], ), PlugwiseBinarySensorEntityDescription( key="plugwise_notification", @@ -102,7 +87,6 @@ BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = ( icon="mdi:mailbox-up-outline", icon_off="mdi:mailbox-outline", entity_category=EntityCategory.DIAGNOSTIC, - value_fn=lambda data: data["plugwise_notification"], ), ) @@ -154,7 +138,7 @@ class PlugwiseBinarySensorEntity(PlugwiseEntity, BinarySensorEntity): @property def is_on(self) -> bool: """Return true if the binary sensor is on.""" - return self.entity_description.value_fn(self.device["binary_sensors"]) + return self.device["binary_sensors"][self.entity_description.key] @property def icon(self) -> str | None: diff --git a/homeassistant/components/plugwise/climate.py b/homeassistant/components/plugwise/climate.py index d0a65799807..5be09a062e2 100644 --- a/homeassistant/components/plugwise/climate.py +++ b/homeassistant/components/plugwise/climate.py @@ -130,13 +130,13 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity): if control_state == "off": return HVACAction.IDLE - hc_data = self.coordinator.data.devices[ - self.coordinator.data.gateway["heater_id"] - ] - if hc_data["binary_sensors"]["heating_state"]: - return HVACAction.HEATING - if hc_data["binary_sensors"].get("cooling_state"): - return HVACAction.COOLING + heater: str | None = self.coordinator.data.gateway["heater_id"] + if heater: + heater_data = self.coordinator.data.devices[heater] + if heater_data["binary_sensors"]["heating_state"]: + return HVACAction.HEATING + if heater_data["binary_sensors"].get("cooling_state"): + return HVACAction.COOLING return HVACAction.IDLE @@ -150,7 +150,7 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity): """Return entity specific state attributes.""" return { "available_schemas": self.device["available_schedules"], - "selected_schema": self.device["selected_schedule"], + "selected_schema": self.device["select_schedule"], } @plugwise_command diff --git a/homeassistant/components/plugwise/coordinator.py b/homeassistant/components/plugwise/coordinator.py index afcd673ef7d..395ec4e6e63 100644 --- a/homeassistant/components/plugwise/coordinator.py +++ b/homeassistant/components/plugwise/coordinator.py @@ -1,9 +1,7 @@ """DataUpdateCoordinator for Plugwise.""" from datetime import timedelta -from typing import NamedTuple, cast -from plugwise import Smile -from plugwise.constants import DeviceData, GatewayData +from plugwise import PlugwiseData, Smile from plugwise.exceptions import ( ConnectionFailedError, InvalidAuthentication, @@ -23,13 +21,6 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda from .const import DEFAULT_PORT, DEFAULT_SCAN_INTERVAL, DEFAULT_USERNAME, DOMAIN, LOGGER -class PlugwiseData(NamedTuple): - """Plugwise data stored in the DataUpdateCoordinator.""" - - gateway: GatewayData - devices: dict[str, DeviceData] - - class PlugwiseDataUpdateCoordinator(DataUpdateCoordinator[PlugwiseData]): """Class to manage fetching Plugwise data from single endpoint.""" @@ -65,13 +56,13 @@ class PlugwiseDataUpdateCoordinator(DataUpdateCoordinator[PlugwiseData]): """Connect to the Plugwise Smile.""" self._connected = await self.api.connect() self.api.get_all_devices() - self.name = self.api.smile_name self.update_interval = DEFAULT_SCAN_INTERVAL.get( str(self.api.smile_type), timedelta(seconds=60) ) async def _async_update_data(self) -> PlugwiseData: """Fetch data from Plugwise.""" + try: if not self._connected: await self._connect() @@ -87,7 +78,4 @@ class PlugwiseDataUpdateCoordinator(DataUpdateCoordinator[PlugwiseData]): raise ConfigEntryError("Device with unsupported firmware") from err except ConnectionFailedError as err: raise UpdateFailed("Failed to connect to the Plugwise Smile") from err - return PlugwiseData( - gateway=cast(GatewayData, data[0]), - devices=cast(dict[str, DeviceData], data[1]), - ) + return data diff --git a/homeassistant/components/plugwise/entity.py b/homeassistant/components/plugwise/entity.py index e2ab5445f07..c0f38cf6d5c 100644 --- a/homeassistant/components/plugwise/entity.py +++ b/homeassistant/components/plugwise/entity.py @@ -67,7 +67,7 @@ class PlugwiseEntity(CoordinatorEntity[PlugwiseDataUpdateCoordinator]): """Return if entity is available.""" return ( self._dev_id in self.coordinator.data.devices - and ("available" not in self.device or self.device["available"]) + and ("available" not in self.device or self.device["available"] is True) and super().available ) diff --git a/homeassistant/components/plugwise/manifest.json b/homeassistant/components/plugwise/manifest.json index 4fdcd0a8bdd..ef0f01b38f7 100644 --- a/homeassistant/components/plugwise/manifest.json +++ b/homeassistant/components/plugwise/manifest.json @@ -7,6 +7,6 @@ "integration_type": "hub", "iot_class": "local_polling", "loggers": ["crcmod", "plugwise"], - "requirements": ["plugwise==0.31.1"], + "requirements": ["plugwise==0.31.9"], "zeroconf": ["_plugwise._tcp.local."] } diff --git a/homeassistant/components/plugwise/number.py b/homeassistant/components/plugwise/number.py index 25667ea16c6..102d94f91b7 100644 --- a/homeassistant/components/plugwise/number.py +++ b/homeassistant/components/plugwise/number.py @@ -4,7 +4,8 @@ from __future__ import annotations from collections.abc import Awaitable, Callable from dataclasses import dataclass -from plugwise import ActuatorData, Smile +from plugwise import Smile +from plugwise.constants import NumberType from homeassistant.components.number import ( NumberDeviceClass, @@ -27,10 +28,6 @@ class PlugwiseEntityDescriptionMixin: """Mixin values for Plugwise entities.""" command: Callable[[Smile, str, float], Awaitable[None]] - native_max_value_fn: Callable[[ActuatorData], float] - native_min_value_fn: Callable[[ActuatorData], float] - native_step_fn: Callable[[ActuatorData], float] - native_value_fn: Callable[[ActuatorData], float] @dataclass @@ -39,6 +36,8 @@ class PlugwiseNumberEntityDescription( ): """Class describing Plugwise Number entities.""" + key: NumberType + NUMBER_TYPES = ( PlugwiseNumberEntityDescription( @@ -48,10 +47,6 @@ NUMBER_TYPES = ( device_class=NumberDeviceClass.TEMPERATURE, entity_category=EntityCategory.CONFIG, native_unit_of_measurement=UnitOfTemperature.CELSIUS, - native_max_value_fn=lambda data: data["upper_bound"], - native_min_value_fn=lambda data: data["lower_bound"], - native_step_fn=lambda data: data["resolution"], - native_value_fn=lambda data: data["setpoint"], ), ) @@ -70,7 +65,7 @@ async def async_setup_entry( entities: list[PlugwiseNumberEntity] = [] for device_id, device in coordinator.data.devices.items(): for description in NUMBER_TYPES: - if (actuator := device.get(description.key)) and "setpoint" in actuator: + if description.key in device: entities.append( PlugwiseNumberEntity(coordinator, device_id, description) ) @@ -91,30 +86,18 @@ class PlugwiseNumberEntity(PlugwiseEntity, NumberEntity): ) -> None: """Initiate Plugwise Number.""" super().__init__(coordinator, device_id) - self.actuator = self.device[description.key] self.entity_description = description self._attr_unique_id = f"{device_id}-{description.key}" self._attr_mode = NumberMode.BOX - @property - def native_max_value(self) -> float: - """Return the setpoint max. value.""" - return self.entity_description.native_max_value_fn(self.actuator) - - @property - def native_min_value(self) -> float: - """Return the setpoint min. value.""" - return self.entity_description.native_min_value_fn(self.actuator) - - @property - def native_step(self) -> float: - """Return the setpoint step value.""" - return max(self.entity_description.native_step_fn(self.actuator), 1) + self._attr_native_max_value = self.device[description.key]["upper_bound"] + self._attr_native_min_value = self.device[description.key]["lower_bound"] + self._attr_native_step = max(self.device[description.key]["resolution"], 0.5) @property def native_value(self) -> float: """Return the present setpoint value.""" - return self.entity_description.native_value_fn(self.actuator) + return self.device[self.entity_description.key]["setpoint"] async def async_set_native_value(self, value: float) -> None: """Change to the new setpoint value.""" diff --git a/homeassistant/components/plugwise/select.py b/homeassistant/components/plugwise/select.py index b78fd689cb9..6646cce3369 100644 --- a/homeassistant/components/plugwise/select.py +++ b/homeassistant/components/plugwise/select.py @@ -3,9 +3,9 @@ from __future__ import annotations from collections.abc import Awaitable, Callable from dataclasses import dataclass -from typing import Any -from plugwise import DeviceData, Smile +from plugwise import Smile +from plugwise.constants import SelectOptionsType, SelectType from homeassistant.components.select import SelectEntity, SelectEntityDescription from homeassistant.config_entries import ConfigEntry @@ -22,16 +22,17 @@ from .entity import PlugwiseEntity class PlugwiseSelectDescriptionMixin: """Mixin values for Plugwise Select entities.""" - command: Callable[[Smile, str, str], Awaitable[Any]] - value_fn: Callable[[DeviceData], str] - options_fn: Callable[[DeviceData], list[str]] + command: Callable[[Smile, str, str], Awaitable[None]] + options_key: SelectOptionsType @dataclass class PlugwiseSelectEntityDescription( SelectEntityDescription, PlugwiseSelectDescriptionMixin ): - """Class describing Plugwise Number entities.""" + """Class describing Plugwise Select entities.""" + + key: SelectType SELECT_TYPES = ( @@ -40,8 +41,7 @@ SELECT_TYPES = ( translation_key="select_schedule", icon="mdi:calendar-clock", command=lambda api, loc, opt: api.set_schedule_state(loc, opt, STATE_ON), - value_fn=lambda data: data["selected_schedule"], - options_fn=lambda data: data.get("available_schedules"), + options_key="available_schedules", ), PlugwiseSelectEntityDescription( key="select_regulation_mode", @@ -49,8 +49,7 @@ SELECT_TYPES = ( icon="mdi:hvac", entity_category=EntityCategory.CONFIG, command=lambda api, loc, opt: api.set_regulation_mode(opt), - value_fn=lambda data: data["regulation_mode"], - options_fn=lambda data: data.get("regulation_modes"), + options_key="regulation_modes", ), PlugwiseSelectEntityDescription( key="select_dhw_mode", @@ -58,8 +57,7 @@ SELECT_TYPES = ( icon="mdi:shower", entity_category=EntityCategory.CONFIG, command=lambda api, loc, opt: api.set_dhw_mode(opt), - value_fn=lambda data: data["dhw_mode"], - options_fn=lambda data: data.get("dhw_modes"), + options_key="dhw_modes", ), ) @@ -77,7 +75,7 @@ async def async_setup_entry( entities: list[PlugwiseSelectEntity] = [] for device_id, device in coordinator.data.devices.items(): for description in SELECT_TYPES: - if (options := description.options_fn(device)) and len(options) > 1: + if description.options_key in device: entities.append( PlugwiseSelectEntity(coordinator, device_id, description) ) @@ -100,16 +98,12 @@ class PlugwiseSelectEntity(PlugwiseEntity, SelectEntity): super().__init__(coordinator, device_id) self.entity_description = entity_description self._attr_unique_id = f"{device_id}-{entity_description.key}" + self._attr_options = self.device[entity_description.options_key] @property def current_option(self) -> str: """Return the selected entity option to represent the entity state.""" - return self.entity_description.value_fn(self.device) - - @property - def options(self) -> list[str]: - """Return the selectable entity options.""" - return self.entity_description.options_fn(self.device) + return self.device[self.entity_description.key] async def async_select_option(self, option: str) -> None: """Change to the selected entity option.""" diff --git a/homeassistant/components/plugwise/sensor.py b/homeassistant/components/plugwise/sensor.py index d18226e5af9..0cc878178fe 100644 --- a/homeassistant/components/plugwise/sensor.py +++ b/homeassistant/components/plugwise/sensor.py @@ -1,6 +1,10 @@ """Plugwise Sensor component for Home Assistant.""" from __future__ import annotations +from dataclasses import dataclass + +from plugwise.constants import SensorType + from homeassistant.components.sensor import ( SensorDeviceClass, SensorEntity, @@ -27,8 +31,16 @@ from .const import DOMAIN from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity -SENSORS: tuple[SensorEntityDescription, ...] = ( - SensorEntityDescription( + +@dataclass +class PlugwiseSensorEntityDescription(SensorEntityDescription): + """Describes Plugwise sensor entity.""" + + key: SensorType + + +SENSORS: tuple[PlugwiseSensorEntityDescription, ...] = ( + PlugwiseSensorEntityDescription( key="setpoint", translation_key="setpoint", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -36,7 +48,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="setpoint_high", translation_key="cooling_setpoint", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -44,7 +56,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="setpoint_low", translation_key="heating_setpoint", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -52,14 +64,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="intended_boiler_temperature", translation_key="intended_boiler_temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -67,7 +79,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="temperature_difference", translation_key="temperature_difference", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -75,14 +87,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="outdoor_temperature", translation_key="outdoor_temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="outdoor_air_temperature", translation_key="outdoor_air_temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -90,7 +102,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="water_temperature", translation_key="water_temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -98,7 +110,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="return_temperature", translation_key="return_temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -106,14 +118,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_consumed", translation_key="electricity_consumed", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_produced", translation_key="electricity_produced", native_unit_of_measurement=UnitOfPower.WATT, @@ -121,28 +133,28 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_consumed_interval", translation_key="electricity_consumed_interval", native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_consumed_peak_interval", translation_key="electricity_consumed_peak_interval", native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_consumed_off_peak_interval", translation_key="electricity_consumed_off_peak_interval", native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_produced_interval", translation_key="electricity_produced_interval", native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, @@ -150,133 +162,133 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( state_class=SensorStateClass.TOTAL, entity_registry_enabled_default=False, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_produced_peak_interval", translation_key="electricity_produced_peak_interval", native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_produced_off_peak_interval", translation_key="electricity_produced_off_peak_interval", native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_consumed_point", translation_key="electricity_consumed_point", device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_consumed_off_peak_point", translation_key="electricity_consumed_off_peak_point", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_consumed_peak_point", translation_key="electricity_consumed_peak_point", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_consumed_off_peak_cumulative", translation_key="electricity_consumed_off_peak_cumulative", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_consumed_peak_cumulative", translation_key="electricity_consumed_peak_cumulative", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_produced_point", translation_key="electricity_produced_point", device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_produced_off_peak_point", translation_key="electricity_produced_off_peak_point", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_produced_peak_point", translation_key="electricity_produced_peak_point", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_produced_off_peak_cumulative", translation_key="electricity_produced_off_peak_cumulative", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_produced_peak_cumulative", translation_key="electricity_produced_peak_cumulative", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_phase_one_consumed", translation_key="electricity_phase_one_consumed", device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_phase_two_consumed", translation_key="electricity_phase_two_consumed", device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_phase_three_consumed", translation_key="electricity_phase_three_consumed", device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_phase_one_produced", translation_key="electricity_phase_one_produced", device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_phase_two_produced", translation_key="electricity_phase_two_produced", device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="electricity_phase_three_produced", translation_key="electricity_phase_three_produced", device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="voltage_phase_one", translation_key="voltage_phase_one", device_class=SensorDeviceClass.VOLTAGE, @@ -284,7 +296,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="voltage_phase_two", translation_key="voltage_phase_two", device_class=SensorDeviceClass.VOLTAGE, @@ -292,7 +304,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="voltage_phase_three", translation_key="voltage_phase_three", device_class=SensorDeviceClass.VOLTAGE, @@ -300,49 +312,49 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="gas_consumed_interval", translation_key="gas_consumed_interval", icon="mdi:meter-gas", native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="gas_consumed_cumulative", translation_key="gas_consumed_cumulative", native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, device_class=SensorDeviceClass.GAS, state_class=SensorStateClass.TOTAL, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="net_electricity_point", translation_key="net_electricity_point", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="net_electricity_cumulative", translation_key="net_electricity_cumulative", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="battery", native_unit_of_measurement=PERCENTAGE, device_class=SensorDeviceClass.BATTERY, entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="illuminance", native_unit_of_measurement=LIGHT_LUX, device_class=SensorDeviceClass.ILLUMINANCE, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="modulation_level", translation_key="modulation_level", icon="mdi:percent", @@ -350,7 +362,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="valve_position", translation_key="valve_position", icon="mdi:valve", @@ -358,7 +370,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( native_unit_of_measurement=PERCENTAGE, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="water_pressure", translation_key="water_pressure", native_unit_of_measurement=UnitOfPressure.BAR, @@ -366,13 +378,13 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="humidity", native_unit_of_measurement=PERCENTAGE, device_class=SensorDeviceClass.HUMIDITY, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="dhw_temperature", translation_key="dhw_temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -380,7 +392,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( + PlugwiseSensorEntityDescription( key="domestic_hot_water_setpoint", translation_key="domestic_hot_water_setpoint", native_unit_of_measurement=UnitOfTemperature.CELSIUS, @@ -388,14 +400,6 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ), - SensorEntityDescription( - key="maximum_boiler_temperature", - translation_key="maximum_boiler_temperature", - native_unit_of_measurement=UnitOfTemperature.CELSIUS, - device_class=SensorDeviceClass.TEMPERATURE, - entity_category=EntityCategory.DIAGNOSTIC, - state_class=SensorStateClass.MEASUREMENT, - ), ) @@ -409,11 +413,10 @@ async def async_setup_entry( entities: list[PlugwiseSensorEntity] = [] for device_id, device in coordinator.data.devices.items(): + if not (sensors := device.get("sensors")): + continue for description in SENSORS: - if ( - "sensors" not in device - or device["sensors"].get(description.key) is None - ): + if description.key not in sensors: continue entities.append( @@ -430,11 +433,13 @@ async def async_setup_entry( class PlugwiseSensorEntity(PlugwiseEntity, SensorEntity): """Represent Plugwise Sensors.""" + entity_description: PlugwiseSensorEntityDescription + def __init__( self, coordinator: PlugwiseDataUpdateCoordinator, device_id: str, - description: SensorEntityDescription, + description: PlugwiseSensorEntityDescription, ) -> None: """Initialise the sensor.""" super().__init__(coordinator, device_id) @@ -442,6 +447,6 @@ class PlugwiseSensorEntity(PlugwiseEntity, SensorEntity): self._attr_unique_id = f"{device_id}-{description.key}" @property - def native_value(self) -> int | float | None: + def native_value(self) -> int | float: """Return the value reported by the sensor.""" - return self.device["sensors"].get(self.entity_description.key) + return self.device["sensors"][self.entity_description.key] diff --git a/homeassistant/components/plugwise/switch.py b/homeassistant/components/plugwise/switch.py index 4204ab5a4d9..8639826e37a 100644 --- a/homeassistant/components/plugwise/switch.py +++ b/homeassistant/components/plugwise/switch.py @@ -1,11 +1,10 @@ """Plugwise Switch component for HomeAssistant.""" from __future__ import annotations -from collections.abc import Callable from dataclasses import dataclass from typing import Any -from plugwise import SmileSwitches +from plugwise.constants import SwitchType from homeassistant.components.switch import ( SwitchDeviceClass, @@ -24,16 +23,11 @@ from .util import plugwise_command @dataclass -class PlugwiseSwitchBaseMixin: - """Mixin for required Plugwise switch description keys.""" - - value_fn: Callable[[SmileSwitches], bool] - - -@dataclass -class PlugwiseSwitchEntityDescription(SwitchEntityDescription, PlugwiseSwitchBaseMixin): +class PlugwiseSwitchEntityDescription(SwitchEntityDescription): """Describes Plugwise switch entity.""" + key: SwitchType + SWITCHES: tuple[PlugwiseSwitchEntityDescription, ...] = ( PlugwiseSwitchEntityDescription( @@ -41,27 +35,24 @@ SWITCHES: tuple[PlugwiseSwitchEntityDescription, ...] = ( translation_key="dhw_cm_switch", icon="mdi:water-plus", entity_category=EntityCategory.CONFIG, - value_fn=lambda data: data["dhw_cm_switch"], ), PlugwiseSwitchEntityDescription( key="lock", translation_key="lock", icon="mdi:lock", entity_category=EntityCategory.CONFIG, - value_fn=lambda data: data["lock"], ), PlugwiseSwitchEntityDescription( key="relay", translation_key="relay", device_class=SwitchDeviceClass.SWITCH, - value_fn=lambda data: data["relay"], ), PlugwiseSwitchEntityDescription( key="cooling_ena_switch", + translation_key="cooling_ena_switch", name="Cooling", icon="mdi:snowflake-thermometer", entity_category=EntityCategory.CONFIG, - value_fn=lambda data: data["cooling_ena_switch"], ), ) @@ -103,7 +94,7 @@ class PlugwiseSwitchEntity(PlugwiseEntity, SwitchEntity): @property def is_on(self) -> bool: """Return True if entity is on.""" - return self.entity_description.value_fn(self.device["switches"]) + return self.device["switches"][self.entity_description.key] @plugwise_command async def async_turn_on(self, **kwargs: Any) -> None: diff --git a/requirements_all.txt b/requirements_all.txt index 1aac3651bc8..7cc1ca2cdc3 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1429,7 +1429,7 @@ plexauth==0.0.6 plexwebsocket==0.0.13 # homeassistant.components.plugwise -plugwise==0.31.1 +plugwise==0.31.9 # homeassistant.components.plum_lightpad plumlightpad==0.0.11 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 9736a8d176a..7e7bc5dc41f 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1080,7 +1080,7 @@ plexauth==0.0.6 plexwebsocket==0.0.13 # homeassistant.components.plugwise -plugwise==0.31.1 +plugwise==0.31.9 # homeassistant.components.plum_lightpad plumlightpad==0.0.11 diff --git a/tests/components/plugwise/conftest.py b/tests/components/plugwise/conftest.py index ae396388639..a97d312cd54 100644 --- a/tests/components/plugwise/conftest.py +++ b/tests/components/plugwise/conftest.py @@ -6,9 +6,10 @@ import json from typing import Any from unittest.mock import AsyncMock, MagicMock, patch +from plugwise import PlugwiseData import pytest -from homeassistant.components.plugwise.const import API, DOMAIN, PW_TYPE +from homeassistant.components.plugwise.const import DOMAIN from homeassistant.const import ( CONF_HOST, CONF_MAC, @@ -39,7 +40,6 @@ def mock_config_entry() -> MockConfigEntry: CONF_PASSWORD: "test-password", CONF_PORT: 80, CONF_USERNAME: "smile", - PW_TYPE: API, }, unique_id="smile98765", ) @@ -90,7 +90,10 @@ def mock_smile_adam() -> Generator[None, MagicMock, None]: smile.connect.return_value = True smile.notifications = _read_json(chosen_env, "notifications") - smile.async_update.return_value = _read_json(chosen_env, "all_data") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) yield smile @@ -116,7 +119,10 @@ def mock_smile_adam_2() -> Generator[None, MagicMock, None]: smile.connect.return_value = True smile.notifications = _read_json(chosen_env, "notifications") - smile.async_update.return_value = _read_json(chosen_env, "all_data") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) yield smile @@ -142,7 +148,39 @@ def mock_smile_adam_3() -> Generator[None, MagicMock, None]: smile.connect.return_value = True smile.notifications = _read_json(chosen_env, "notifications") - smile.async_update.return_value = _read_json(chosen_env, "all_data") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) + + yield smile + + +@pytest.fixture +def mock_smile_adam_4() -> Generator[None, MagicMock, None]: + """Create a 4th Mock Adam environment for testing exceptions.""" + chosen_env = "adam_jip" + + with patch( + "homeassistant.components.plugwise.coordinator.Smile", autospec=True + ) as smile_mock: + smile = smile_mock.return_value + + smile.gateway_id = "b5c2386c6f6342669e50fe49dd05b188" + smile.heater_id = "e4684553153b44afbef2200885f379dc" + smile.smile_version = "3.2.8" + smile.smile_type = "thermostat" + smile.smile_hostname = "smile98765" + smile.smile_model = "Gateway" + smile.smile_name = "Adam" + + smile.connect.return_value = True + + smile.notifications = _read_json(chosen_env, "notifications") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) yield smile @@ -167,7 +205,10 @@ def mock_smile_anna() -> Generator[None, MagicMock, None]: smile.connect.return_value = True smile.notifications = _read_json(chosen_env, "notifications") - smile.async_update.return_value = _read_json(chosen_env, "all_data") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) yield smile @@ -192,7 +233,10 @@ def mock_smile_anna_2() -> Generator[None, MagicMock, None]: smile.connect.return_value = True smile.notifications = _read_json(chosen_env, "notifications") - smile.async_update.return_value = _read_json(chosen_env, "all_data") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) yield smile @@ -217,7 +261,10 @@ def mock_smile_anna_3() -> Generator[None, MagicMock, None]: smile.connect.return_value = True smile.notifications = _read_json(chosen_env, "notifications") - smile.async_update.return_value = _read_json(chosen_env, "all_data") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) yield smile @@ -242,7 +289,10 @@ def mock_smile_p1() -> Generator[None, MagicMock, None]: smile.connect.return_value = True smile.notifications = _read_json(chosen_env, "notifications") - smile.async_update.return_value = _read_json(chosen_env, "all_data") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) yield smile @@ -250,7 +300,7 @@ def mock_smile_p1() -> Generator[None, MagicMock, None]: @pytest.fixture def mock_smile_p1_2() -> Generator[None, MagicMock, None]: """Create a Mock P1 3-phase DSMR environment for testing exceptions.""" - chosen_env = "p1v4_3ph" + chosen_env = "p1v4_442_triple" with patch( "homeassistant.components.plugwise.coordinator.Smile", autospec=True ) as smile_mock: @@ -267,7 +317,10 @@ def mock_smile_p1_2() -> Generator[None, MagicMock, None]: smile.connect.return_value = True smile.notifications = _read_json(chosen_env, "notifications") - smile.async_update.return_value = _read_json(chosen_env, "all_data") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) yield smile @@ -290,7 +343,10 @@ def mock_stretch() -> Generator[None, MagicMock, None]: smile.smile_name = "Stretch" smile.connect.return_value = True - smile.async_update.return_value = _read_json(chosen_env, "all_data") + all_data = _read_json(chosen_env, "all_data") + smile.async_update.return_value = PlugwiseData( + all_data["gateway"], all_data["devices"] + ) yield smile diff --git a/tests/components/plugwise/fixtures/adam_jip/all_data.json b/tests/components/plugwise/fixtures/adam_jip/all_data.json new file mode 100644 index 00000000000..177478f0fff --- /dev/null +++ b/tests/components/plugwise/fixtures/adam_jip/all_data.json @@ -0,0 +1,266 @@ +{ + "devices": { + "1346fbd8498d4dbcab7e18d51b771f3d": { + "active_preset": "no_frost", + "available": true, + "available_schedules": ["None"], + "control_state": "off", + "dev_class": "zone_thermostat", + "firmware": "2016-10-27T02:00:00+02:00", + "hardware": "255", + "last_used": null, + "location": "06aecb3d00354375924f50c47af36bd2", + "mode": "heat", + "model": "Lisa", + "name": "Slaapkamer", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "None", + "sensors": { + "battery": 92, + "setpoint": 13.0, + "temperature": 24.2 + }, + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint": 13.0, + "upper_bound": 99.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A03" + }, + "1da4d325838e4ad8aac12177214505c9": { + "available": true, + "dev_class": "thermo_sensor", + "firmware": "2020-11-04T01:00:00+01:00", + "hardware": "1", + "location": "d58fec52899f4f1c92e4f8fad6d8c48c", + "model": "Tom/Floor", + "name": "Tom Logeerkamer", + "sensors": { + "setpoint": 13.0, + "temperature": 28.8, + "temperature_difference": 2.0, + "valve_position": 0.0 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A07" + }, + "356b65335e274d769c338223e7af9c33": { + "available": true, + "dev_class": "thermo_sensor", + "firmware": "2020-11-04T01:00:00+01:00", + "hardware": "1", + "location": "06aecb3d00354375924f50c47af36bd2", + "model": "Tom/Floor", + "name": "Tom Slaapkamer", + "sensors": { + "setpoint": 13.0, + "temperature": 24.3, + "temperature_difference": 1.7, + "valve_position": 0.0 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A05" + }, + "457ce8414de24596a2d5e7dbc9c7682f": { + "available": true, + "dev_class": "zz_misc", + "location": "9e4433a9d69f40b3aefd15e74395eaec", + "model": "lumi.plug.maeu01", + "name": "Plug", + "sensors": { + "electricity_consumed_interval": 0.0 + }, + "switches": { + "lock": true, + "relay": false + }, + "vendor": "LUMI", + "zigbee_mac_address": "ABCD012345670A06" + }, + "6f3e9d7084214c21b9dfa46f6eeb8700": { + "active_preset": "home", + "available": true, + "available_schedules": ["None"], + "control_state": "off", + "dev_class": "zone_thermostat", + "firmware": "2016-10-27T02:00:00+02:00", + "hardware": "255", + "last_used": null, + "location": "d27aede973b54be484f6842d1b2802ad", + "mode": "heat", + "model": "Lisa", + "name": "Kinderkamer", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "None", + "sensors": { + "battery": 79, + "setpoint": 13.0, + "temperature": 30.0 + }, + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint": 13.0, + "upper_bound": 99.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A02" + }, + "833de10f269c4deab58fb9df69901b4e": { + "available": true, + "dev_class": "thermo_sensor", + "firmware": "2020-11-04T01:00:00+01:00", + "hardware": "1", + "location": "13228dab8ce04617af318a2888b3c548", + "model": "Tom/Floor", + "name": "Tom Woonkamer", + "sensors": { + "setpoint": 9.0, + "temperature": 24.0, + "temperature_difference": 1.8, + "valve_position": 100 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A09" + }, + "a6abc6a129ee499c88a4d420cc413b47": { + "active_preset": "home", + "available": true, + "available_schedules": ["None"], + "control_state": "off", + "dev_class": "zone_thermostat", + "firmware": "2016-10-27T02:00:00+02:00", + "hardware": "255", + "last_used": null, + "location": "d58fec52899f4f1c92e4f8fad6d8c48c", + "mode": "heat", + "model": "Lisa", + "name": "Logeerkamer", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "None", + "sensors": { + "battery": 80, + "setpoint": 13.0, + "temperature": 30.0 + }, + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint": 13.0, + "upper_bound": 99.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A01" + }, + "b5c2386c6f6342669e50fe49dd05b188": { + "binary_sensors": { + "plugwise_notification": false + }, + "dev_class": "gateway", + "firmware": "3.2.8", + "hardware": "AME Smile 2.0 board", + "location": "9e4433a9d69f40b3aefd15e74395eaec", + "mac_address": "012345670001", + "model": "Gateway", + "name": "Adam", + "regulation_modes": ["heating", "off", "bleeding_cold", "bleeding_hot"], + "select_regulation_mode": "heating", + "sensors": { + "outdoor_temperature": 24.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670101" + }, + "d4496250d0e942cfa7aea3476e9070d5": { + "available": true, + "dev_class": "thermo_sensor", + "firmware": "2020-11-04T01:00:00+01:00", + "hardware": "1", + "location": "d27aede973b54be484f6842d1b2802ad", + "model": "Tom/Floor", + "name": "Tom Kinderkamer", + "sensors": { + "setpoint": 13.0, + "temperature": 28.7, + "temperature_difference": 1.9, + "valve_position": 0.0 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A04" + }, + "e4684553153b44afbef2200885f379dc": { + "available": true, + "binary_sensors": { + "dhw_state": false, + "flame_state": false, + "heating_state": false + }, + "dev_class": "heater_central", + "location": "9e4433a9d69f40b3aefd15e74395eaec", + "max_dhw_temperature": { + "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 + }, + "model": "10.20", + "name": "OpenTherm", + "sensors": { + "intended_boiler_temperature": 0.0, + "modulation_level": 0.0, + "return_temperature": 37.1, + "water_pressure": 1.4, + "water_temperature": 37.3 + }, + "switches": { + "dhw_cm_switch": false + }, + "vendor": "Remeha B.V." + }, + "f61f1a2535f54f52ad006a3d18e459ca": { + "active_preset": "home", + "available": true, + "available_schedules": ["None"], + "control_state": "off", + "dev_class": "zone_thermometer", + "firmware": "2020-09-01T02:00:00+02:00", + "hardware": "1", + "last_used": null, + "location": "13228dab8ce04617af318a2888b3c548", + "mode": "heat", + "model": "Jip", + "name": "Woonkamer", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "None", + "sensors": { + "battery": 100, + "humidity": 56.2, + "setpoint": 9.0, + "temperature": 27.4 + }, + "thermostat": { + "lower_bound": 4.0, + "resolution": 0.01, + "setpoint": 9.0, + "upper_bound": 30.0 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A08" + } + }, + "gateway": { + "cooling_present": false, + "gateway_id": "b5c2386c6f6342669e50fe49dd05b188", + "heater_id": "e4684553153b44afbef2200885f379dc", + "notifications": {}, + "smile_name": "Adam" + } +} diff --git a/tests/components/plugwise/fixtures/p1v4_3ph/notifications.json b/tests/components/plugwise/fixtures/adam_jip/notifications.json similarity index 100% rename from tests/components/plugwise/fixtures/p1v4_3ph/notifications.json rename to tests/components/plugwise/fixtures/adam_jip/notifications.json diff --git a/tests/components/plugwise/fixtures/adam_multiple_devices_per_zone/all_data.json b/tests/components/plugwise/fixtures/adam_multiple_devices_per_zone/all_data.json index d62ff0e249d..63f0012ea92 100644 --- a/tests/components/plugwise/fixtures/adam_multiple_devices_per_zone/all_data.json +++ b/tests/components/plugwise/fixtures/adam_multiple_devices_per_zone/all_data.json @@ -1,164 +1,32 @@ -[ - { - "smile_name": "Adam", - "gateway_id": "fe799307f1624099878210aa0b9f1475", - "heater_id": "90986d591dcd426cae3ec3e8111ff730", - "cooling_present": false, - "notifications": { - "af82e4ccf9c548528166d38e560662a4": { - "warning": "Node Plug (with MAC address 000D6F000D13CB01, in room 'n.a.') has been unreachable since 23:03 2020-01-18. Please check the connection and restart the device." - } - } - }, - { - "df4a4a8169904cdb9c03d61a21f42140": { - "dev_class": "zone_thermostat", - "firmware": "2016-10-27T02:00:00+02:00", - "hardware": "255", - "location": "12493538af164a409c6a1c79e38afe1c", - "model": "Lisa", - "name": "Zone Lisa Bios", - "zigbee_mac_address": "ABCD012345670A06", - "vendor": "Plugwise", - "thermostat": { - "setpoint": 13.0, - "lower_bound": 0.0, - "upper_bound": 99.9, - "resolution": 0.01 +{ + "devices": { + "02cf28bfec924855854c544690a609ef": { + "available": true, + "dev_class": "vcr", + "firmware": "2019-06-21T02:00:00+02:00", + "location": "cd143c07248f491493cea0533bc3d669", + "model": "Plug", + "name": "NVR", + "sensors": { + "electricity_consumed": 34.0, + "electricity_consumed_interval": 9.15, + "electricity_produced": 0.0, + "electricity_produced_interval": 0.0 }, - "available": true, - "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], - "active_preset": "away", - "available_schedules": [ - "CV Roan", - "Bios Schema met Film Avond", - "GF7 Woonkamer", - "Badkamer Schema", - "CV Jessie" - ], - "selected_schedule": "None", - "last_used": "Badkamer Schema", - "mode": "heat", - "sensors": { - "temperature": 16.5, - "setpoint": 13.0, - "battery": 67 - } - }, - "b310b72a0e354bfab43089919b9a88bf": { - "dev_class": "thermo_sensor", - "firmware": "2019-03-27T01:00:00+01:00", - "hardware": "1", - "location": "c50f167537524366a5af7aa3942feb1e", - "model": "Tom/Floor", - "name": "Floor kraan", - "zigbee_mac_address": "ABCD012345670A02", - "vendor": "Plugwise", - "available": true, - "sensors": { - "temperature": 26.0, - "setpoint": 21.5, - "temperature_difference": 3.5, - "valve_position": 100 - } - }, - "a2c3583e0a6349358998b760cea82d2a": { - "dev_class": "thermo_sensor", - "firmware": "2019-03-27T01:00:00+01:00", - "hardware": "1", - "location": "12493538af164a409c6a1c79e38afe1c", - "model": "Tom/Floor", - "name": "Bios Cv Thermostatic Radiator ", - "zigbee_mac_address": "ABCD012345670A09", - "vendor": "Plugwise", - "available": true, - "sensors": { - "temperature": 17.2, - "setpoint": 13.0, - "battery": 62, - "temperature_difference": -0.2, - "valve_position": 0.0 - } - }, - "b59bcebaf94b499ea7d46e4a66fb62d8": { - "dev_class": "zone_thermostat", - "firmware": "2016-08-02T02:00:00+02:00", - "hardware": "255", - "location": "c50f167537524366a5af7aa3942feb1e", - "model": "Lisa", - "name": "Zone Lisa WK", - "zigbee_mac_address": "ABCD012345670A07", - "vendor": "Plugwise", - "thermostat": { - "setpoint": 21.5, - "lower_bound": 0.0, - "upper_bound": 99.9, - "resolution": 0.01 + "switches": { + "lock": true, + "relay": true }, - "available": true, - "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], - "active_preset": "home", - "available_schedules": [ - "CV Roan", - "Bios Schema met Film Avond", - "GF7 Woonkamer", - "Badkamer Schema", - "CV Jessie" - ], - "selected_schedule": "GF7 Woonkamer", - "last_used": "GF7 Woonkamer", - "mode": "auto", - "sensors": { - "temperature": 20.9, - "setpoint": 21.5, - "battery": 34 - } - }, - "fe799307f1624099878210aa0b9f1475": { - "dev_class": "gateway", - "firmware": "3.0.15", - "hardware": "AME Smile 2.0 board", - "location": "1f9dcf83fd4e4b66b72ff787957bfe5d", - "mac_address": "012345670001", - "model": "Gateway", - "name": "Adam", - "zigbee_mac_address": "ABCD012345670101", "vendor": "Plugwise", - "regulation_mode": "heating", - "binary_sensors": { - "plugwise_notification": true - }, - "sensors": { - "outdoor_temperature": 7.81 - } - }, - "d3da73bde12a47d5a6b8f9dad971f2ec": { - "dev_class": "thermo_sensor", - "firmware": "2019-03-27T01:00:00+01:00", - "hardware": "1", - "location": "82fa13f017d240daa0d0ea1775420f24", - "model": "Tom/Floor", - "name": "Thermostatic Radiator Jessie", - "zigbee_mac_address": "ABCD012345670A10", - "vendor": "Plugwise", - "available": true, - "sensors": { - "temperature": 17.1, - "setpoint": 15.0, - "battery": 62, - "temperature_difference": 0.1, - "valve_position": 0.0 - } + "zigbee_mac_address": "ABCD012345670A15" }, "21f2b542c49845e6bb416884c55778d6": { + "available": true, "dev_class": "game_console", "firmware": "2019-06-21T02:00:00+02:00", "location": "cd143c07248f491493cea0533bc3d669", "model": "Plug", "name": "Playstation Smart Plug", - "zigbee_mac_address": "ABCD012345670A12", - "vendor": "Plugwise", - "available": true, "sensors": { "electricity_consumed": 82.6, "electricity_consumed_interval": 8.6, @@ -166,19 +34,111 @@ "electricity_produced_interval": 0.0 }, "switches": { - "relay": true, - "lock": false - } + "lock": false, + "relay": true + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A12" + }, + "4a810418d5394b3f82727340b91ba740": { + "available": true, + "dev_class": "router", + "firmware": "2019-06-21T02:00:00+02:00", + "location": "cd143c07248f491493cea0533bc3d669", + "model": "Plug", + "name": "USG Smart Plug", + "sensors": { + "electricity_consumed": 8.5, + "electricity_consumed_interval": 0.0, + "electricity_produced": 0.0, + "electricity_produced_interval": 0.0 + }, + "switches": { + "lock": true, + "relay": true + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A16" + }, + "675416a629f343c495449970e2ca37b5": { + "available": true, + "dev_class": "router", + "firmware": "2019-06-21T02:00:00+02:00", + "location": "cd143c07248f491493cea0533bc3d669", + "model": "Plug", + "name": "Ziggo Modem", + "sensors": { + "electricity_consumed": 12.2, + "electricity_consumed_interval": 2.97, + "electricity_produced": 0.0, + "electricity_produced_interval": 0.0 + }, + "switches": { + "lock": true, + "relay": true + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A01" + }, + "680423ff840043738f42cc7f1ff97a36": { + "available": true, + "dev_class": "thermo_sensor", + "firmware": "2019-03-27T01:00:00+01:00", + "hardware": "1", + "location": "08963fec7c53423ca5680aa4cb502c63", + "model": "Tom/Floor", + "name": "Thermostatic Radiator Badkamer", + "sensors": { + "battery": 51, + "setpoint": 14.0, + "temperature": 19.1, + "temperature_difference": -0.4, + "valve_position": 0.0 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A17" + }, + "6a3bf693d05e48e0b460c815a4fdd09d": { + "active_preset": "asleep", + "available": true, + "available_schedules": [ + "CV Roan", + "Bios Schema met Film Avond", + "GF7 Woonkamer", + "Badkamer Schema", + "CV Jessie" + ], + "dev_class": "zone_thermostat", + "firmware": "2016-10-27T02:00:00+02:00", + "hardware": "255", + "last_used": "CV Jessie", + "location": "82fa13f017d240daa0d0ea1775420f24", + "mode": "auto", + "model": "Lisa", + "name": "Zone Thermostat Jessie", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "CV Jessie", + "sensors": { + "battery": 37, + "setpoint": 15.0, + "temperature": 17.2 + }, + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint": 15.0, + "upper_bound": 99.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A03" }, "78d1126fc4c743db81b61c20e88342a7": { + "available": true, "dev_class": "central_heating_pump", "firmware": "2019-06-21T02:00:00+02:00", "location": "c50f167537524366a5af7aa3942feb1e", "model": "Plug", "name": "CV Pomp", - "zigbee_mac_address": "ABCD012345670A05", - "vendor": "Plugwise", - "available": true, "sensors": { "electricity_consumed": 35.6, "electricity_consumed_interval": 7.37, @@ -187,91 +147,31 @@ }, "switches": { "relay": true - } + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A05" }, "90986d591dcd426cae3ec3e8111ff730": { + "binary_sensors": { + "heating_state": true + }, "dev_class": "heater_central", "location": "1f9dcf83fd4e4b66b72ff787957bfe5d", "model": "Unknown", "name": "OnOff", - "binary_sensors": { - "heating_state": true - }, "sensors": { - "water_temperature": 70.0, "intended_boiler_temperature": 70.0, - "modulation_level": 1 - } - }, - "cd0ddb54ef694e11ac18ed1cbce5dbbd": { - "dev_class": "vcr", - "firmware": "2019-06-21T02:00:00+02:00", - "location": "cd143c07248f491493cea0533bc3d669", - "model": "Plug", - "name": "NAS", - "zigbee_mac_address": "ABCD012345670A14", - "vendor": "Plugwise", - "available": true, - "sensors": { - "electricity_consumed": 16.5, - "electricity_consumed_interval": 0.5, - "electricity_produced": 0.0, - "electricity_produced_interval": 0.0 - }, - "switches": { - "relay": true, - "lock": true - } - }, - "4a810418d5394b3f82727340b91ba740": { - "dev_class": "router", - "firmware": "2019-06-21T02:00:00+02:00", - "location": "cd143c07248f491493cea0533bc3d669", - "model": "Plug", - "name": "USG Smart Plug", - "zigbee_mac_address": "ABCD012345670A16", - "vendor": "Plugwise", - "available": true, - "sensors": { - "electricity_consumed": 8.5, - "electricity_consumed_interval": 0.0, - "electricity_produced": 0.0, - "electricity_produced_interval": 0.0 - }, - "switches": { - "relay": true, - "lock": true - } - }, - "02cf28bfec924855854c544690a609ef": { - "dev_class": "vcr", - "firmware": "2019-06-21T02:00:00+02:00", - "location": "cd143c07248f491493cea0533bc3d669", - "model": "Plug", - "name": "NVR", - "zigbee_mac_address": "ABCD012345670A15", - "vendor": "Plugwise", - "available": true, - "sensors": { - "electricity_consumed": 34.0, - "electricity_consumed_interval": 9.15, - "electricity_produced": 0.0, - "electricity_produced_interval": 0.0 - }, - "switches": { - "relay": true, - "lock": true + "modulation_level": 1, + "water_temperature": 70.0 } }, "a28f588dc4a049a483fd03a30361ad3a": { + "available": true, "dev_class": "settop", "firmware": "2019-06-21T02:00:00+02:00", "location": "cd143c07248f491493cea0533bc3d669", "model": "Plug", "name": "Fibaro HC2", - "zigbee_mac_address": "ABCD012345670A13", - "vendor": "Plugwise", - "available": true, "sensors": { "electricity_consumed": 12.5, "electricity_consumed_interval": 3.8, @@ -279,80 +179,50 @@ "electricity_produced_interval": 0.0 }, "switches": { - "relay": true, - "lock": true - } - }, - "6a3bf693d05e48e0b460c815a4fdd09d": { - "dev_class": "zone_thermostat", - "firmware": "2016-10-27T02:00:00+02:00", - "hardware": "255", - "location": "82fa13f017d240daa0d0ea1775420f24", - "model": "Lisa", - "name": "Zone Thermostat Jessie", - "zigbee_mac_address": "ABCD012345670A03", - "vendor": "Plugwise", - "thermostat": { - "setpoint": 15.0, - "lower_bound": 0.0, - "upper_bound": 99.9, - "resolution": 0.01 + "lock": true, + "relay": true }, - "available": true, - "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], - "active_preset": "asleep", - "available_schedules": [ - "CV Roan", - "Bios Schema met Film Avond", - "GF7 Woonkamer", - "Badkamer Schema", - "CV Jessie" - ], - "selected_schedule": "CV Jessie", - "last_used": "CV Jessie", - "mode": "auto", - "sensors": { - "temperature": 17.2, - "setpoint": 15.0, - "battery": 37 - } + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A13" }, - "680423ff840043738f42cc7f1ff97a36": { + "a2c3583e0a6349358998b760cea82d2a": { + "available": true, "dev_class": "thermo_sensor", "firmware": "2019-03-27T01:00:00+01:00", "hardware": "1", - "location": "08963fec7c53423ca5680aa4cb502c63", + "location": "12493538af164a409c6a1c79e38afe1c", "model": "Tom/Floor", - "name": "Thermostatic Radiator Badkamer", - "zigbee_mac_address": "ABCD012345670A17", - "vendor": "Plugwise", - "available": true, + "name": "Bios Cv Thermostatic Radiator ", "sensors": { - "temperature": 19.1, - "setpoint": 14.0, - "battery": 51, - "temperature_difference": -0.4, + "battery": 62, + "setpoint": 13.0, + "temperature": 17.2, + "temperature_difference": -0.2, "valve_position": 0.0 - } - }, - "f1fee6043d3642a9b0a65297455f008e": { - "dev_class": "zone_thermostat", - "firmware": "2016-10-27T02:00:00+02:00", - "hardware": "255", - "location": "08963fec7c53423ca5680aa4cb502c63", - "model": "Lisa", - "name": "Zone Thermostat Badkamer", - "zigbee_mac_address": "ABCD012345670A08", - "vendor": "Plugwise", - "thermostat": { - "setpoint": 14.0, - "lower_bound": 0.0, - "upper_bound": 99.9, - "resolution": 0.01 }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A09" + }, + "b310b72a0e354bfab43089919b9a88bf": { + "available": true, + "dev_class": "thermo_sensor", + "firmware": "2019-03-27T01:00:00+01:00", + "hardware": "1", + "location": "c50f167537524366a5af7aa3942feb1e", + "model": "Tom/Floor", + "name": "Floor kraan", + "sensors": { + "setpoint": 21.5, + "temperature": 26.0, + "temperature_difference": 3.5, + "valve_position": 100 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A02" + }, + "b59bcebaf94b499ea7d46e4a66fb62d8": { + "active_preset": "home", "available": true, - "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], - "active_preset": "away", "available_schedules": [ "CV Roan", "Bios Schema met Film Avond", @@ -360,53 +230,71 @@ "Badkamer Schema", "CV Jessie" ], - "selected_schedule": "Badkamer Schema", - "last_used": "Badkamer Schema", + "dev_class": "zone_thermostat", + "firmware": "2016-08-02T02:00:00+02:00", + "hardware": "255", + "last_used": "GF7 Woonkamer", + "location": "c50f167537524366a5af7aa3942feb1e", "mode": "auto", + "model": "Lisa", + "name": "Zone Lisa WK", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "GF7 Woonkamer", "sensors": { - "temperature": 18.9, - "setpoint": 14.0, - "battery": 92 - } + "battery": 34, + "setpoint": 21.5, + "temperature": 20.9 + }, + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint": 21.5, + "upper_bound": 99.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A07" }, - "675416a629f343c495449970e2ca37b5": { - "dev_class": "router", + "cd0ddb54ef694e11ac18ed1cbce5dbbd": { + "available": true, + "dev_class": "vcr", "firmware": "2019-06-21T02:00:00+02:00", "location": "cd143c07248f491493cea0533bc3d669", "model": "Plug", - "name": "Ziggo Modem", - "zigbee_mac_address": "ABCD012345670A01", - "vendor": "Plugwise", - "available": true, + "name": "NAS", "sensors": { - "electricity_consumed": 12.2, - "electricity_consumed_interval": 2.97, + "electricity_consumed": 16.5, + "electricity_consumed_interval": 0.5, "electricity_produced": 0.0, "electricity_produced_interval": 0.0 }, "switches": { - "relay": true, - "lock": true - } + "lock": true, + "relay": true + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A14" }, - "e7693eb9582644e5b865dba8d4447cf1": { - "dev_class": "thermostatic_radiator_valve", + "d3da73bde12a47d5a6b8f9dad971f2ec": { + "available": true, + "dev_class": "thermo_sensor", "firmware": "2019-03-27T01:00:00+01:00", "hardware": "1", - "location": "446ac08dd04d4eff8ac57489757b7314", + "location": "82fa13f017d240daa0d0ea1775420f24", "model": "Tom/Floor", - "name": "CV Kraan Garage", - "zigbee_mac_address": "ABCD012345670A11", - "vendor": "Plugwise", - "thermostat": { - "setpoint": 5.5, - "lower_bound": 0.0, - "upper_bound": 100.0, - "resolution": 0.01 + "name": "Thermostatic Radiator Jessie", + "sensors": { + "battery": 62, + "setpoint": 15.0, + "temperature": 17.1, + "temperature_difference": 0.1, + "valve_position": 0.0 }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A10" + }, + "df4a4a8169904cdb9c03d61a21f42140": { + "active_preset": "away", "available": true, - "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], - "active_preset": "no_frost", "available_schedules": [ "CV Roan", "Bios Schema met Film Avond", @@ -414,16 +302,128 @@ "Badkamer Schema", "CV Jessie" ], - "selected_schedule": "None", + "dev_class": "zone_thermostat", + "firmware": "2016-10-27T02:00:00+02:00", + "hardware": "255", "last_used": "Badkamer Schema", + "location": "12493538af164a409c6a1c79e38afe1c", "mode": "heat", + "model": "Lisa", + "name": "Zone Lisa Bios", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "None", + "sensors": { + "battery": 67, + "setpoint": 13.0, + "temperature": 16.5 + }, + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint": 13.0, + "upper_bound": 99.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A06" + }, + "e7693eb9582644e5b865dba8d4447cf1": { + "active_preset": "no_frost", + "available": true, + "available_schedules": [ + "CV Roan", + "Bios Schema met Film Avond", + "GF7 Woonkamer", + "Badkamer Schema", + "CV Jessie" + ], + "dev_class": "thermostatic_radiator_valve", + "firmware": "2019-03-27T01:00:00+01:00", + "hardware": "1", + "last_used": "Badkamer Schema", + "location": "446ac08dd04d4eff8ac57489757b7314", + "mode": "heat", + "model": "Tom/Floor", + "name": "CV Kraan Garage", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "None", "sensors": { - "temperature": 15.6, - "setpoint": 5.5, "battery": 68, + "setpoint": 5.5, + "temperature": 15.6, "temperature_difference": 0.0, "valve_position": 0.0 - } + }, + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint": 5.5, + "upper_bound": 100.0 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A11" + }, + "f1fee6043d3642a9b0a65297455f008e": { + "active_preset": "away", + "available": true, + "available_schedules": [ + "CV Roan", + "Bios Schema met Film Avond", + "GF7 Woonkamer", + "Badkamer Schema", + "CV Jessie" + ], + "dev_class": "zone_thermostat", + "firmware": "2016-10-27T02:00:00+02:00", + "hardware": "255", + "last_used": "Badkamer Schema", + "location": "08963fec7c53423ca5680aa4cb502c63", + "mode": "auto", + "model": "Lisa", + "name": "Zone Thermostat Badkamer", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "Badkamer Schema", + "sensors": { + "battery": 92, + "setpoint": 14.0, + "temperature": 18.9 + }, + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint": 14.0, + "upper_bound": 99.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A08" + }, + "fe799307f1624099878210aa0b9f1475": { + "binary_sensors": { + "plugwise_notification": true + }, + "dev_class": "gateway", + "firmware": "3.0.15", + "hardware": "AME Smile 2.0 board", + "location": "1f9dcf83fd4e4b66b72ff787957bfe5d", + "mac_address": "012345670001", + "model": "Gateway", + "name": "Adam", + "select_regulation_mode": "heating", + "sensors": { + "outdoor_temperature": 7.81 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670101" } + }, + "gateway": { + "cooling_present": false, + "gateway_id": "fe799307f1624099878210aa0b9f1475", + "heater_id": "90986d591dcd426cae3ec3e8111ff730", + "notifications": { + "af82e4ccf9c548528166d38e560662a4": { + "warning": "Node Plug (with MAC address 000D6F000D13CB01, in room 'n.a.') has been unreachable since 23:03 2020-01-18. Please check the connection and restart the device." + } + }, + "smile_name": "Adam" } -] +} diff --git a/tests/components/plugwise/fixtures/anna_heatpump_heating/all_data.json b/tests/components/plugwise/fixtures/anna_heatpump_heating/all_data.json index f00293a6554..49b5221233f 100644 --- a/tests/components/plugwise/fixtures/anna_heatpump_heating/all_data.json +++ b/tests/components/plugwise/fixtures/anna_heatpump_heating/all_data.json @@ -1,48 +1,9 @@ -[ - { - "smile_name": "Smile Anna", - "gateway_id": "015ae9ea3f964e668e490fa39da3870b", - "heater_id": "1cbf783bb11e4a7c8a6843dee3a86927", - "cooling_present": false, - "notifications": {} - }, - { - "1cbf783bb11e4a7c8a6843dee3a86927": { - "dev_class": "heater_central", - "location": "a57efe5f145f498c9be62a9b63626fbf", - "model": "Generic heater/cooler", - "name": "OpenTherm", - "vendor": "Techneco", - "maximum_boiler_temperature": { - "setpoint": 60.0, - "lower_bound": 0.0, - "upper_bound": 100.0, - "resolution": 1.0 - }, - "available": true, - "binary_sensors": { - "cooling_enabled": false, - "dhw_state": false, - "heating_state": true, - "compressor_state": true, - "slave_boiler_state": false, - "flame_state": false - }, - "sensors": { - "water_temperature": 29.1, - "domestic_hot_water_setpoint": 60.0, - "dhw_temperature": 46.3, - "intended_boiler_temperature": 35.0, - "modulation_level": 52, - "return_temperature": 25.1, - "water_pressure": 1.57, - "outdoor_air_temperature": 3.0 - }, - "switches": { - "dhw_cm_switch": false - } - }, +{ + "devices": { "015ae9ea3f964e668e490fa39da3870b": { + "binary_sensors": { + "plugwise_notification": false + }, "dev_class": "gateway", "firmware": "4.0.15", "hardware": "AME Smile 2.0 board", @@ -50,41 +11,85 @@ "mac_address": "012345670001", "model": "Gateway", "name": "Smile Anna", - "vendor": "Plugwise", - "binary_sensors": { - "plugwise_notification": false - }, "sensors": { "outdoor_temperature": 20.2 - } + }, + "vendor": "Plugwise" + }, + "1cbf783bb11e4a7c8a6843dee3a86927": { + "available": true, + "binary_sensors": { + "compressor_state": true, + "cooling_enabled": false, + "dhw_state": false, + "flame_state": false, + "heating_state": true, + "slave_boiler_state": false + }, + "dev_class": "heater_central", + "location": "a57efe5f145f498c9be62a9b63626fbf", + "max_dhw_temperature": { + "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 + }, + "model": "Generic heater", + "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 + }, + "switches": { + "dhw_cm_switch": false + }, + "vendor": "Techneco" }, "3cb70739631c4d17a86b8b12e8a5161b": { + "active_preset": "home", + "available_schedules": ["standaard"], "dev_class": "thermostat", "firmware": "2018-02-08T11:15:53+01:00", "hardware": "6539-1301-5002", + "last_used": "standaard", "location": "c784ee9fdab44e1395b8dee7d7a497d5", + "mode": "auto", "model": "ThermoTouch", "name": "Anna", - "vendor": "Plugwise", - "thermostat": { - "setpoint": 20.5, - "lower_bound": 4.0, - "upper_bound": 30.0, - "resolution": 0.1 - }, "preset_modes": ["no_frost", "home", "away", "asleep", "vacation"], - "active_preset": "home", - "available_schedules": ["standaard"], - "selected_schedule": "standaard", - "last_used": "standaard", - "mode": "auto", + "select_schedule": "standaard", "sensors": { - "temperature": 19.3, - "setpoint": 20.5, - "illuminance": 86.0, "cooling_activation_outdoor_temperature": 21.0, - "cooling_deactivation_threshold": 4.0 - } + "cooling_deactivation_threshold": 4.0, + "illuminance": 86.0, + "setpoint": 20.5, + "temperature": 19.3 + }, + "thermostat": { + "lower_bound": 4.0, + "resolution": 0.1, + "setpoint": 20.5, + "upper_bound": 30.0 + }, + "vendor": "Plugwise" } + }, + "gateway": { + "cooling_present": false, + "gateway_id": "015ae9ea3f964e668e490fa39da3870b", + "heater_id": "1cbf783bb11e4a7c8a6843dee3a86927", + "notifications": {}, + "smile_name": "Smile Anna" } -] +} diff --git a/tests/components/plugwise/fixtures/m_adam_cooling/all_data.json b/tests/components/plugwise/fixtures/m_adam_cooling/all_data.json index 06a3fa400bf..92618a90189 100644 --- a/tests/components/plugwise/fixtures/m_adam_cooling/all_data.json +++ b/tests/components/plugwise/fixtures/m_adam_cooling/all_data.json @@ -1,88 +1,80 @@ -[ - { - "smile_name": "Adam", - "gateway_id": "da224107914542988a88561b4452b0f6", - "heater_id": "056ee145a816487eaa69243c3280f8bf", - "cooling_present": true, - "notifications": {} - }, - { - "ad4838d7d35c4d6ea796ee12ae5aedf8": { - "dev_class": "thermostat", - "location": "f2bf9048bef64cc5b6d5110154e33c81", - "model": "ThermoTouch", - "name": "Anna", - "vendor": "Plugwise", - "thermostat": { - "setpoint_low": 4.0, - "setpoint_high": 23.5, - "lower_bound": 1.0, - "upper_bound": 35.0, - "resolution": 0.01 - }, +{ + "devices": { + "056ee145a816487eaa69243c3280f8bf": { "available": true, - "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], - "active_preset": "asleep", - "available_schedules": ["Weekschema", "Badkamer", "Test"], - "selected_schedule": "None", - "last_used": "Weekschema", - "control_state": "cooling", - "mode": "heat_cool", + "binary_sensors": { + "cooling_state": true, + "dhw_state": false, + "flame_state": false, + "heating_state": false + }, + "dev_class": "heater_central", + "location": "bc93488efab249e5bc54fd7e175a6f91", + "maximum_boiler_temperature": { + "lower_bound": 25.0, + "resolution": 0.01, + "setpoint": 60.0, + "upper_bound": 95.0 + }, + "model": "Generic heater", + "name": "OpenTherm", "sensors": { - "temperature": 25.8, - "setpoint_low": 4.0, - "setpoint_high": 23.5 + "intended_boiler_temperature": 17.5, + "water_temperature": 19.0 + }, + "switches": { + "dhw_cm_switch": false } }, "1772a4ea304041adb83f357b751341ff": { + "available": true, "dev_class": "thermo_sensor", "firmware": "2020-11-04T01:00:00+01:00", "hardware": "1", "location": "f871b8c4d63549319221e294e4f88074", "model": "Tom/Floor", "name": "Tom Badkamer", - "zigbee_mac_address": "ABCD012345670A01", - "vendor": "Plugwise", - "available": true, "sensors": { - "temperature": 21.6, "battery": 99, + "temperature": 21.6, "temperature_difference": 2.3, "valve_position": 0.0 - } - }, - "e2f4322d57924fa090fbbc48b3a140dc": { - "dev_class": "zone_thermostat", - "firmware": "2016-10-10T02:00:00+02:00", - "hardware": "255", - "location": "f871b8c4d63549319221e294e4f88074", - "model": "Lisa", - "name": "Lisa Badkamer", - "zigbee_mac_address": "ABCD012345670A04", - "vendor": "Plugwise", - "thermostat": { - "setpoint_low": 19.0, - "setpoint_high": 25.0, - "lower_bound": 0.0, - "upper_bound": 99.9, - "resolution": 0.01 }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A01" + }, + "ad4838d7d35c4d6ea796ee12ae5aedf8": { + "active_preset": "asleep", "available": true, - "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], - "active_preset": "home", "available_schedules": ["Weekschema", "Badkamer", "Test"], - "selected_schedule": "Badkamer", - "last_used": "Badkamer", - "control_state": "off", - "mode": "auto", + "control_state": "cooling", + "dev_class": "thermostat", + "last_used": "Weekschema", + "location": "f2bf9048bef64cc5b6d5110154e33c81", + "mode": "heat_cool", + "model": "ThermoTouch", + "name": "Anna", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "Weekschema", + "selected_schedule": "None", "sensors": { - "temperature": 239, - "battery": 56, - "setpoint_low": 20.0, - "setpoint_high": 23.5 - } + "setpoint_high": 23.5, + "setpoint_low": 4.0, + "temperature": 25.8 + }, + "thermostat": { + "lower_bound": 1.0, + "resolution": 0.01, + "setpoint_high": 23.5, + "setpoint_low": 4.0, + "upper_bound": 35.0 + }, + "vendor": "Plugwise" }, "da224107914542988a88561b4452b0f6": { + "binary_sensors": { + "plugwise_notification": false + }, "dev_class": "gateway", "firmware": "3.6.4", "hardware": "AME Smile 2.0 board", @@ -90,60 +82,70 @@ "mac_address": "012345670001", "model": "Gateway", "name": "Adam", - "zigbee_mac_address": "ABCD012345670101", - "vendor": "Plugwise", "regulation_mode": "cooling", "regulation_modes": [ - "cooling", "heating", "off", "bleeding_cold", - "bleeding_hot" + "bleeding_hot", + "cooling" ], - "binary_sensors": { - "plugwise_notification": false - }, + "select_regulation_mode": "heating", "sensors": { "outdoor_temperature": 29.65 - } + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670101" }, - "056ee145a816487eaa69243c3280f8bf": { - "dev_class": "heater_central", - "location": "bc93488efab249e5bc54fd7e175a6f91", - "model": "Generic heater", - "name": "OpenTherm", - "maximum_boiler_temperature": { - "setpoint": 60.0, - "lower_bound": 25.0, - "upper_bound": 95.0, - "resolution": 0.01 - }, + "e2f4322d57924fa090fbbc48b3a140dc": { + "active_preset": "home", "available": true, - "binary_sensors": { - "cooling_state": true, - "dhw_state": false, - "heating_state": false, - "flame_state": false - }, + "available_schedules": ["Weekschema", "Badkamer", "Test"], + "control_state": "off", + "dev_class": "zone_thermostat", + "firmware": "2016-10-10T02:00:00+02:00", + "hardware": "255", + "last_used": "Badkamer", + "location": "f871b8c4d63549319221e294e4f88074", + "mode": "auto", + "model": "Lisa", + "name": "Lisa Badkamer", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "Badkamer", "sensors": { - "water_temperature": 19.0, - "intended_boiler_temperature": 17.5 + "battery": 56, + "setpoint_high": 23.5, + "setpoint_low": 20.0, + "temperature": 239 }, - "switches": { - "dhw_cm_switch": false - } + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint_high": 25.0, + "setpoint_low": 19.0, + "upper_bound": 99.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A04" }, "e8ef2a01ed3b4139a53bf749204fe6b4": { "dev_class": "switching", - "model": "Switchgroup", - "name": "Test", "members": [ "2568cc4b9c1e401495d4741a5f89bee1", "29542b2b6a6a4169acecc15c72a599b8" ], + "model": "Switchgroup", + "name": "Test", "switches": { "relay": true } } + }, + "gateway": { + "cooling_present": true, + "gateway_id": "da224107914542988a88561b4452b0f6", + "heater_id": "056ee145a816487eaa69243c3280f8bf", + "notifications": {}, + "smile_name": "Adam" } -] +} diff --git a/tests/components/plugwise/fixtures/m_adam_heating/all_data.json b/tests/components/plugwise/fixtures/m_adam_heating/all_data.json index 8ee3df544e5..4345cf76a3a 100644 --- a/tests/components/plugwise/fixtures/m_adam_heating/all_data.json +++ b/tests/components/plugwise/fixtures/m_adam_heating/all_data.json @@ -1,81 +1,83 @@ -[ - { - "smile_name": "Adam", - "gateway_id": "da224107914542988a88561b4452b0f6", - "heater_id": "056ee145a816487eaa69243c3280f8bf", - "cooling_present": false, - "notifications": {} - }, - { - "ad4838d7d35c4d6ea796ee12ae5aedf8": { - "dev_class": "thermostat", - "location": "f2bf9048bef64cc5b6d5110154e33c81", - "model": "ThermoTouch", - "name": "Anna", - "vendor": "Plugwise", - "thermostat": { - "setpoint": 20.0, - "lower_bound": 1.0, - "upper_bound": 35.0, - "resolution": 0.01 - }, +{ + "devices": { + "056ee145a816487eaa69243c3280f8bf": { "available": true, - "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], - "active_preset": "asleep", - "available_schedules": ["Weekschema", "Badkamer", "Test"], - "selected_schedule": "None", - "last_used": "Weekschema", - "control_state": "heating", - "mode": "heat", - "sensors": { "temperature": 19.1, "setpoint": 20.0 } + "binary_sensors": { + "dhw_state": false, + "flame_state": false, + "heating_state": true + }, + "dev_class": "heater_central", + "location": "bc93488efab249e5bc54fd7e175a6f91", + "max_dhw_temperature": { + "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": 60.0, + "upper_bound": 95.0 + }, + "model": "Generic heater", + "name": "OpenTherm", + "sensors": { + "intended_boiler_temperature": 38.1, + "water_temperature": 37.0 + }, + "switches": { + "dhw_cm_switch": false + } }, "1772a4ea304041adb83f357b751341ff": { + "available": true, "dev_class": "thermo_sensor", "firmware": "2020-11-04T01:00:00+01:00", "hardware": "1", "location": "f871b8c4d63549319221e294e4f88074", "model": "Tom/Floor", "name": "Tom Badkamer", - "zigbee_mac_address": "ABCD012345670A01", - "vendor": "Plugwise", - "available": true, "sensors": { - "temperature": 18.6, "battery": 99, + "temperature": 18.6, "temperature_difference": 2.3, "valve_position": 0.0 - } - }, - "e2f4322d57924fa090fbbc48b3a140dc": { - "dev_class": "zone_thermostat", - "firmware": "2016-10-10T02:00:00+02:00", - "hardware": "255", - "location": "f871b8c4d63549319221e294e4f88074", - "model": "Lisa", - "name": "Lisa Badkamer", - "zigbee_mac_address": "ABCD012345670A04", - "vendor": "Plugwise", - "thermostat": { - "setpoint": 15.0, - "lower_bound": 0.0, - "upper_bound": 99.9, - "resolution": 0.01 }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A01" + }, + "ad4838d7d35c4d6ea796ee12ae5aedf8": { + "active_preset": "asleep", "available": true, - "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], - "active_preset": "home", "available_schedules": ["Weekschema", "Badkamer", "Test"], - "selected_schedule": "Badkamer", - "last_used": "Badkamer", - "control_state": "off", - "mode": "auto", + "control_state": "heating", + "dev_class": "thermostat", + "last_used": "Weekschema", + "location": "f2bf9048bef64cc5b6d5110154e33c81", + "mode": "heat", + "model": "ThermoTouch", + "name": "Anna", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "Weekschema", + "selected_schedule": "None", "sensors": { - "temperature": 17.9, - "battery": 56, - "setpoint": 15.0 - } + "setpoint": 20.0, + "temperature": 19.1 + }, + "thermostat": { + "lower_bound": 1.0, + "resolution": 0.01, + "setpoint": 20.0, + "upper_bound": 35.0 + }, + "vendor": "Plugwise" }, "da224107914542988a88561b4452b0f6": { + "binary_sensors": { + "plugwise_notification": false + }, "dev_class": "gateway", "firmware": "3.6.4", "hardware": "AME Smile 2.0 board", @@ -83,59 +85,62 @@ "mac_address": "012345670001", "model": "Gateway", "name": "Adam", - "zigbee_mac_address": "ABCD012345670101", - "vendor": "Plugwise", "regulation_mode": "heating", "regulation_modes": ["heating", "off", "bleeding_cold", "bleeding_hot"], - "binary_sensors": { - "plugwise_notification": false - }, + "select_regulation_mode": "heating", "sensors": { "outdoor_temperature": -1.25 - } + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670101" }, - "056ee145a816487eaa69243c3280f8bf": { - "dev_class": "heater_central", - "location": "bc93488efab249e5bc54fd7e175a6f91", - "model": "Generic heater", - "name": "OpenTherm", - "maximum_boiler_temperature": { - "setpoint": 60.0, - "lower_bound": 25.0, - "upper_bound": 95.0, - "resolution": 0.01 - }, - "domestic_hot_water_setpoint": { - "setpoint": 60.0, - "lower_bound": 40.0, - "upper_bound": 60.0, - "resolution": 0.01 - }, + "e2f4322d57924fa090fbbc48b3a140dc": { + "active_preset": "home", "available": true, - "binary_sensors": { - "dhw_state": false, - "heating_state": true, - "flame_state": false - }, + "available_schedules": ["Weekschema", "Badkamer", "Test"], + "control_state": "off", + "dev_class": "zone_thermostat", + "firmware": "2016-10-10T02:00:00+02:00", + "hardware": "255", + "last_used": "Badkamer", + "location": "f871b8c4d63549319221e294e4f88074", + "mode": "auto", + "model": "Lisa", + "name": "Lisa Badkamer", + "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], + "select_schedule": "Badkamer", "sensors": { - "water_temperature": 37.0, - "intended_boiler_temperature": 38.1 + "battery": 56, + "setpoint": 15.0, + "temperature": 17.9 }, - "switches": { - "dhw_cm_switch": false - } + "thermostat": { + "lower_bound": 0.0, + "resolution": 0.01, + "setpoint": 15.0, + "upper_bound": 99.9 + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A04" }, "e8ef2a01ed3b4139a53bf749204fe6b4": { "dev_class": "switching", - "model": "Switchgroup", - "name": "Test", "members": [ "2568cc4b9c1e401495d4741a5f89bee1", "29542b2b6a6a4169acecc15c72a599b8" ], + "model": "Switchgroup", + "name": "Test", "switches": { "relay": true } } + }, + "gateway": { + "cooling_present": false, + "gateway_id": "da224107914542988a88561b4452b0f6", + "heater_id": "056ee145a816487eaa69243c3280f8bf", + "notifications": {}, + "smile_name": "Adam" } -] +} diff --git a/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/all_data.json b/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/all_data.json index ba980a7fce3..20f2db213bd 100644 --- a/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/all_data.json +++ b/tests/components/plugwise/fixtures/m_anna_heatpump_cooling/all_data.json @@ -1,49 +1,9 @@ -[ - { - "smile_name": "Smile Anna", - "gateway_id": "015ae9ea3f964e668e490fa39da3870b", - "heater_id": "1cbf783bb11e4a7c8a6843dee3a86927", - "cooling_present": true, - "notifications": {} - }, - { - "1cbf783bb11e4a7c8a6843dee3a86927": { - "dev_class": "heater_central", - "location": "a57efe5f145f498c9be62a9b63626fbf", - "model": "Generic heater/cooler", - "name": "OpenTherm", - "vendor": "Techneco", - "maximum_boiler_temperature": { - "setpoint": 60.0, - "lower_bound": 0.0, - "upper_bound": 100.0, - "resolution": 1.0 - }, - "available": true, - "binary_sensors": { - "cooling_enabled": true, - "dhw_state": false, - "heating_state": false, - "compressor_state": true, - "cooling_state": true, - "slave_boiler_state": false, - "flame_state": false - }, - "sensors": { - "water_temperature": 22.7, - "domestic_hot_water_setpoint": 60.0, - "dhw_temperature": 41.5, - "intended_boiler_temperature": 0.0, - "modulation_level": 40, - "return_temperature": 23.8, - "water_pressure": 1.57, - "outdoor_air_temperature": 28.0 - }, - "switches": { - "dhw_cm_switch": false - } - }, +{ + "devices": { "015ae9ea3f964e668e490fa39da3870b": { + "binary_sensors": { + "plugwise_notification": false + }, "dev_class": "gateway", "firmware": "4.0.15", "hardware": "AME Smile 2.0 board", @@ -51,43 +11,88 @@ "mac_address": "012345670001", "model": "Gateway", "name": "Smile Anna", - "vendor": "Plugwise", - "binary_sensors": { - "plugwise_notification": false - }, "sensors": { "outdoor_temperature": 28.2 - } + }, + "vendor": "Plugwise" + }, + "1cbf783bb11e4a7c8a6843dee3a86927": { + "available": true, + "binary_sensors": { + "compressor_state": true, + "cooling_enabled": true, + "cooling_state": true, + "dhw_state": false, + "flame_state": false, + "heating_state": false, + "slave_boiler_state": false + }, + "dev_class": "heater_central", + "location": "a57efe5f145f498c9be62a9b63626fbf", + "max_dhw_temperature": { + "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 + }, + "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 + }, + "switches": { + "dhw_cm_switch": false + }, + "vendor": "Techneco" }, "3cb70739631c4d17a86b8b12e8a5161b": { + "active_preset": "home", + "available_schedules": ["standaard"], "dev_class": "thermostat", "firmware": "2018-02-08T11:15:53+01:00", "hardware": "6539-1301-5002", + "last_used": "standaard", "location": "c784ee9fdab44e1395b8dee7d7a497d5", + "mode": "auto", "model": "ThermoTouch", "name": "Anna", - "vendor": "Plugwise", - "thermostat": { - "setpoint_low": 20.5, - "setpoint_high": 24.0, - "lower_bound": 4.0, - "upper_bound": 30.0, - "resolution": 0.1 - }, "preset_modes": ["no_frost", "home", "away", "asleep", "vacation"], - "active_preset": "home", - "available_schedules": ["standaard"], - "selected_schedule": "standaard", - "last_used": "standaard", - "mode": "auto", + "select_schedule": "standaard", "sensors": { - "temperature": 26.3, - "illuminance": 86.0, "cooling_activation_outdoor_temperature": 21.0, "cooling_deactivation_threshold": 4.0, + "illuminance": 86.0, + "setpoint_high": 24.0, "setpoint_low": 20.5, - "setpoint_high": 24.0 - } + "temperature": 26.3 + }, + "thermostat": { + "lower_bound": 4.0, + "resolution": 0.1, + "setpoint_high": 24.0, + "setpoint_low": 20.5, + "upper_bound": 30.0 + }, + "vendor": "Plugwise" } + }, + "gateway": { + "cooling_present": true, + "gateway_id": "015ae9ea3f964e668e490fa39da3870b", + "heater_id": "1cbf783bb11e4a7c8a6843dee3a86927", + "notifications": {}, + "smile_name": "Smile Anna" } -] +} diff --git a/tests/components/plugwise/fixtures/m_anna_heatpump_idle/all_data.json b/tests/components/plugwise/fixtures/m_anna_heatpump_idle/all_data.json index 0a421be5343..3a7bd2dae89 100644 --- a/tests/components/plugwise/fixtures/m_anna_heatpump_idle/all_data.json +++ b/tests/components/plugwise/fixtures/m_anna_heatpump_idle/all_data.json @@ -1,48 +1,9 @@ -[ - { - "smile_name": "Smile Anna", - "gateway_id": "015ae9ea3f964e668e490fa39da3870b", - "heater_id": "1cbf783bb11e4a7c8a6843dee3a86927", - "cooling_present": true, - "notifications": {} - }, - { - "1cbf783bb11e4a7c8a6843dee3a86927": { - "dev_class": "heater_central", - "location": "a57efe5f145f498c9be62a9b63626fbf", - "model": "Generic heater/cooler", - "name": "OpenTherm", - "vendor": "Techneco", - "maximum_boiler_temperature": { - "setpoint": 60.0, - "lower_bound": 0.0, - "upper_bound": 100.0, - "resolution": 1.0 - }, - "available": true, - "binary_sensors": { - "cooling_enabled": true, - "dhw_state": false, - "heating_state": false, - "compressor_state": false, - "cooling_state": false, - "slave_boiler_state": false, - "flame_state": false - }, - "sensors": { - "water_temperature": 19.1, - "dhw_temperature": 46.3, - "intended_boiler_temperature": 18.0, - "modulation_level": 0, - "return_temperature": 22.0, - "water_pressure": 1.57, - "outdoor_air_temperature": 28.2 - }, - "switches": { - "dhw_cm_switch": false - } - }, +{ + "devices": { "015ae9ea3f964e668e490fa39da3870b": { + "binary_sensors": { + "plugwise_notification": false + }, "dev_class": "gateway", "firmware": "4.0.15", "hardware": "AME Smile 2.0 board", @@ -50,43 +11,88 @@ "mac_address": "012345670001", "model": "Gateway", "name": "Smile Anna", - "vendor": "Plugwise", - "binary_sensors": { - "plugwise_notification": false - }, "sensors": { "outdoor_temperature": 28.2 - } + }, + "vendor": "Plugwise" + }, + "1cbf783bb11e4a7c8a6843dee3a86927": { + "available": true, + "binary_sensors": { + "compressor_state": false, + "cooling_enabled": true, + "cooling_state": false, + "dhw_state": false, + "flame_state": false, + "heating_state": false, + "slave_boiler_state": false + }, + "dev_class": "heater_central", + "location": "a57efe5f145f498c9be62a9b63626fbf", + "max_dhw_temperature": { + "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 + }, + "model": "Generic heater/cooler", + "name": "OpenTherm", + "sensors": { + "dhw_temperature": 46.3, + "intended_boiler_temperature": 18.0, + "modulation_level": 0, + "outdoor_air_temperature": 28.2, + "return_temperature": 22.0, + "water_pressure": 1.57, + "water_temperature": 19.1 + }, + "switches": { + "dhw_cm_switch": false + }, + "vendor": "Techneco" }, "3cb70739631c4d17a86b8b12e8a5161b": { + "active_preset": "home", + "available_schedules": ["standaard"], "dev_class": "thermostat", "firmware": "2018-02-08T11:15:53+01:00", "hardware": "6539-1301-5002", + "last_used": "standaard", "location": "c784ee9fdab44e1395b8dee7d7a497d5", + "mode": "auto", "model": "ThermoTouch", "name": "Anna", - "vendor": "Plugwise", - "thermostat": { - "setpoint_low": 20.5, - "setpoint_high": 24.0, - "lower_bound": 4.0, - "upper_bound": 30.0, - "resolution": 0.1 - }, "preset_modes": ["no_frost", "home", "away", "asleep", "vacation"], - "active_preset": "home", - "available_schedules": ["standaard"], - "selected_schedule": "standaard", - "last_used": "standaard", - "mode": "auto", + "select_schedule": "standaard", "sensors": { - "temperature": 23.0, - "illuminance": 86.0, "cooling_activation_outdoor_temperature": 25.0, "cooling_deactivation_threshold": 4.0, + "illuminance": 86.0, + "setpoint_high": 24.0, "setpoint_low": 20.5, - "setpoint_high": 24.0 - } + "temperature": 23.0 + }, + "thermostat": { + "lower_bound": 4.0, + "resolution": 0.1, + "setpoint_high": 24.0, + "setpoint_low": 20.5, + "upper_bound": 30.0 + }, + "vendor": "Plugwise" } + }, + "gateway": { + "cooling_present": true, + "gateway_id": "015ae9ea3f964e668e490fa39da3870b", + "heater_id": "1cbf783bb11e4a7c8a6843dee3a86927", + "notifications": {}, + "smile_name": "Smile Anna" } -] +} diff --git a/tests/components/plugwise/fixtures/p1v3_full_option/all_data.json b/tests/components/plugwise/fixtures/p1v3_full_option/all_data.json index c52f33e6323..0e0b3c51a07 100644 --- a/tests/components/plugwise/fixtures/p1v3_full_option/all_data.json +++ b/tests/components/plugwise/fixtures/p1v3_full_option/all_data.json @@ -1,11 +1,9 @@ -[ - { - "smile_name": "Smile P1", - "gateway_id": "cd3e822288064775a7c4afcdd70bdda2", - "notifications": {} - }, - { +{ + "devices": { "cd3e822288064775a7c4afcdd70bdda2": { + "binary_sensors": { + "plugwise_notification": false + }, "dev_class": "gateway", "firmware": "3.3.9", "hardware": "AME Smile 2.0 board", @@ -13,36 +11,38 @@ "mac_address": "012345670001", "model": "Gateway", "name": "Smile P1", - "vendor": "Plugwise", - "binary_sensors": { - "plugwise_notification": false - } + "vendor": "Plugwise" }, "e950c7d5e1ee407a858e2a8b5016c8b3": { + "available": true, "dev_class": "smartmeter", "location": "cd3e822288064775a7c4afcdd70bdda2", "model": "2M550E-1012", "name": "P1", - "vendor": "ISKRAEMECO", - "available": true, "sensors": { - "net_electricity_point": -2816, - "electricity_consumed_peak_point": 0, - "electricity_consumed_off_peak_point": 0, - "net_electricity_cumulative": 442.972, - "electricity_consumed_peak_cumulative": 442.932, "electricity_consumed_off_peak_cumulative": 551.09, - "electricity_consumed_peak_interval": 0, "electricity_consumed_off_peak_interval": 0, - "electricity_produced_peak_point": 2816, + "electricity_consumed_off_peak_point": 0, + "electricity_consumed_peak_cumulative": 442.932, + "electricity_consumed_peak_interval": 0, + "electricity_consumed_peak_point": 0, + "electricity_produced_off_peak_cumulative": 154.491, + "electricity_produced_off_peak_interval": 0, "electricity_produced_off_peak_point": 0, "electricity_produced_peak_cumulative": 396.559, - "electricity_produced_off_peak_cumulative": 154.491, "electricity_produced_peak_interval": 0, - "electricity_produced_off_peak_interval": 0, + "electricity_produced_peak_point": 2816, "gas_consumed_cumulative": 584.85, - "gas_consumed_interval": 0.0 - } + "gas_consumed_interval": 0.0, + "net_electricity_cumulative": 442.972, + "net_electricity_point": -2816 + }, + "vendor": "ISKRAEMECO" } + }, + "gateway": { + "gateway_id": "cd3e822288064775a7c4afcdd70bdda2", + "notifications": {}, + "smile_name": "Smile P1" } -] +} diff --git a/tests/components/plugwise/fixtures/p1v4_3ph/all_data.json b/tests/components/plugwise/fixtures/p1v4_442_triple/all_data.json similarity index 88% rename from tests/components/plugwise/fixtures/p1v4_3ph/all_data.json rename to tests/components/plugwise/fixtures/p1v4_442_triple/all_data.json index 852ca2857cd..e9a3b4c68b9 100644 --- a/tests/components/plugwise/fixtures/p1v4_3ph/all_data.json +++ b/tests/components/plugwise/fixtures/p1v4_442_triple/all_data.json @@ -1,11 +1,9 @@ -[ - { - "smile_name": "Smile P1", - "gateway_id": "03e65b16e4b247a29ae0d75a78cb492e", - "notifications": {} - }, - { +{ + "devices": { "03e65b16e4b247a29ae0d75a78cb492e": { + "binary_sensors": { + "plugwise_notification": false + }, "dev_class": "gateway", "firmware": "4.4.2", "hardware": "AME Smile 2.0 board", @@ -13,45 +11,47 @@ "mac_address": "012345670001", "model": "Gateway", "name": "Smile P1", - "vendor": "Plugwise", - "binary_sensors": { - "plugwise_notification": false - } + "vendor": "Plugwise" }, "b82b6b3322484f2ea4e25e0bd5f3d61f": { + "available": true, "dev_class": "smartmeter", "location": "03e65b16e4b247a29ae0d75a78cb492e", "model": "XMX5LGF0010453051839", "name": "P1", - "vendor": "XEMEX NV", - "available": true, "sensors": { - "net_electricity_point": 5553, - "electricity_consumed_peak_point": 0, - "electricity_consumed_off_peak_point": 5553, - "net_electricity_cumulative": 231866.539, - "electricity_consumed_peak_cumulative": 161328.641, "electricity_consumed_off_peak_cumulative": 70537.898, - "electricity_consumed_peak_interval": 0, "electricity_consumed_off_peak_interval": 314, - "electricity_produced_peak_point": 0, + "electricity_consumed_off_peak_point": 5553, + "electricity_consumed_peak_cumulative": 161328.641, + "electricity_consumed_peak_interval": 0, + "electricity_consumed_peak_point": 0, + "electricity_phase_one_consumed": 1763, + "electricity_phase_one_produced": 0, + "electricity_phase_three_consumed": 2080, + "electricity_phase_three_produced": 0, + "electricity_phase_two_consumed": 1703, + "electricity_phase_two_produced": 0, + "electricity_produced_off_peak_cumulative": 0.0, + "electricity_produced_off_peak_interval": 0, "electricity_produced_off_peak_point": 0, "electricity_produced_peak_cumulative": 0.0, - "electricity_produced_off_peak_cumulative": 0.0, "electricity_produced_peak_interval": 0, - "electricity_produced_off_peak_interval": 0, - "electricity_phase_one_consumed": 1763, - "electricity_phase_two_consumed": 1703, - "electricity_phase_three_consumed": 2080, - "electricity_phase_one_produced": 0, - "electricity_phase_two_produced": 0, - "electricity_phase_three_produced": 0, + "electricity_produced_peak_point": 0, "gas_consumed_cumulative": 16811.37, "gas_consumed_interval": 0.06, + "net_electricity_cumulative": 231866.539, + "net_electricity_point": 5553, "voltage_phase_one": 233.2, - "voltage_phase_two": 234.4, - "voltage_phase_three": 234.7 - } + "voltage_phase_three": 234.7, + "voltage_phase_two": 234.4 + }, + "vendor": "XEMEX NV" } + }, + "gateway": { + "gateway_id": "03e65b16e4b247a29ae0d75a78cb492e", + "notifications": {}, + "smile_name": "Smile P1" } -] +} diff --git a/tests/components/plugwise/fixtures/p1v4_442_triple/notifications.json b/tests/components/plugwise/fixtures/p1v4_442_triple/notifications.json new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/tests/components/plugwise/fixtures/p1v4_442_triple/notifications.json @@ -0,0 +1 @@ +{} diff --git a/tests/components/plugwise/fixtures/stretch_v31/all_data.json b/tests/components/plugwise/fixtures/stretch_v31/all_data.json index 1ce34e376d7..c336a9cb9c2 100644 --- a/tests/components/plugwise/fixtures/stretch_v31/all_data.json +++ b/tests/components/plugwise/fixtures/stretch_v31/all_data.json @@ -1,10 +1,5 @@ -[ - { - "smile_name": "Stretch", - "gateway_id": "0000aaaa0000aaaa0000aaaa0000aa00", - "notifications": {} - }, - { +{ + "devices": { "0000aaaa0000aaaa0000aaaa0000aa00": { "dev_class": "gateway", "firmware": "3.1.11", @@ -12,8 +7,27 @@ "mac_address": "01:23:45:67:89:AB", "model": "Gateway", "name": "Stretch", - "zigbee_mac_address": "ABCD012345670101", - "vendor": "Plugwise" + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670101" + }, + "059e4d03c7a34d278add5c7a4a781d19": { + "dev_class": "washingmachine", + "firmware": "2011-06-27T10:52:18+02:00", + "hardware": "0000-0440-0107", + "location": "0000aaaa0000aaaa0000aaaa0000aa00", + "model": "Circle type F", + "name": "Wasmachine (52AC1)", + "sensors": { + "electricity_consumed": 0.0, + "electricity_consumed_interval": 0.0, + "electricity_produced": 0.0 + }, + "switches": { + "lock": false, + "relay": true + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A01" }, "5871317346d045bc9f6b987ef25ee638": { "dev_class": "water_heater_vessel", @@ -22,35 +36,25 @@ "location": "0000aaaa0000aaaa0000aaaa0000aa00", "model": "Circle type F", "name": "Boiler (1EB31)", - "zigbee_mac_address": "ABCD012345670A07", - "vendor": "Plugwise", "sensors": { "electricity_consumed": 1.19, "electricity_consumed_interval": 0.0, "electricity_produced": 0.0 }, "switches": { - "relay": true, - "lock": false - } - }, - "e1c884e7dede431dadee09506ec4f859": { - "dev_class": "refrigerator", - "firmware": "2011-06-27T10:47:37+02:00", - "hardware": "6539-0700-7330", - "location": "0000aaaa0000aaaa0000aaaa0000aa00", - "model": "Circle+ type F", - "name": "Koelkast (92C4A)", - "zigbee_mac_address": "0123456789AB", - "vendor": "Plugwise", - "sensors": { - "electricity_consumed": 50.5, - "electricity_consumed_interval": 0.08, - "electricity_produced": 0.0 + "lock": false, + "relay": true }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A07" + }, + "71e1944f2a944b26ad73323e399efef0": { + "dev_class": "switching", + "members": ["5ca521ac179d468e91d772eeeb8a2117"], + "model": "Switchgroup", + "name": "Test", "switches": { - "relay": true, - "lock": false + "relay": true } }, "aac7b735042c4832ac9ff33aae4f453b": { @@ -60,17 +64,17 @@ "location": "0000aaaa0000aaaa0000aaaa0000aa00", "model": "Circle type F", "name": "Vaatwasser (2a1ab)", - "zigbee_mac_address": "ABCD012345670A02", - "vendor": "Plugwise", "sensors": { "electricity_consumed": 0.0, "electricity_consumed_interval": 0.71, "electricity_produced": 0.0 }, "switches": { - "relay": true, - "lock": false - } + "lock": false, + "relay": true + }, + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A02" }, "cfe95cf3de1948c0b8955125bf754614": { "dev_class": "dryer", @@ -79,50 +83,32 @@ "location": "0000aaaa0000aaaa0000aaaa0000aa00", "model": "Circle type F", "name": "Droger (52559)", - "zigbee_mac_address": "ABCD012345670A04", - "vendor": "Plugwise", "sensors": { "electricity_consumed": 0.0, "electricity_consumed_interval": 0.0, "electricity_produced": 0.0 }, "switches": { - "relay": true, - "lock": false - } - }, - "059e4d03c7a34d278add5c7a4a781d19": { - "dev_class": "washingmachine", - "firmware": "2011-06-27T10:52:18+02:00", - "hardware": "0000-0440-0107", - "location": "0000aaaa0000aaaa0000aaaa0000aa00", - "model": "Circle type F", - "name": "Wasmachine (52AC1)", - "zigbee_mac_address": "ABCD012345670A01", - "vendor": "Plugwise", - "sensors": { - "electricity_consumed": 0.0, - "electricity_consumed_interval": 0.0, - "electricity_produced": 0.0 + "lock": false, + "relay": true }, - "switches": { - "relay": true, - "lock": false - } + "vendor": "Plugwise", + "zigbee_mac_address": "ABCD012345670A04" }, - "71e1944f2a944b26ad73323e399efef0": { + "d03738edfcc947f7b8f4573571d90d2d": { "dev_class": "switching", + "members": [ + "059e4d03c7a34d278add5c7a4a781d19", + "cfe95cf3de1948c0b8955125bf754614" + ], "model": "Switchgroup", - "name": "Test", - "members": ["5ca521ac179d468e91d772eeeb8a2117"], + "name": "Schakel", "switches": { "relay": true } }, "d950b314e9d8499f968e6db8d82ef78c": { "dev_class": "report", - "model": "Switchgroup", - "name": "Stroomvreters", "members": [ "059e4d03c7a34d278add5c7a4a781d19", "5871317346d045bc9f6b987ef25ee638", @@ -130,21 +116,35 @@ "cfe95cf3de1948c0b8955125bf754614", "e1c884e7dede431dadee09506ec4f859" ], + "model": "Switchgroup", + "name": "Stroomvreters", "switches": { "relay": true } }, - "d03738edfcc947f7b8f4573571d90d2d": { - "dev_class": "switching", - "model": "Switchgroup", - "name": "Schakel", - "members": [ - "059e4d03c7a34d278add5c7a4a781d19", - "cfe95cf3de1948c0b8955125bf754614" - ], + "e1c884e7dede431dadee09506ec4f859": { + "dev_class": "refrigerator", + "firmware": "2011-06-27T10:47:37+02:00", + "hardware": "6539-0700-7330", + "location": "0000aaaa0000aaaa0000aaaa0000aa00", + "model": "Circle+ type F", + "name": "Koelkast (92C4A)", + "sensors": { + "electricity_consumed": 50.5, + "electricity_consumed_interval": 0.08, + "electricity_produced": 0.0 + }, "switches": { + "lock": false, "relay": true - } + }, + "vendor": "Plugwise", + "zigbee_mac_address": "0123456789AB" } + }, + "gateway": { + "gateway_id": "0000aaaa0000aaaa0000aaaa0000aa00", + "notifications": {}, + "smile_name": "Stretch" } -] +} diff --git a/tests/components/plugwise/test_binary_sensor.py b/tests/components/plugwise/test_binary_sensor.py index f4f2a3f3c5f..aec20bc4a0b 100644 --- a/tests/components/plugwise/test_binary_sensor.py +++ b/tests/components/plugwise/test_binary_sensor.py @@ -4,7 +4,6 @@ from unittest.mock import MagicMock from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant -from homeassistant.helpers.entity_component import async_update_entity from tests.common import MockConfigEntry @@ -30,6 +29,10 @@ async def test_anna_climate_binary_sensor_entities( assert state assert state.state == STATE_OFF + state = hass.states.get("binary_sensor.opentherm_compressor_state") + assert state + assert state.state == STATE_ON + async def test_anna_climate_binary_sensor_change( hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry @@ -42,7 +45,9 @@ async def test_anna_climate_binary_sensor_change( assert state assert state.state == STATE_ON - await async_update_entity(hass, "binary_sensor.opentherm_dhw_state") + await hass.helpers.entity_component.async_update_entity( + "binary_sensor.opentherm_dhw_state" + ) state = hass.states.get("binary_sensor.opentherm_dhw_state") assert state diff --git a/tests/components/plugwise/test_climate.py b/tests/components/plugwise/test_climate.py index 5636523a919..c73bd5b6190 100644 --- a/tests/components/plugwise/test_climate.py +++ b/tests/components/plugwise/test_climate.py @@ -135,6 +135,22 @@ async def test_adam_climate_entity_climate_changes( "c50f167537524366a5af7aa3942feb1e", {"setpoint": 25.0} ) + await hass.services.async_call( + "climate", + "set_temperature", + { + "entity_id": "climate.zone_lisa_wk", + "hvac_mode": "heat", + "temperature": 25, + }, + blocking=True, + ) + + assert mock_smile_adam.set_temperature.call_count == 2 + mock_smile_adam.set_temperature.assert_called_with( + "c50f167537524366a5af7aa3942feb1e", {"setpoint": 25.0} + ) + with pytest.raises(ValueError): await hass.services.async_call( "climate", @@ -162,7 +178,7 @@ async def test_adam_climate_entity_climate_changes( blocking=True, ) - assert mock_smile_adam.set_temperature.call_count == 2 + assert mock_smile_adam.set_temperature.call_count == 3 mock_smile_adam.set_temperature.assert_called_with( "82fa13f017d240daa0d0ea1775420f24", {"setpoint": 25.0} ) diff --git a/tests/components/plugwise/test_diagnostics.py b/tests/components/plugwise/test_diagnostics.py index 6f73619ea77..5dde8a0e09e 100644 --- a/tests/components/plugwise/test_diagnostics.py +++ b/tests/components/plugwise/test_diagnostics.py @@ -15,6 +15,7 @@ async def test_diagnostics( init_integration: MockConfigEntry, ) -> None: """Test diagnostics.""" + assert await get_diagnostics_for_config_entry( hass, hass_client, init_integration ) == { @@ -55,7 +56,7 @@ async def test_diagnostics( "Badkamer Schema", "CV Jessie", ], - "selected_schedule": "None", + "select_schedule": "None", "last_used": "Badkamer Schema", "mode": "heat", "sensors": {"temperature": 16.5, "setpoint": 13.0, "battery": 67}, @@ -120,7 +121,7 @@ async def test_diagnostics( "Badkamer Schema", "CV Jessie", ], - "selected_schedule": "GF7 Woonkamer", + "select_schedule": "GF7 Woonkamer", "last_used": "GF7 Woonkamer", "mode": "auto", "sensors": {"temperature": 20.9, "setpoint": 21.5, "battery": 34}, @@ -135,7 +136,7 @@ async def test_diagnostics( "name": "Adam", "zigbee_mac_address": "ABCD012345670101", "vendor": "Plugwise", - "regulation_mode": "heating", + "select_regulation_mode": "heating", "binary_sensors": {"plugwise_notification": True}, "sensors": {"outdoor_temperature": 7.81}, }, @@ -296,7 +297,7 @@ async def test_diagnostics( "Badkamer Schema", "CV Jessie", ], - "selected_schedule": "CV Jessie", + "select_schedule": "CV Jessie", "last_used": "CV Jessie", "mode": "auto", "sensors": {"temperature": 17.2, "setpoint": 15.0, "battery": 37}, @@ -344,7 +345,7 @@ async def test_diagnostics( "Badkamer Schema", "CV Jessie", ], - "selected_schedule": "Badkamer Schema", + "select_schedule": "Badkamer Schema", "last_used": "Badkamer Schema", "mode": "auto", "sensors": {"temperature": 18.9, "setpoint": 14.0, "battery": 92}, @@ -391,7 +392,7 @@ async def test_diagnostics( "Badkamer Schema", "CV Jessie", ], - "selected_schedule": "None", + "select_schedule": "None", "last_used": "Badkamer Schema", "mode": "heat", "sensors": { diff --git a/tests/components/plugwise/test_init.py b/tests/components/plugwise/test_init.py index 1ed1e509cef..1b5297b71d2 100644 --- a/tests/components/plugwise/test_init.py +++ b/tests/components/plugwise/test_init.py @@ -99,7 +99,7 @@ async def test_migrate_unique_id_temperature( mock_config_entry.add_to_hass(hass) entity_registry = er.async_get(hass) - entity: er.RegistryEntry = entity_registry.async_get_or_create( + entity: entity_registry.RegistryEntry = entity_registry.async_get_or_create( **entitydata, config_entry=mock_config_entry, ) @@ -140,7 +140,7 @@ async def test_migrate_unique_id_relay( mock_config_entry.add_to_hass(hass) entity_registry = er.async_get(hass) - entity: er.RegistryEntry = entity_registry.async_get_or_create( + entity: entity_registry.RegistryEntry = entity_registry.async_get_or_create( **entitydata, config_entry=mock_config_entry, ) diff --git a/tests/components/plugwise/test_sensor.py b/tests/components/plugwise/test_sensor.py index 0c7483c19bd..46f31e1458f 100644 --- a/tests/components/plugwise/test_sensor.py +++ b/tests/components/plugwise/test_sensor.py @@ -2,6 +2,8 @@ from unittest.mock import MagicMock +from homeassistant.components.plugwise.const import DOMAIN +from homeassistant.components.plugwise.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_component import async_update_entity from homeassistant.helpers.entity_registry import async_get @@ -36,6 +38,58 @@ async def test_adam_climate_sensor_entities( assert int(state.state) == 34 +async def test_adam_climate_sensor_entity_2( + hass: HomeAssistant, mock_smile_adam_4: MagicMock, init_integration: MockConfigEntry +) -> None: + """Test creation of climate related sensor entities.""" + state = hass.states.get("sensor.woonkamer_humidity") + assert state + assert float(state.state) == 56.2 + + +async def test_unique_id_migration_humidity( + hass: HomeAssistant, + mock_smile_adam_4: MagicMock, + mock_config_entry: MockConfigEntry, +) -> None: + """Test unique ID migration of -relative_humidity to -humidity.""" + mock_config_entry.add_to_hass(hass) + + entity_registry = async_get(hass) + # Entry to migrate + entity_registry.async_get_or_create( + SENSOR_DOMAIN, + DOMAIN, + "f61f1a2535f54f52ad006a3d18e459ca-relative_humidity", + config_entry=mock_config_entry, + suggested_object_id="woonkamer_humidity", + disabled_by=None, + ) + # Entry not needing migration + entity_registry.async_get_or_create( + SENSOR_DOMAIN, + DOMAIN, + "f61f1a2535f54f52ad006a3d18e459ca-battery", + config_entry=mock_config_entry, + suggested_object_id="woonkamer_battery", + disabled_by=None, + ) + + await hass.config_entries.async_setup(mock_config_entry.entry_id) + await hass.async_block_till_done() + + assert hass.states.get("sensor.woonkamer_humidity") is not None + assert hass.states.get("sensor.woonkamer_battery") is not None + + entity_entry = entity_registry.async_get("sensor.woonkamer_humidity") + assert entity_entry + assert entity_entry.unique_id == "f61f1a2535f54f52ad006a3d18e459ca-humidity" + + entity_entry = entity_registry.async_get("sensor.woonkamer_battery") + assert entity_entry + assert entity_entry.unique_id == "f61f1a2535f54f52ad006a3d18e459ca-battery" + + async def test_anna_as_smt_climate_sensor_entities( hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry ) -> None: @@ -48,10 +102,6 @@ async def test_anna_as_smt_climate_sensor_entities( assert state assert float(state.state) == 29.1 - state = hass.states.get("sensor.opentherm_dhw_setpoint") - assert state - assert float(state.state) == 60.0 - state = hass.states.get("sensor.opentherm_dhw_temperature") assert state assert float(state.state) == 46.3 diff --git a/tests/components/plugwise/test_switch.py b/tests/components/plugwise/test_switch.py index 64519aba0a8..2d47a420fe8 100644 --- a/tests/components/plugwise/test_switch.py +++ b/tests/components/plugwise/test_switch.py @@ -173,7 +173,7 @@ async def test_unique_id_migration_plug_relay( DOMAIN, "675416a629f343c495449970e2ca37b5-relay", config_entry=mock_config_entry, - suggested_object_id="router", + suggested_object_id="ziggo_modem", disabled_by=None, ) @@ -181,12 +181,12 @@ async def test_unique_id_migration_plug_relay( await hass.async_block_till_done() assert hass.states.get("switch.playstation_smart_plug") is not None - assert hass.states.get("switch.router") is not None + assert hass.states.get("switch.ziggo_modem") is not None entity_entry = registry.async_get("switch.playstation_smart_plug") assert entity_entry assert entity_entry.unique_id == "21f2b542c49845e6bb416884c55778d6-relay" - entity_entry = registry.async_get("switch.router") + entity_entry = registry.async_get("switch.ziggo_modem") assert entity_entry assert entity_entry.unique_id == "675416a629f343c495449970e2ca37b5-relay"