mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Add distance and height sensors for the HomematicIP ELV-SH-DUSI (#185701)
Co-authored-by: Joostlek <joostlek@outlook.com>
This commit is contained in:
co-authored by
Joostlek
parent
29fde5807e
commit
6481e267c5
@@ -35,6 +35,7 @@ from homematicip.device import (
|
||||
TemperatureHumiditySensorOutdoor,
|
||||
TemperatureHumiditySensorWithoutDisplay,
|
||||
TiltVibrationSensor,
|
||||
UltrasonicDistanceSensor,
|
||||
WateringActuator,
|
||||
WeatherSensor,
|
||||
WeatherSensorPlus,
|
||||
@@ -53,6 +54,7 @@ from homeassistant.const import (
|
||||
LIGHT_LUX,
|
||||
UnitOfDensity,
|
||||
UnitOfEnergy,
|
||||
UnitOfLength,
|
||||
UnitOfPower,
|
||||
UnitOfPrecipitationDepth,
|
||||
UnitOfRatio,
|
||||
@@ -415,6 +417,25 @@ TILT_TEMPERATURE_DESC = HmipSensorDescription[Device](
|
||||
channel_type=FunctionalChannelType.TEMPERATURE_SENSOR_CHANNEL,
|
||||
)
|
||||
|
||||
DISTANCE_DESC = HmipSensorDescription[Device](
|
||||
key="distance",
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
native_unit_of_measurement=UnitOfLength.CENTIMETERS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda d: d.distance,
|
||||
channel=1,
|
||||
)
|
||||
|
||||
HEIGHT_DESC = HmipSensorDescription[Device](
|
||||
key="height",
|
||||
translation_key="height",
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
native_unit_of_measurement=UnitOfLength.CENTIMETERS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda d: d.calculatedHeight,
|
||||
channel=1,
|
||||
)
|
||||
|
||||
|
||||
# Keys must not subclass each other so each device matches one key; the setup
|
||||
# loop breaks after the first match (enforced by
|
||||
@@ -454,6 +475,7 @@ SENSOR_DESCRIPTIONS_BY_DEVICE: dict[
|
||||
TEMPERATURE_EXTERNAL_DELTA_DESC,
|
||||
),
|
||||
TiltVibrationSensor: (TILT_ANGLE_DESC, TILT_TEMPERATURE_DESC),
|
||||
UltrasonicDistanceSensor: (DISTANCE_DESC, HEIGHT_DESC),
|
||||
WeatherSensor: (
|
||||
TEMPERATURE_DESC,
|
||||
HUMIDITY_DESC,
|
||||
|
||||
@@ -94,6 +94,9 @@
|
||||
"heating": {
|
||||
"name": "Heating"
|
||||
},
|
||||
"height": {
|
||||
"name": "Height"
|
||||
},
|
||||
"smoke_detector_alarm_counter": {
|
||||
"name": "Alarm counter"
|
||||
},
|
||||
|
||||
@@ -9599,6 +9599,122 @@
|
||||
"type": "WALL_MOUNTED_UNIVERSAL_ACTUATOR",
|
||||
"updateState": "UP_TO_DATE"
|
||||
},
|
||||
"3014F711000000000000DUSI": {
|
||||
"availableFirmwareVersion": "1.0.22",
|
||||
"connectionType": "HMIP_RF",
|
||||
"deviceArchetype": "HMIP",
|
||||
"firmwareVersion": "1.0.22",
|
||||
"firmwareVersionInteger": 65558,
|
||||
"functionalChannels": {
|
||||
"0": {
|
||||
"altitude": null,
|
||||
"bootedRecently": false,
|
||||
"busConfigMismatch": null,
|
||||
"coProFaulty": false,
|
||||
"coProRestartNeeded": false,
|
||||
"coProUpdateFailure": false,
|
||||
"configPending": false,
|
||||
"controlsMountingOrientation": null,
|
||||
"daliBusState": null,
|
||||
"dataDecodingFailedError": null,
|
||||
"defaultLinkedGroup": [],
|
||||
"deviceAliveSignalEnabled": null,
|
||||
"deviceCanBusError": null,
|
||||
"deviceCommunicationError": null,
|
||||
"deviceDriveError": null,
|
||||
"deviceDriveModeError": null,
|
||||
"deviceId": "3014F711000000000000DUSI",
|
||||
"deviceOperationMode": null,
|
||||
"deviceOverheated": false,
|
||||
"deviceOverloaded": false,
|
||||
"devicePowerFailureDetected": false,
|
||||
"deviceUndervoltage": false,
|
||||
"displayContrast": null,
|
||||
"displayMode": null,
|
||||
"displayMountingOrientation": null,
|
||||
"dutyCycle": false,
|
||||
"fanControlMode": null,
|
||||
"frostProtectionError": null,
|
||||
"frostProtectionErrorAcknowledged": null,
|
||||
"functionalChannelType": "DEVICE_BASE",
|
||||
"groupIndex": 0,
|
||||
"groups": [],
|
||||
"index": 0,
|
||||
"input1CoproEnabled": null,
|
||||
"input2CoproEnabled": null,
|
||||
"input3CoproEnabled": null,
|
||||
"input4CoproEnabled": null,
|
||||
"inputLayoutMode": null,
|
||||
"invertedDisplayColors": null,
|
||||
"label": "",
|
||||
"lastBootTimestamp": 1788192156339,
|
||||
"lockJammed": null,
|
||||
"lowBat": false,
|
||||
"mountingModuleError": null,
|
||||
"mountingOrientation": null,
|
||||
"multicastRoutingEnabled": false,
|
||||
"noDataFromLinkyError": null,
|
||||
"notRechargeableBattery": null,
|
||||
"operationDays": null,
|
||||
"particulateMatterSensorCommunicationError": null,
|
||||
"particulateMatterSensorError": null,
|
||||
"powerShortCircuit": null,
|
||||
"profilePeriodLimitReached": null,
|
||||
"routerModuleEnabled": false,
|
||||
"routerModuleSupported": false,
|
||||
"rssiDeviceValue": -65,
|
||||
"rssiPeerValue": null,
|
||||
"sensorCommunicationError": null,
|
||||
"sensorError": false,
|
||||
"shortCircuitDataLine": null,
|
||||
"supportedOptionalFeatures": {
|
||||
"IFeatureDeviceSensorError": true,
|
||||
"IFeatureRssiValue": true,
|
||||
"IOptionalFeatureDutyCycle": true,
|
||||
"IOptionalFeatureLowBat": true
|
||||
},
|
||||
"switchChannelMode": null,
|
||||
"temperatureHumiditySensorCommunicationError": null,
|
||||
"temperatureHumiditySensorError": null,
|
||||
"temperatureOutOfRange": false,
|
||||
"ticVersionError": null,
|
||||
"unreach": false,
|
||||
"valveFlowError": null,
|
||||
"valveWaterError": null
|
||||
},
|
||||
"1": {
|
||||
"calculatedHeight": 619.2,
|
||||
"channelRole": "GENERIC_SENSOR",
|
||||
"deviceId": "3014F711000000000000DUSI",
|
||||
"distance": 30.8,
|
||||
"distanceSensorVoltage": "SENSOR_VOLTAGE_3_3",
|
||||
"functionalChannelType": "DISTANCE_SENSOR_CHANNEL",
|
||||
"groupIndex": 1,
|
||||
"groups": [],
|
||||
"heightActivated": false,
|
||||
"index": 1,
|
||||
"label": "",
|
||||
"measuringInterval": 30,
|
||||
"referenceHeight": 650.0,
|
||||
"supportedOptionalFeatures": {}
|
||||
}
|
||||
},
|
||||
"homeId": "00000000-0000-0000-0000-000000000001",
|
||||
"id": "3014F711000000000000DUSI",
|
||||
"label": "Zisterne",
|
||||
"lastStatusUpdate": 1788289759179,
|
||||
"liveUpdateState": "LIVE_UPDATE_NOT_SUPPORTED",
|
||||
"manuallyUpdateForced": false,
|
||||
"manufacturerCode": 9,
|
||||
"measuredAttributes": {},
|
||||
"modelId": 639,
|
||||
"modelType": "ELV-SH-DUSI",
|
||||
"oem": "eQ-3",
|
||||
"permanentlyReachable": false,
|
||||
"serializedGlobalTradeItemNumber": "3014F711000000000000DUSI",
|
||||
"type": "ULTRASONIC_DISTANCE_SENSOR",
|
||||
"updateState": "UP_TO_DATE"
|
||||
},
|
||||
"3014F71100000000000DRBL4": {
|
||||
"availableFirmwareVersion": "1.8.2",
|
||||
"connectionType": "HMIP_WIRED",
|
||||
|
||||
@@ -24,7 +24,7 @@ async def test_hmip_load_all_supported_devices(
|
||||
test_devices=None, test_groups=None
|
||||
)
|
||||
|
||||
assert len(mock_hap.hmip_device_by_entity_id) == 396
|
||||
assert len(mock_hap.hmip_device_by_entity_id) == 399
|
||||
|
||||
|
||||
async def test_hmip_remove_device(
|
||||
|
||||
@@ -28,8 +28,13 @@ from homeassistant.components.homematicip_cloud.sensor import (
|
||||
ATTR_WIND_DIRECTION_VARIATION,
|
||||
SENSOR_DESCRIPTIONS_BY_DEVICE,
|
||||
)
|
||||
from homeassistant.components.sensor import ATTR_STATE_CLASS, SensorStateClass
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_STATE_CLASS,
|
||||
SensorDeviceClass,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
@@ -1126,6 +1131,47 @@ async def test_hmip_soil_temperature_sensor(
|
||||
assert ha_state.state == "18.3"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id", "entity_name", "attribute", "value", "new_value"),
|
||||
[
|
||||
("sensor.zisterne_distance", "Zisterne Distance", "distance", "30.8", 39.4),
|
||||
(
|
||||
"sensor.zisterne_height",
|
||||
"Zisterne Height",
|
||||
"calculatedHeight",
|
||||
"619.2",
|
||||
610.6,
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_hmip_ultrasonic_distance_sensor(
|
||||
hass: HomeAssistant,
|
||||
default_mock_hap_factory: HomeFactory,
|
||||
entity_id: str,
|
||||
entity_name: str,
|
||||
attribute: str,
|
||||
value: str,
|
||||
new_value: float,
|
||||
) -> None:
|
||||
"""Test the ELV-SH-DUSI distance and height sensors."""
|
||||
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
|
||||
test_devices=["Zisterne"]
|
||||
)
|
||||
|
||||
ha_state, hmip_device = get_and_check_entity_basics(
|
||||
hass, mock_hap, entity_id, entity_name, "ELV-SH-DUSI"
|
||||
)
|
||||
|
||||
assert ha_state.state == value
|
||||
assert ha_state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfLength.CENTIMETERS
|
||||
assert ha_state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT
|
||||
assert ha_state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.DISTANCE
|
||||
|
||||
await async_manipulate_test_data(hass, hmip_device, attribute, new_value)
|
||||
ha_state = hass.states.get(entity_id)
|
||||
assert ha_state.state == str(new_value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("device_data_fixture", "device_label", "entity_id", "device_model", "channel"),
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user