Skip to content

Commit

Permalink
Add device HmIP-STE2-PCB to homematicip_cloud (home-assistant#75369)
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-th authored Jul 25, 2022
1 parent e3fb4ce commit f4e7436
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 4 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/homematicip_cloud/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "HomematicIP Cloud",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/homematicip_cloud",
"requirements": ["homematicip==1.0.5"],
"requirements": ["homematicip==1.0.7"],
"codeowners": [],
"quality_scale": "platinum",
"iot_class": "cloud_push",
Expand Down
80 changes: 80 additions & 0 deletions homeassistant/components/homematicip_cloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
AsyncPlugableSwitchMeasuring,
AsyncPresenceDetectorIndoor,
AsyncRoomControlDeviceAnalog,
AsyncTemperatureDifferenceSensor2,
AsyncTemperatureHumiditySensorDisplay,
AsyncTemperatureHumiditySensorOutdoor,
AsyncTemperatureHumiditySensorWithoutDisplay,
Expand Down Expand Up @@ -124,6 +125,10 @@ async def async_setup_entry(
entities.append(HomematicipTodayRainSensor(hap, device))
if isinstance(device, AsyncPassageDetector):
entities.append(HomematicipPassageDetectorDeltaCounter(hap, device))
if isinstance(device, AsyncTemperatureDifferenceSensor2):
entities.append(HomematicpTemperatureExternalSensorCh1(hap, device))
entities.append(HomematicpTemperatureExternalSensorCh2(hap, device))
entities.append(HomematicpTemperatureExternalSensorDelta(hap, device))

if entities:
async_add_entities(entities)
Expand Down Expand Up @@ -387,6 +392,81 @@ def native_unit_of_measurement(self) -> str:
return LENGTH_MILLIMETERS


class HomematicpTemperatureExternalSensorCh1(HomematicipGenericEntity, SensorEntity):
"""Representation of the HomematicIP device HmIP-STE2-PCB."""

_attr_state_class = SensorStateClass.MEASUREMENT

def __init__(self, hap: HomematicipHAP, device) -> None:
"""Initialize the device."""
super().__init__(hap, device, post="Channel 1 Temperature")

@property
def device_class(self) -> str:
"""Return the device class of the sensor."""
return SensorDeviceClass.TEMPERATURE

@property
def native_value(self) -> float:
"""Return the state."""
return self._device.temperatureExternalOne

@property
def native_unit_of_measurement(self) -> str:
"""Return the unit this state is expressed in."""
return TEMP_CELSIUS


class HomematicpTemperatureExternalSensorCh2(HomematicipGenericEntity, SensorEntity):
"""Representation of the HomematicIP device HmIP-STE2-PCB."""

_attr_state_class = SensorStateClass.MEASUREMENT

def __init__(self, hap: HomematicipHAP, device) -> None:
"""Initialize the device."""
super().__init__(hap, device, post="Channel 2 Temperature")

@property
def device_class(self) -> str:
"""Return the device class of the sensor."""
return SensorDeviceClass.TEMPERATURE

@property
def native_value(self) -> float:
"""Return the state."""
return self._device.temperatureExternalTwo

@property
def native_unit_of_measurement(self) -> str:
"""Return the unit this state is expressed in."""
return TEMP_CELSIUS


class HomematicpTemperatureExternalSensorDelta(HomematicipGenericEntity, SensorEntity):
"""Representation of the HomematicIP device HmIP-STE2-PCB."""

_attr_state_class = SensorStateClass.MEASUREMENT

def __init__(self, hap: HomematicipHAP, device) -> None:
"""Initialize the device."""
super().__init__(hap, device, post="Delta Temperature")

@property
def device_class(self) -> str:
"""Return the device class of the sensor."""
return SensorDeviceClass.TEMPERATURE

@property
def native_value(self) -> float:
"""Return the state."""
return self._device.temperatureExternalDelta

@property
def native_unit_of_measurement(self) -> str:
"""Return the unit this state is expressed in."""
return TEMP_CELSIUS


class HomematicipPassageDetectorDeltaCounter(HomematicipGenericEntity, SensorEntity):
"""Representation of the HomematicIP passage detector delta counter."""

Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ home-assistant-frontend==20220707.1
homeconnect==0.7.1

# homeassistant.components.homematicip_cloud
homematicip==1.0.5
homematicip==1.0.7

# homeassistant.components.home_plus_control
homepluscontrol==0.0.5
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ home-assistant-frontend==20220707.1
homeconnect==0.7.1

# homeassistant.components.homematicip_cloud
homematicip==1.0.5
homematicip==1.0.7

# homeassistant.components.home_plus_control
homepluscontrol==0.0.5
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) == 258
assert len(mock_hap.hmip_device_by_entity_id) == 262


async def test_hmip_remove_device(hass, default_mock_hap_factory):
Expand Down
75 changes: 75 additions & 0 deletions tests/components/homematicip_cloud/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,81 @@ async def test_hmip_today_rain_sensor(hass, default_mock_hap_factory):
assert ha_state.state == "14.2"


async def test_hmip_temperature_external_sensor_channel_1(
hass, default_mock_hap_factory
):
"""Test HomematicipTemperatureDifferenceSensor Channel 1 HmIP-STE2-PCB."""
entity_id = "sensor.ste2_channel_1_temperature"
entity_name = "STE2 Channel 1 Temperature"
device_model = "HmIP-STE2-PCB"

mock_hap = await default_mock_hap_factory.async_get_mock_hap(test_devices=["STE2"])
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)

