diff --git a/homeassistant/components/smartthings/sensor.py b/homeassistant/components/smartthings/sensor.py index e5fe6ef1fd6..6c8c78b4d32 100644 --- a/homeassistant/components/smartthings/sensor.py +++ b/homeassistant/components/smartthings/sensor.py @@ -26,6 +26,7 @@ from homeassistant.const import ( UnitOfEnergy, UnitOfMass, UnitOfPower, + UnitOfPressure, UnitOfTemperature, UnitOfVolume, ) @@ -200,6 +201,15 @@ CAPABILITY_TO_SENSORS: dict[ ) ] }, + Capability.ATMOSPHERIC_PRESSURE_MEASUREMENT: { + Attribute.ATMOSPHERIC_PRESSURE: [ + SmartThingsSensorEntityDescription( + key=Attribute.ATMOSPHERIC_PRESSURE, + device_class=SensorDeviceClass.ATMOSPHERIC_PRESSURE, + state_class=SensorStateClass.MEASUREMENT, + ) + ] + }, Capability.AUDIO_VOLUME: { Attribute.VOLUME: [ SmartThingsSensorEntityDescription( @@ -1071,6 +1081,7 @@ UNITS = { "lux": LIGHT_LUX, "mG": None, "μg/m^3": CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, + "kPa": UnitOfPressure.KPA, } diff --git a/tests/components/smartthings/conftest.py b/tests/components/smartthings/conftest.py index 7a2945d4c02..ab6c6031d5e 100644 --- a/tests/components/smartthings/conftest.py +++ b/tests/components/smartthings/conftest.py @@ -160,6 +160,7 @@ def mock_smartthings() -> Generator[AsyncMock]: "aux_ac", "hw_q80r_soundbar", "gas_meter", + "lumi", ] ) def device_fixture( diff --git a/tests/components/smartthings/fixtures/device_status/lumi.json b/tests/components/smartthings/fixtures/device_status/lumi.json new file mode 100644 index 00000000000..dc01671f4d9 --- /dev/null +++ b/tests/components/smartthings/fixtures/device_status/lumi.json @@ -0,0 +1,56 @@ +{ + "components": { + "main": { + "configuration": {}, + "relativeHumidityMeasurement": { + "humidity": { + "value": 27.24, + "unit": "%", + "timestamp": "2025-05-11T23:31:11.979Z" + } + }, + "temperatureMeasurement": { + "temperatureRange": { + "value": { + "minimum": -58.0, + "maximum": 482.0 + }, + "unit": "F", + "timestamp": "2025-05-07T14:34:47.868Z" + }, + "temperature": { + "value": 76.0, + "unit": "F", + "timestamp": "2025-05-11T23:31:11.904Z" + } + }, + "atmosphericPressureMeasurement": { + "atmosphericPressure": { + "value": 100, + "unit": "kPa", + "timestamp": "2025-05-11T23:31:11.979Z" + } + }, + "battery": { + "quantity": { + "value": null + }, + "battery": { + "value": 100, + "unit": "%", + "timestamp": "2025-05-11T23:11:16.463Z" + }, + "type": { + "value": null + } + }, + "legendabsolute60149.atmosPressure": { + "atmosPressure": { + "value": 1004, + "unit": "mBar", + "timestamp": "2025-05-11T23:31:11.979Z" + } + } + } + } +} diff --git a/tests/components/smartthings/fixtures/devices/lumi.json b/tests/components/smartthings/fixtures/devices/lumi.json new file mode 100644 index 00000000000..2a5b90adfa1 --- /dev/null +++ b/tests/components/smartthings/fixtures/devices/lumi.json @@ -0,0 +1,75 @@ +{ + "items": [ + { + "deviceId": "692ea4e9-2022-4ed8-8a57-1b884a59cc38", + "name": "temp-humid-press-therm-battery-05", + "label": "Outdoor Temp", + "manufacturerName": "SmartThingsCommunity", + "presentationId": "cea6ca21-a702-3c43-8fe5-a7872c7a963f", + "deviceManufacturerCode": "LUMI", + "locationId": "96fe7a00-c7f6-440a-940e-77aa81a9af4b", + "ownerId": "eabfbf0b-ba3f-40f5-8dcb-8aaba788f8e3", + "roomId": "1eca2d6d-d15d-4f0e-9e32-8709acb9b3fe", + "components": [ + { + "id": "main", + "label": "main", + "capabilities": [ + { + "id": "temperatureMeasurement", + "version": 1 + }, + { + "id": "atmosphericPressureMeasurement", + "version": 1 + }, + { + "id": "legendabsolute60149.atmosPressure", + "version": 1 + }, + { + "id": "relativeHumidityMeasurement", + "version": 1 + }, + { + "id": "configuration", + "version": 1 + }, + { + "id": "battery", + "version": 1 + } + ], + "categories": [ + { + "name": "Thermostat", + "categoryType": "manufacturer" + } + ], + "optional": false + } + ], + "createTime": "2024-06-12T21:27:55.959Z", + "parentDeviceId": "61f28b8c-b975-415a-9197-fbc4e441e77a", + "profile": { + "id": "fa7886ec-6139-3357-8f4a-07a66491c173" + }, + "zigbee": { + "eui": "00158D000967924A", + "networkId": "4B01", + "driverId": "c09c02d7-d05d-4bf4-831b-207a1adeae2f", + "executingLocally": true, + "hubId": "61f28b8c-b975-415a-9197-fbc4e441e77a", + "provisioningState": "NONFUNCTIONAL", + "fingerprintType": "ZIGBEE_MANUFACTURER", + "fingerprintId": "lumi.weather" + }, + "type": "ZIGBEE", + "restrictionTier": 0, + "allowed": null, + "executionContext": "LOCAL", + "relationships": [] + } + ], + "_links": {} +} diff --git a/tests/components/smartthings/snapshots/test_init.ambr b/tests/components/smartthings/snapshots/test_init.ambr index e96615f3120..58b89099b11 100644 --- a/tests/components/smartthings/snapshots/test_init.ambr +++ b/tests/components/smartthings/snapshots/test_init.ambr @@ -1685,6 +1685,39 @@ 'via_device_id': None, }) # --- +# name: test_devices[lumi] + DeviceRegistryEntrySnapshot({ + 'area_id': None, + 'config_entries': , + 'config_entries_subentries': , + 'configuration_url': 'https://account.smartthings.com', + 'connections': set({ + }), + 'disabled_by': None, + 'entry_type': None, + 'hw_version': None, + 'id': , + 'identifiers': set({ + tuple( + 'smartthings', + '692ea4e9-2022-4ed8-8a57-1b884a59cc38', + ), + }), + 'is_new': False, + 'labels': set({ + }), + 'manufacturer': None, + 'model': None, + 'model_id': None, + 'name': 'Outdoor Temp', + 'name_by_user': None, + 'primary_config_entry': , + 'serial_number': None, + 'suggested_area': None, + 'sw_version': None, + 'via_device_id': None, + }) +# --- # name: test_devices[multipurpose_sensor] DeviceRegistryEntrySnapshot({ 'area_id': 'theater', diff --git a/tests/components/smartthings/snapshots/test_sensor.ambr b/tests/components/smartthings/snapshots/test_sensor.ambr index 26805a83799..2884ded50af 100644 --- a/tests/components/smartthings/snapshots/test_sensor.ambr +++ b/tests/components/smartthings/snapshots/test_sensor.ambr @@ -10877,6 +10877,214 @@ 'state': '37', }) # --- +# name: test_all_entities[lumi][sensor.outdoor_temp_atmospheric_pressure-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.outdoor_temp_atmospheric_pressure', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Atmospheric pressure', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '692ea4e9-2022-4ed8-8a57-1b884a59cc38_main_atmosphericPressureMeasurement_atmosphericPressure_atmosphericPressure', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities[lumi][sensor.outdoor_temp_atmospheric_pressure-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'atmospheric_pressure', + 'friendly_name': 'Outdoor Temp Atmospheric pressure', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.outdoor_temp_atmospheric_pressure', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1000', + }) +# --- +# name: test_all_entities[lumi][sensor.outdoor_temp_battery-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.outdoor_temp_battery', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Battery', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '692ea4e9-2022-4ed8-8a57-1b884a59cc38_main_battery_battery_battery', + 'unit_of_measurement': '%', + }) +# --- +# name: test_all_entities[lumi][sensor.outdoor_temp_battery-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'battery', + 'friendly_name': 'Outdoor Temp Battery', + 'unit_of_measurement': '%', + }), + 'context': , + 'entity_id': 'sensor.outdoor_temp_battery', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '100', + }) +# --- +# name: test_all_entities[lumi][sensor.outdoor_temp_humidity-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.outdoor_temp_humidity', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Humidity', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '692ea4e9-2022-4ed8-8a57-1b884a59cc38_main_relativeHumidityMeasurement_humidity_humidity', + 'unit_of_measurement': '%', + }) +# --- +# name: test_all_entities[lumi][sensor.outdoor_temp_humidity-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'humidity', + 'friendly_name': 'Outdoor Temp Humidity', + 'state_class': , + 'unit_of_measurement': '%', + }), + 'context': , + 'entity_id': 'sensor.outdoor_temp_humidity', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '27.24', + }) +# --- +# name: test_all_entities[lumi][sensor.outdoor_temp_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.outdoor_temp_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Temperature', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '692ea4e9-2022-4ed8-8a57-1b884a59cc38_main_temperatureMeasurement_temperature_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities[lumi][sensor.outdoor_temp_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Outdoor Temp Temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.outdoor_temp_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '24.4', + }) +# --- # name: test_all_entities[multipurpose_sensor][sensor.deck_door_battery-entry] EntityRegistryEntrySnapshot({ 'aliases': set({