mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add absolute humidity sensor to homematicip_cloud (#143709)
* add absolute humidity sensor * drop unused tests; rename test * Fix docstrings
This commit is contained in:
parent
8760a82dfa
commit
1626b3b7c9
@ -46,6 +46,7 @@ from homeassistant.components.sensor import (
|
|||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
@ -127,6 +128,7 @@ async def async_setup_entry(
|
|||||||
):
|
):
|
||||||
entities.append(HomematicipTemperatureSensor(hap, device))
|
entities.append(HomematicipTemperatureSensor(hap, device))
|
||||||
entities.append(HomematicipHumiditySensor(hap, device))
|
entities.append(HomematicipHumiditySensor(hap, device))
|
||||||
|
entities.append(HomematicipAbsoluteHumiditySensor(hap, device))
|
||||||
elif isinstance(device, (RoomControlDeviceAnalog,)):
|
elif isinstance(device, (RoomControlDeviceAnalog,)):
|
||||||
entities.append(HomematicipTemperatureSensor(hap, device))
|
entities.append(HomematicipTemperatureSensor(hap, device))
|
||||||
if isinstance(
|
if isinstance(
|
||||||
@ -348,6 +350,35 @@ class HomematicipTemperatureSensor(HomematicipGenericEntity, SensorEntity):
|
|||||||
return state_attr
|
return state_attr
|
||||||
|
|
||||||
|
|
||||||
|
class HomematicipAbsoluteHumiditySensor(HomematicipGenericEntity, SensorEntity):
|
||||||
|
"""Representation of the HomematicIP absolute humidity sensor."""
|
||||||
|
|
||||||
|
_attr_native_unit_of_measurement = CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER
|
||||||
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
|
|
||||||
|
def __init__(self, hap: HomematicipHAP, device) -> None:
|
||||||
|
"""Initialize the thermometer device."""
|
||||||
|
super().__init__(hap, device, post="Absolute Humidity")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def native_value(self) -> int | None:
|
||||||
|
"""Return the state."""
|
||||||
|
if self.functional_channel is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
value = self.functional_channel.vaporAmount
|
||||||
|
|
||||||
|
# Handle case where value might be None
|
||||||
|
if (
|
||||||
|
self.functional_channel.vaporAmount is None
|
||||||
|
or self.functional_channel.vaporAmount == ""
|
||||||
|
):
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Convert from g/m³ to mg/m³
|
||||||
|
return int(float(value) * 1000)
|
||||||
|
|
||||||
|
|
||||||
class HomematicipIlluminanceSensor(HomematicipGenericEntity, SensorEntity):
|
class HomematicipIlluminanceSensor(HomematicipGenericEntity, SensorEntity):
|
||||||
"""Representation of the HomematicIP Illuminance sensor."""
|
"""Representation of the HomematicIP Illuminance sensor."""
|
||||||
|
|
||||||
|
@ -8296,6 +8296,130 @@
|
|||||||
"serializedGlobalTradeItemNumber": "3014F7110000000000DSDPCB",
|
"serializedGlobalTradeItemNumber": "3014F7110000000000DSDPCB",
|
||||||
"type": "DOOR_BELL_CONTACT_INTERFACE",
|
"type": "DOOR_BELL_CONTACT_INTERFACE",
|
||||||
"updateState": "UP_TO_DATE"
|
"updateState": "UP_TO_DATE"
|
||||||
|
},
|
||||||
|
"3014F71100000000000SVCTH": {
|
||||||
|
"availableFirmwareVersion": "1.0.10",
|
||||||
|
"connectionType": "HMIP_RF",
|
||||||
|
"deviceArchetype": "HMIP",
|
||||||
|
"firmwareVersion": "1.0.10",
|
||||||
|
"firmwareVersionInteger": 65546,
|
||||||
|
"functionalChannels": {
|
||||||
|
"0": {
|
||||||
|
"busConfigMismatch": null,
|
||||||
|
"coProFaulty": false,
|
||||||
|
"coProRestartNeeded": false,
|
||||||
|
"coProUpdateFailure": false,
|
||||||
|
"configPending": false,
|
||||||
|
"controlsMountingOrientation": null,
|
||||||
|
"daliBusState": null,
|
||||||
|
"defaultLinkedGroup": [],
|
||||||
|
"deviceAliveSignalEnabled": null,
|
||||||
|
"deviceCommunicationError": null,
|
||||||
|
"deviceDriveError": null,
|
||||||
|
"deviceDriveModeError": null,
|
||||||
|
"deviceId": "3014F71100000000000SVCTH",
|
||||||
|
"deviceOperationMode": null,
|
||||||
|
"deviceOverheated": false,
|
||||||
|
"deviceOverloaded": false,
|
||||||
|
"devicePowerFailureDetected": false,
|
||||||
|
"deviceUndervoltage": false,
|
||||||
|
"displayContrast": null,
|
||||||
|
"displayMode": null,
|
||||||
|
"displayMountingOrientation": null,
|
||||||
|
"dutyCycle": false,
|
||||||
|
"functionalChannelType": "DEVICE_BASE",
|
||||||
|
"groupIndex": 0,
|
||||||
|
"groups": ["00000000-0000-0000-0000-000000000033"],
|
||||||
|
"index": 0,
|
||||||
|
"invertedDisplayColors": null,
|
||||||
|
"label": "",
|
||||||
|
"lockJammed": null,
|
||||||
|
"lowBat": false,
|
||||||
|
"mountingOrientation": null,
|
||||||
|
"multicastRoutingEnabled": false,
|
||||||
|
"operationDays": null,
|
||||||
|
"particulateMatterSensorCommunicationError": null,
|
||||||
|
"particulateMatterSensorError": null,
|
||||||
|
"powerShortCircuit": null,
|
||||||
|
"profilePeriodLimitReached": null,
|
||||||
|
"routerModuleEnabled": false,
|
||||||
|
"routerModuleSupported": false,
|
||||||
|
"rssiDeviceValue": -84,
|
||||||
|
"rssiPeerValue": null,
|
||||||
|
"sensorCommunicationError": null,
|
||||||
|
"sensorError": null,
|
||||||
|
"shortCircuitDataLine": null,
|
||||||
|
"supportedOptionalFeatures": {
|
||||||
|
"IFeatureBusConfigMismatch": false,
|
||||||
|
"IFeatureDeviceCoProError": false,
|
||||||
|
"IFeatureDeviceCoProRestart": false,
|
||||||
|
"IFeatureDeviceCoProUpdate": false,
|
||||||
|
"IFeatureDeviceCommunicationError": false,
|
||||||
|
"IFeatureDeviceDaliBusError": false,
|
||||||
|
"IFeatureDeviceDriveError": false,
|
||||||
|
"IFeatureDeviceDriveModeError": false,
|
||||||
|
"IFeatureDeviceIdentify": false,
|
||||||
|
"IFeatureDeviceOverheated": false,
|
||||||
|
"IFeatureDeviceOverloaded": false,
|
||||||
|
"IFeatureDeviceParticulateMatterSensorCommunicationError": false,
|
||||||
|
"IFeatureDeviceParticulateMatterSensorError": false,
|
||||||
|
"IFeatureDevicePowerFailure": false,
|
||||||
|
"IFeatureDeviceSensorCommunicationError": false,
|
||||||
|
"IFeatureDeviceSensorError": false,
|
||||||
|
"IFeatureDeviceTemperatureHumiditySensorCommunicationError": false,
|
||||||
|
"IFeatureDeviceTemperatureHumiditySensorError": false,
|
||||||
|
"IFeatureDeviceTemperatureOutOfRange": true,
|
||||||
|
"IFeatureDeviceUndervoltage": false,
|
||||||
|
"IFeatureMulticastRouter": false,
|
||||||
|
"IFeaturePowerShortCircuit": false,
|
||||||
|
"IFeatureProfilePeriodLimit": false,
|
||||||
|
"IFeatureRssiValue": true,
|
||||||
|
"IFeatureShortCircuitDataLine": false,
|
||||||
|
"IOptionalFeatureDefaultLinkedGroup": false,
|
||||||
|
"IOptionalFeatureDeviceAliveSignalEnabled": false,
|
||||||
|
"IOptionalFeatureDeviceErrorLockJammed": false,
|
||||||
|
"IOptionalFeatureDeviceOperationMode": false,
|
||||||
|
"IOptionalFeatureDisplayContrast": false,
|
||||||
|
"IOptionalFeatureDisplayMode": false,
|
||||||
|
"IOptionalFeatureDutyCycle": true,
|
||||||
|
"IOptionalFeatureInvertedDisplayColors": false,
|
||||||
|
"IOptionalFeatureLowBat": true,
|
||||||
|
"IOptionalFeatureMountingOrientation": false,
|
||||||
|
"IOptionalFeatureOperationDays": false
|
||||||
|
},
|
||||||
|
"temperatureHumiditySensorCommunicationError": null,
|
||||||
|
"temperatureHumiditySensorError": null,
|
||||||
|
"temperatureOutOfRange": false,
|
||||||
|
"unreach": false
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"actualTemperature": 19.7,
|
||||||
|
"channelRole": "WEATHER_SENSOR",
|
||||||
|
"deviceId": "3014F71100000000000SVCTH",
|
||||||
|
"functionalChannelType": "CLIMATE_SENSOR_CHANNEL",
|
||||||
|
"groupIndex": 1,
|
||||||
|
"groups": ["00000000-0000-0000-0000-000000000035"],
|
||||||
|
"humidity": 36,
|
||||||
|
"index": 1,
|
||||||
|
"label": "",
|
||||||
|
"vaporAmount": 6.098938251390021
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"homeId": "00000000-0000-0000-0000-000000000001",
|
||||||
|
"id": "3014F71100000000000SVCTH",
|
||||||
|
"label": "elvshctv",
|
||||||
|
"lastStatusUpdate": 1744114372880,
|
||||||
|
"liveUpdateState": "LIVE_UPDATE_NOT_SUPPORTED",
|
||||||
|
"manuallyUpdateForced": false,
|
||||||
|
"manufacturerCode": 9,
|
||||||
|
"measuredAttributes": {},
|
||||||
|
"modelId": 555,
|
||||||
|
"modelType": "ELV-SH-CTH",
|
||||||
|
"oem": "eQ-3",
|
||||||
|
"permanentlyReachable": false,
|
||||||
|
"serializedGlobalTradeItemNumber": "3014F71100000000000SVCTH",
|
||||||
|
"type": "TEMPERATURE_HUMIDITY_SENSOR_COMPACT",
|
||||||
|
"updateState": "UP_TO_DATE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"groups": {
|
"groups": {
|
||||||
|
@ -28,7 +28,7 @@ async def test_hmip_load_all_supported_devices(
|
|||||||
test_devices=None, test_groups=None
|
test_devices=None, test_groups=None
|
||||||
)
|
)
|
||||||
|
|
||||||
assert len(mock_hap.hmip_device_by_entity_id) == 310
|
assert len(mock_hap.hmip_device_by_entity_id) == 325
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_remove_device(
|
async def test_hmip_remove_device(
|
||||||
|
@ -720,3 +720,42 @@ async def test_hmip_esi_led_energy_counter_usage_high_tariff(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert ha_state.state == "23825.748"
|
assert ha_state.state == "23825.748"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_hmip_absolute_humidity_sensor(
|
||||||
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
|
) -> None:
|
||||||
|
"""Test absolute humidity sensor (vaporAmount)."""
|
||||||
|
entity_id = "sensor.elvshctv_absolute_humidity"
|
||||||
|
entity_name = "elvshctv Absolute Humidity"
|
||||||
|
device_model = "ELV-SH-CTH"
|
||||||
|
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
|
||||||
|
test_devices=["elvshctv"]
|
||||||
|
)
|
||||||
|
|
||||||
|
ha_state, hmip_device = get_and_check_entity_basics(
|
||||||
|
hass, mock_hap, entity_id, entity_name, device_model
|
||||||
|
)
|
||||||
|
|
||||||
|
assert ha_state.state == "6098"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_hmip_absolute_humidity_sensor_invalid_value(
|
||||||
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
|
) -> None:
|
||||||
|
"""Test absolute humidity sensor with invalid value for vaporAmount."""
|
||||||
|
entity_id = "sensor.elvshctv_absolute_humidity"
|
||||||
|
entity_name = "elvshctv Absolute Humidity"
|
||||||
|
device_model = "ELV-SH-CTH"
|
||||||
|
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
|
||||||
|
test_devices=["elvshctv"]
|
||||||
|
)
|
||||||
|
|
||||||
|
ha_state, hmip_device = get_and_check_entity_basics(
|
||||||
|
hass, mock_hap, entity_id, entity_name, device_model
|
||||||
|
)
|
||||||
|
|
||||||
|
await async_manipulate_test_data(hass, hmip_device, "vaporAmount", None, 1)
|
||||||
|
ha_state = hass.states.get(entity_id)
|
||||||
|
|
||||||
|
assert ha_state.state == STATE_UNKNOWN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user