From 9f8dea10f78e7c4ae232a15bc3160a8f65c5e205 Mon Sep 17 00:00:00 2001 From: hahn-th Date: Tue, 29 Nov 2022 11:13:53 +0100 Subject: [PATCH] Add support for HmIP-eTRV-E to homematicip_cloud (#82876) * Add device HmIP-eTRV-E * Fix test --- .../components/homematicip_cloud/climate.py | 15 ++- .../components/homematicip_cloud/sensor.py | 10 +- .../homematicip_cloud/test_device.py | 2 +- .../homematicip_cloud/test_sensor.py | 44 +++++++++ tests/fixtures/homematicip_cloud.json | 98 +++++++++++++++++++ 5 files changed, 164 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/homematicip_cloud/climate.py b/homeassistant/components/homematicip_cloud/climate.py index 2fc9f8fd12d..b6ac23b5c71 100644 --- a/homeassistant/components/homematicip_cloud/climate.py +++ b/homeassistant/components/homematicip_cloud/climate.py @@ -3,7 +3,11 @@ from __future__ import annotations from typing import Any -from homematicip.aio.device import AsyncHeatingThermostat, AsyncHeatingThermostatCompact +from homematicip.aio.device import ( + AsyncHeatingThermostat, + AsyncHeatingThermostatCompact, + AsyncHeatingThermostatEvo, +) from homematicip.aio.group import AsyncHeatingGroup from homematicip.base.enums import AbsenceType from homematicip.device import Switch @@ -312,11 +316,16 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity): @property def _first_radiator_thermostat( self, - ) -> AsyncHeatingThermostat | AsyncHeatingThermostatCompact | None: + ) -> AsyncHeatingThermostat | AsyncHeatingThermostatCompact | AsyncHeatingThermostatEvo | None: """Return the first radiator thermostat from the hmip heating group.""" for device in self._device.devices: if isinstance( - device, (AsyncHeatingThermostat, AsyncHeatingThermostatCompact) + device, + ( + AsyncHeatingThermostat, + AsyncHeatingThermostatCompact, + AsyncHeatingThermostatEvo, + ), ): return device diff --git a/homeassistant/components/homematicip_cloud/sensor.py b/homeassistant/components/homematicip_cloud/sensor.py index 03aaa7626b7..9da0bb37ed4 100644 --- a/homeassistant/components/homematicip_cloud/sensor.py +++ b/homeassistant/components/homematicip_cloud/sensor.py @@ -8,6 +8,7 @@ from homematicip.aio.device import ( AsyncFullFlushSwitchMeasuring, AsyncHeatingThermostat, AsyncHeatingThermostatCompact, + AsyncHeatingThermostatEvo, AsyncHomeControlAccessPoint, AsyncLightSensor, AsyncMotionDetectorIndoor, @@ -75,7 +76,14 @@ async def async_setup_entry( for device in hap.home.devices: if isinstance(device, AsyncHomeControlAccessPoint): entities.append(HomematicipAccesspointDutyCycle(hap, device)) - if isinstance(device, (AsyncHeatingThermostat, AsyncHeatingThermostatCompact)): + if isinstance( + device, + ( + AsyncHeatingThermostat, + AsyncHeatingThermostatCompact, + AsyncHeatingThermostatEvo, + ), + ): entities.append(HomematicipHeatingThermostat(hap, device)) entities.append(HomematicipTemperatureSensor(hap, device)) if isinstance( diff --git a/tests/components/homematicip_cloud/test_device.py b/tests/components/homematicip_cloud/test_device.py index 52b92fdff9a..327f53f129c 100644 --- a/tests/components/homematicip_cloud/test_device.py +++ b/tests/components/homematicip_cloud/test_device.py @@ -22,7 +22,7 @@ async def test_hmip_load_all_supported_devices(hass, default_mock_hap_factory): test_devices=None, test_groups=None ) - assert len(mock_hap.hmip_device_by_entity_id) == 264 + assert len(mock_hap.hmip_device_by_entity_id) == 267 async def test_hmip_remove_device(hass, default_mock_hap_factory): diff --git a/tests/components/homematicip_cloud/test_sensor.py b/tests/components/homematicip_cloud/test_sensor.py index 823508d5fee..33da0f217ae 100644 --- a/tests/components/homematicip_cloud/test_sensor.py +++ b/tests/components/homematicip_cloud/test_sensor.py @@ -193,6 +193,50 @@ async def test_hmip_temperature_sensor3(hass, default_mock_hap_factory): assert ha_state.attributes[ATTR_TEMPERATURE_OFFSET] == 10 +async def test_hmip_thermostat_evo_heating(hass, default_mock_hap_factory): + """Test HomematicipHeatingThermostat for HmIP-eTRV-E.""" + entity_id = "sensor.thermostat_evo_heating" + entity_name = "thermostat_evo Heating" + device_model = "HmIP-eTRV-E" + mock_hap = await default_mock_hap_factory.async_get_mock_hap( + test_devices=["thermostat_evo"] + ) + + ha_state, hmip_device = get_and_check_entity_basics( + hass, mock_hap, entity_id, entity_name, device_model + ) + + assert ha_state.state == "33" + await async_manipulate_test_data(hass, hmip_device, "valvePosition", 0.4) + ha_state = hass.states.get(entity_id) + assert ha_state.attributes[ATTR_UNIT_OF_MEASUREMENT] == PERCENTAGE + assert ha_state.state == "40" + + +async def test_hmip_thermostat_evo_temperature(hass, default_mock_hap_factory): + """Test HomematicipTemperatureSensor.""" + entity_id = "sensor.thermostat_evo_temperature" + entity_name = "thermostat_evo Temperature" + device_model = "HmIP-eTRV-E" + mock_hap = await default_mock_hap_factory.async_get_mock_hap( + test_devices=["thermostat_evo"] + ) + + ha_state, hmip_device = get_and_check_entity_basics( + hass, mock_hap, entity_id, entity_name, device_model + ) + + assert ha_state.state == "18.7" + assert ha_state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS + await async_manipulate_test_data(hass, hmip_device, "valveActualTemperature", 23.5) + ha_state = hass.states.get(entity_id) + assert ha_state.state == "23.5" + + await async_manipulate_test_data(hass, hmip_device, "temperatureOffset", 0.7) + ha_state = hass.states.get(entity_id) + assert ha_state.attributes[ATTR_TEMPERATURE_OFFSET] == 0.7 + + async def test_hmip_power_sensor(hass, default_mock_hap_factory): """Test HomematicipPowerSensor.""" entity_id = "sensor.flur_oben_power" diff --git a/tests/fixtures/homematicip_cloud.json b/tests/fixtures/homematicip_cloud.json index 1ca05d29af6..3e3536a2f42 100644 --- a/tests/fixtures/homematicip_cloud.json +++ b/tests/fixtures/homematicip_cloud.json @@ -2736,6 +2736,104 @@ "type": "HEATING_THERMOSTAT_COMPACT", "updateState": "UP_TO_DATE" }, + "3014F7110000000000000E70": { + "automaticValveAdaptionNeeded": false, + "availableFirmwareVersion": "1.0.10", + "connectionType": "HMIP_RF", + "firmwareVersion": "1.0.10", + "firmwareVersionInteger": 65546, + "functionalChannels": { + "0": { + "busConfigMismatch": null, + "coProFaulty": false, + "coProRestartNeeded": false, + "coProUpdateFailure": false, + "configPending": false, + "deviceId": "3014F7110000000000000E70", + "deviceOverheated": false, + "deviceOverloaded": false, + "devicePowerFailureDetected": false, + "deviceUndervoltage": false, + "displayContrast": 5, + "dutyCycle": false, + "functionalChannelType": "DEVICE_OPERATIONLOCK", + "groupIndex": 0, + "groups": ["00000000-0000-0000-0000-000000000012"], + "index": 0, + "label": "", + "lockJammed": null, + "lowBat": false, + "mountingOrientation": "RIGHT", + "multicastRoutingEnabled": false, + "operationLockActive": false, + "particulateMatterSensorCommunicationError": null, + "particulateMatterSensorError": null, + "powerShortCircuit": null, + "profilePeriodLimitReached": null, + "routerModuleEnabled": false, + "routerModuleSupported": false, + "rssiDeviceValue": -64, + "rssiPeerValue": -67, + "shortCircuitDataLine": null, + "supportedOptionalFeatures": { + "IFeatureBusConfigMismatch": false, + "IFeatureDeviceCoProError": false, + "IFeatureDeviceCoProRestart": false, + "IFeatureDeviceCoProUpdate": false, + "IFeatureDeviceIdentify": false, + "IFeatureDeviceOverheated": false, + "IFeatureDeviceOverloaded": false, + "IFeatureDeviceParticulateMatterSensorCommunicationError": false, + "IFeatureDeviceParticulateMatterSensorError": false, + "IFeatureDevicePowerFailure": false, + "IFeatureDeviceTemperatureHumiditySensorCommunicationError": false, + "IFeatureDeviceTemperatureHumiditySensorError": false, + "IFeatureDeviceTemperatureOutOfRange": false, + "IFeatureDeviceUndervoltage": false, + "IFeatureMulticastRouter": false, + "IFeaturePowerShortCircuit": false, + "IFeatureProfilePeriodLimit": false, + "IFeatureRssiValue": true, + "IFeatureShortCircuitDataLine": false, + "IOptionalFeatureDeviceErrorLockJammed": false, + "IOptionalFeatureDisplayContrast": true, + "IOptionalFeatureDutyCycle": true, + "IOptionalFeatureLowBat": true, + "IOptionalFeatureMountingOrientation": true + }, + "temperatureHumiditySensorCommunicationError": null, + "temperatureHumiditySensorError": null, + "temperatureOutOfRange": false, + "unreach": false + }, + "1": { + "deviceId": "3014F7110000000000000E70", + "functionalChannelType": "HEATING_THERMOSTAT_CHANNEL", + "groupIndex": 1, + "groups": ["00000000-0000-0000-0000-000000000013"], + "index": 1, + "label": "", + "setPointTemperature": 19.0, + "temperatureOffset": 0.5, + "valveActualTemperature": 18.7, + "valvePosition": 0.33, + "valveState": "ADAPTION_DONE" + } + }, + "homeId": "00000000-0000-0000-0000-000000000001", + "id": "3014F7110000000000000E70", + "label": "thermostat_evo", + "lastStatusUpdate": 1644406143910, + "liveUpdateState": "LIVE_UPDATE_NOT_SUPPORTED", + "manufacturerCode": 1, + "modelId": 425, + "modelType": "HmIP-eTRV-E", + "oem": "eQ-3", + "permanentlyReachable": true, + "serializedGlobalTradeItemNumber": "3014F7110000000000000E70", + "type": "HEATING_THERMOSTAT_EVO", + "updateState": "UP_TO_DATE" + }, "3014F71100000000000TEST1": { "availableFirmwareVersion": "0.0.0", "connectionType": "HMIP_RF",