mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix SmartThings gas meter (#142741)
This commit is contained in:
parent
5816a24577
commit
7b78f6db17
@ -413,7 +413,6 @@ CAPABILITY_TO_SENSORS: dict[
|
||||
)
|
||||
]
|
||||
},
|
||||
# Haven't seen at devices yet
|
||||
Capability.GAS_METER: {
|
||||
Attribute.GAS_METER: [
|
||||
SmartThingsSensorEntityDescription(
|
||||
@ -421,7 +420,7 @@ CAPABILITY_TO_SENSORS: dict[
|
||||
translation_key="gas_meter",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
)
|
||||
],
|
||||
Attribute.GAS_METER_CALORIFIC: [
|
||||
@ -443,7 +442,7 @@ CAPABILITY_TO_SENSORS: dict[
|
||||
key=Attribute.GAS_METER_VOLUME,
|
||||
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||
device_class=SensorDeviceClass.GAS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
)
|
||||
],
|
||||
},
|
||||
@ -1003,6 +1002,7 @@ CAPABILITY_TO_SENSORS: dict[
|
||||
UNITS = {
|
||||
"C": UnitOfTemperature.CELSIUS,
|
||||
"F": UnitOfTemperature.FAHRENHEIT,
|
||||
"ccf": UnitOfVolume.CENTUM_CUBIC_FEET,
|
||||
"lux": LIGHT_LUX,
|
||||
"mG": None,
|
||||
"μg/m^3": CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
|
@ -146,6 +146,7 @@ def mock_smartthings() -> Generator[AsyncMock]:
|
||||
"ikea_kadrilj",
|
||||
"aux_ac",
|
||||
"hw_q80r_soundbar",
|
||||
"gas_meter",
|
||||
]
|
||||
)
|
||||
def device_fixture(
|
||||
|
@ -0,0 +1,61 @@
|
||||
{
|
||||
"components": {
|
||||
"main": {
|
||||
"healthCheck": {
|
||||
"checkInterval": {
|
||||
"value": 60,
|
||||
"unit": "s",
|
||||
"data": {
|
||||
"deviceScheme": "UNTRACKED",
|
||||
"protocol": "cloud"
|
||||
},
|
||||
"timestamp": "2025-02-27T14:06:11.704Z"
|
||||
},
|
||||
"healthStatus": {
|
||||
"value": null
|
||||
},
|
||||
"DeviceWatch-Enroll": {
|
||||
"value": null
|
||||
},
|
||||
"DeviceWatch-DeviceStatus": {
|
||||
"value": "online",
|
||||
"data": {},
|
||||
"timestamp": "2025-04-11T13:00:00.444Z"
|
||||
}
|
||||
},
|
||||
"refresh": {},
|
||||
"gasMeter": {
|
||||
"gasMeterPrecision": {
|
||||
"value": {
|
||||
"volume": 5,
|
||||
"calorific": 1,
|
||||
"conversion": 1
|
||||
},
|
||||
"timestamp": "2025-04-11T13:00:00.444Z"
|
||||
},
|
||||
"gasMeterCalorific": {
|
||||
"value": 40,
|
||||
"timestamp": "2025-04-11T13:00:00.444Z"
|
||||
},
|
||||
"gasMeterTime": {
|
||||
"value": "2025-04-11T13:30:00.028Z",
|
||||
"timestamp": "2025-04-11T13:30:00.532Z"
|
||||
},
|
||||
"gasMeterVolume": {
|
||||
"value": 14,
|
||||
"unit": "ccf",
|
||||
"timestamp": "2025-04-11T13:00:00.444Z"
|
||||
},
|
||||
"gasMeterConversion": {
|
||||
"value": 3.6,
|
||||
"timestamp": "2025-04-11T13:00:00.444Z"
|
||||
},
|
||||
"gasMeter": {
|
||||
"value": 450.5,
|
||||
"unit": "kWh",
|
||||
"timestamp": "2025-04-11T13:00:00.444Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
56
tests/components/smartthings/fixtures/devices/gas_meter.json
Normal file
56
tests/components/smartthings/fixtures/devices/gas_meter.json
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"deviceId": "3b57dca3-9a90-4f27-ba80-f947b1e60d58",
|
||||
"name": "copper_gas_meter_v04",
|
||||
"label": "Gas Meter",
|
||||
"manufacturerName": "0A6v",
|
||||
"presentationId": "ST_176e9efa-01d2-4d1b-8130-d37a4ef1b413",
|
||||
"deviceManufacturerCode": "CopperLabs",
|
||||
"locationId": "4e88bf74-3bed-4e6d-9fa7-6acb776a4df9",
|
||||
"ownerId": "6fc21de5-123e-2f8c-2cc6-311635aeaaef",
|
||||
"roomId": "fafae9db-a2b5-480f-8ff5-df8f913356df",
|
||||
"components": [
|
||||
{
|
||||
"id": "main",
|
||||
"label": "main",
|
||||
"capabilities": [
|
||||
{
|
||||
"id": "healthCheck",
|
||||
"version": 1
|
||||
},
|
||||
{
|
||||
"id": "refresh",
|
||||
"version": 1
|
||||
},
|
||||
{
|
||||
"id": "gasMeter",
|
||||
"version": 1
|
||||
}
|
||||
],
|
||||
"categories": [
|
||||
{
|
||||
"name": "GasMeter",
|
||||
"categoryType": "manufacturer"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"createTime": "2025-02-27T14:06:11.522Z",
|
||||
"profile": {
|
||||
"id": "5cca2553-23d6-43c4-81ad-a1c6c43efa00"
|
||||
},
|
||||
"viper": {
|
||||
"manufacturerName": "CopperLabs",
|
||||
"modelName": "Virtual Gas Meter",
|
||||
"endpointAppId": "viper_1d5767a0-af08-11ed-a999-9f1f172a27ff"
|
||||
},
|
||||
"type": "VIPER",
|
||||
"restrictionTier": 0,
|
||||
"allowed": null,
|
||||
"executionContext": "CLOUD",
|
||||
"relationships": []
|
||||
}
|
||||
],
|
||||
"_links": {}
|
||||
}
|
@ -1058,6 +1058,39 @@
|
||||
'via_device_id': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_devices[gas_meter]
|
||||
DeviceRegistryEntrySnapshot({
|
||||
'area_id': None,
|
||||
'config_entries': <ANY>,
|
||||
'config_entries_subentries': <ANY>,
|
||||
'configuration_url': 'https://account.smartthings.com',
|
||||
'connections': set({
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'entry_type': None,
|
||||
'hw_version': None,
|
||||
'id': <ANY>,
|
||||
'identifiers': set({
|
||||
tuple(
|
||||
'smartthings',
|
||||
'3b57dca3-9a90-4f27-ba80-f947b1e60d58',
|
||||
),
|
||||
}),
|
||||
'is_new': False,
|
||||
'labels': set({
|
||||
}),
|
||||
'manufacturer': 'CopperLabs',
|
||||
'model': 'Virtual Gas Meter',
|
||||
'model_id': None,
|
||||
'name': 'Gas Meter',
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'suggested_area': None,
|
||||
'sw_version': None,
|
||||
'via_device_id': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_devices[ge_in_wall_smart_dimmer]
|
||||
DeviceRegistryEntrySnapshot({
|
||||
'area_id': 'theater',
|
||||
|
@ -8007,6 +8007,208 @@
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[gas_meter][sensor.gas_meter_gas-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.gas_meter_gas',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
'sensor.private': dict({
|
||||
'suggested_unit_of_measurement': <UnitOfVolume.CUBIC_METERS: 'm³'>,
|
||||
}),
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.GAS: 'gas'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Gas',
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': None,
|
||||
'unique_id': '3b57dca3-9a90-4f27-ba80-f947b1e60d58_main_gasMeter_gasMeterVolume_gasMeterVolume',
|
||||
'unit_of_measurement': <UnitOfVolume.CUBIC_METERS: 'm³'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[gas_meter][sensor.gas_meter_gas-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'gas',
|
||||
'friendly_name': 'Gas Meter Gas',
|
||||
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
||||
'unit_of_measurement': <UnitOfVolume.CUBIC_METERS: 'm³'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.gas_meter_gas',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '40',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[gas_meter][sensor.gas_meter_gas_meter-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.gas_meter_gas_meter',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Gas meter',
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'gas_meter',
|
||||
'unique_id': '3b57dca3-9a90-4f27-ba80-f947b1e60d58_main_gasMeter_gasMeter_gasMeter',
|
||||
'unit_of_measurement': 'kWh',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[gas_meter][sensor.gas_meter_gas_meter-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'energy',
|
||||
'friendly_name': 'Gas Meter Gas meter',
|
||||
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
||||
'unit_of_measurement': 'kWh',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.gas_meter_gas_meter',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '450.5',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[gas_meter][sensor.gas_meter_gas_meter_calorific-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.gas_meter_gas_meter_calorific',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Gas meter calorific',
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'gas_meter_calorific',
|
||||
'unique_id': '3b57dca3-9a90-4f27-ba80-f947b1e60d58_main_gasMeter_gasMeterCalorific_gasMeterCalorific',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[gas_meter][sensor.gas_meter_gas_meter_calorific-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'Gas Meter Gas meter calorific',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.gas_meter_gas_meter_calorific',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '40',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[gas_meter][sensor.gas_meter_gas_meter_time-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.gas_meter_gas_meter_time',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.TIMESTAMP: 'timestamp'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Gas meter time',
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'gas_meter_time',
|
||||
'unique_id': '3b57dca3-9a90-4f27-ba80-f947b1e60d58_main_gasMeter_gasMeterTime_gasMeterTime',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[gas_meter][sensor.gas_meter_gas_meter_time-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'timestamp',
|
||||
'friendly_name': 'Gas Meter Gas meter time',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.gas_meter_gas_meter_time',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '2025-04-11T13:30:00+00:00',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[generic_ef00_v1][sensor.thermostat_kuche_link_quality-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
Loading…
x
Reference in New Issue
Block a user