Skip to content

Commit

Permalink
Add support for HmIP-eTRV-E to homematicip_cloud (#82876)
Browse files Browse the repository at this point in the history
* Add device HmIP-eTRV-E

* Fix test
  • Loading branch information
hahn-th committed Nov 29, 2022
1 parent 987c7a2 commit 9f8dea1
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 5 deletions.
15 changes: 12 additions & 3 deletions homeassistant/components/homematicip_cloud/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

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
Expand Down Expand Up @@ -312,11 +316,16 @@ def _has_radiator_thermostat(self) -> bool:
@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

Expand Down
10 changes: 9 additions & 1 deletion homeassistant/components/homematicip_cloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
AsyncFullFlushSwitchMeasuring,
AsyncHeatingThermostat,
AsyncHeatingThermostatCompact,
AsyncHeatingThermostatEvo,
AsyncHomeControlAccessPoint,
AsyncLightSensor,
AsyncMotionDetectorIndoor,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/components/homematicip_cloud/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
44 changes: 44 additions & 0 deletions tests/components/homematicip_cloud/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
98 changes: 98 additions & 0 deletions tests/fixtures/homematicip_cloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9f8dea1

Please sign in to comment.