hmip_device = mock_hap.hmip_device_by_entity_id.get(entity_id)

await async_manipulate_test_data(hass, hmip_device, "temperatureExternalOne", 25.4)

ha_state = hass.states.get(entity_id)
assert ha_state.state == "25.4"
assert ha_state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
await async_manipulate_test_data(hass, hmip_device, "temperatureExternalOne", 23.5)
ha_state = hass.states.get(entity_id)
assert ha_state.state == "23.5"


async def test_hmip_temperature_external_sensor_channel_2(
hass, default_mock_hap_factory
):
"""Test HomematicipTemperatureDifferenceSensor Channel 2 HmIP-STE2-PCB."""
entity_id = "sensor.ste2_channel_2_temperature"
entity_name = "STE2 Channel 2 Temperature"
device_model = "HmIP-STE2-PCB"

mock_hap = await default_mock_hap_factory.async_get_mock_hap(test_devices=["STE2"])
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)

hmip_device = mock_hap.hmip_device_by_entity_id.get(entity_id)

await async_manipulate_test_data(hass, hmip_device, "temperatureExternalTwo", 22.4)

ha_state = hass.states.get(entity_id)
assert ha_state.state == "22.4"
assert ha_state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
await async_manipulate_test_data(hass, hmip_device, "temperatureExternalTwo", 23.4)
ha_state = hass.states.get(entity_id)
assert ha_state.state == "23.4"


async def test_hmip_temperature_external_sensor_delta(hass, default_mock_hap_factory):
"""Test HomematicipTemperatureDifferenceSensor Delta HmIP-STE2-PCB."""
entity_id = "sensor.ste2_delta_temperature"
entity_name = "STE2 Delta Temperature"
device_model = "HmIP-STE2-PCB"

mock_hap = await default_mock_hap_factory.async_get_mock_hap(test_devices=["STE2"])
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)

hmip_device = mock_hap.hmip_device_by_entity_id.get(entity_id)

await async_manipulate_test_data(hass, hmip_device, "temperatureExternalDelta", 0.4)

ha_state = hass.states.get(entity_id)
assert ha_state.state == "0.4"
assert ha_state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
await async_manipulate_test_data(
hass, hmip_device, "temperatureExternalDelta", -0.5
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == "-0.5"


async def test_hmip_passage_detector_delta_counter(hass, default_mock_hap_factory):
"""Test HomematicipPassageDetectorDeltaCounter."""
entity_id = "sensor.spdr_1"
Expand Down
94 changes: 94 additions & 0 deletions tests/fixtures/homematicip_cloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -6631,6 +6631,100 @@
"serializedGlobalTradeItemNumber": "3014F7110000000000056775",
"type": "FULL_FLUSH_CONTACT_INTERFACE_6",
"updateState": "UP_TO_DATE"
},
"3014F7110000000000STE2015": {
"availableFirmwareVersion": "1.0.26",
"connectionType": "HMIP_RF",
"firmwareVersion": "1.0.18",
"firmwareVersionInteger": 65554,
"functionalChannels": {
"0": {
"busConfigMismatch": null,
"coProFaulty": false,
"coProRestartNeeded": false,
"coProUpdateFailure": false,
"configPending": false,
"deviceId": "3014F7110000000000STE2015",
"deviceOverheated": false,
"deviceOverloaded": false,
"devicePowerFailureDetected": false,
"deviceUndervoltage": false,
"displayContrast": null,
"dutyCycle": false,
"functionalChannelType": "DEVICE_BASE",
"groupIndex": 0,
"groups": ["00000000-0000-0000-0000-000000000024"],
"index": 0,
"label": "",
"lockJammed": null,
"lowBat": false,
"mountingOrientation": null,
"multicastRoutingEnabled": false,
"particulateMatterSensorCommunicationError": null,
"particulateMatterSensorError": null,
"powerShortCircuit": null,
"profilePeriodLimitReached": null,
"routerModuleEnabled": false,
"routerModuleSupported": false,
"rssiDeviceValue": -60,
"rssiPeerValue": null,
"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": false,
"IOptionalFeatureDutyCycle": true,
"IOptionalFeatureLowBat": true,
"IOptionalFeatureMountingOrientation": false
},
"temperatureHumiditySensorCommunicationError": null,
"temperatureHumiditySensorError": null,
"temperatureOutOfRange": false,
"unreach": false
},
"1": {
"deviceId": "3014F7110000000000STE2015",
"functionalChannelType": "TEMPERATURE_SENSOR_2_EXTERNAL_DELTA_CHANNEL",
"groupIndex": 1,
"groups": ["00000000-0000-0000-0000-000000000025"],
"index": 1,
"label": "",
"temperatureExternalDelta": -0.9,
"temperatureExternalOne": 24.5,
"temperatureExternalTwo": 25.4
}
},
"homeId": "00000000-0000-0000-0000-000000000001",
"id": "3014F7110000000000STE2015",
"label": "STE2",
"lastStatusUpdate": 1645012379988,
"liveUpdateState": "LIVE_UPDATE_NOT_SUPPORTED",
"manufacturerCode": 1,
"modelId": 415,
"modelType": "HmIP-STE2-PCB",
"oem": "eQ-3",
"permanentlyReachable": false,
"serializedGlobalTradeItemNumber": "3014F7110000000000STE2015",
"type": "TEMPERATURE_SENSOR_2_EXTERNAL_DELTA",
"updateState": "TRANSFERING_UPDATE"
}
},
"groups": {
Expand Down

0 comments on commit f4e7436

Please sign in to comment.