Fix missing powerconsumptionreport in Smartthings (#153438)

This commit is contained in:
Joost Lekkerkerker
2025-10-02 22:08:48 +02:00
committed by Franck Nijhof
parent cf668e9dc2
commit 1e8aae0a89
6 changed files with 297 additions and 2 deletions

View File

@@ -1151,8 +1151,11 @@ async def async_setup_entry(
)
and (
not description.exists_fn
or description.exists_fn(
device.status[MAIN][capability][attribute]
or (
component == MAIN
and description.exists_fn(
device.status[MAIN][capability][attribute]
)
)
)
and (

View File

@@ -166,6 +166,7 @@ def mock_smartthings() -> Generator[AsyncMock]:
"hw_q80r_soundbar",
"gas_meter",
"lumi",
"tesla_powerwall",
]
)
def device_fixture(

View File

@@ -0,0 +1,107 @@
{
"components": {
"charge": {
"powerMeter": {
"power": {
"value": 0,
"unit": "W",
"timestamp": "2025-10-02T12:21:29.196Z"
}
},
"powerConsumptionReport": {
"powerConsumption": {
"value": {
"start": "2025-10-02T12:20:00Z",
"end": "2025-10-02T12:25:00Z",
"energy": 29765947,
"deltaEnergy": 0
},
"timestamp": "2025-10-02T12:26:24.729Z"
}
}
},
"discharge": {
"powerMeter": {
"power": {
"value": 0,
"unit": "W",
"timestamp": "2025-10-02T11:41:20.556Z"
}
},
"powerConsumptionReport": {
"powerConsumption": {
"value": {
"start": "2025-10-02T12:20:00Z",
"end": "2025-10-02T12:25:00Z",
"energy": 27827062,
"deltaEnergy": 0
},
"timestamp": "2025-10-02T12:26:24.729Z"
}
}
},
"main": {
"healthCheck": {
"checkInterval": {
"value": 60,
"unit": "s",
"data": {
"deviceScheme": "UNTRACKED",
"protocol": "cloud"
},
"timestamp": "2025-10-02T11:56:25.223Z"
},
"healthStatus": {
"value": null
},
"DeviceWatch-Enroll": {
"value": null
},
"DeviceWatch-DeviceStatus": {
"value": "online",
"data": {},
"timestamp": "2025-10-02T11:56:25.223Z"
}
},
"rivertalent14263.adaptiveEnergyUsageState": {
"stormWatchEnabled": {
"value": true,
"timestamp": "2024-07-16T12:40:19.190Z"
},
"stormWatchActive": {
"value": false,
"timestamp": "2024-07-16T12:40:19.190Z"
},
"gridStatusSupport": {
"value": true,
"timestamp": "2024-07-16T12:40:19.190Z"
},
"stormWatchSupport": {
"value": true,
"timestamp": "2025-09-17T18:31:31.669Z"
},
"energyUsageState": {
"value": null
},
"gridStatusStatus": {
"value": "on-grid",
"timestamp": "2025-09-17T18:31:31.669Z"
}
},
"refresh": {},
"battery": {
"quantity": {
"value": null
},
"battery": {
"value": 35,
"unit": "%",
"timestamp": "2025-10-02T11:41:20.556Z"
},
"type": {
"value": null
}
}
}
}
}

View File

@@ -0,0 +1,103 @@
{
"items": [
{
"deviceId": "d2595c45-df6e-41ac-a7af-8e275071c19b",
"name": "UDHN-TESLA-ENERGY-BATTERY",
"label": "Powerwall",
"manufacturerName": "0AHI",
"presentationId": "STES-1-PV-TESLA-ENERGY-BATTERY",
"locationId": "d22d6401-6070-4928-8e7b-b724e2dbf425",
"ownerId": "35445a41-3ae2-4bc0-6f51-31705de6b96f",
"components": [
{
"id": "main",
"label": "main",
"capabilities": [
{
"id": "healthCheck",
"version": 1
},
{
"id": "refresh",
"version": 1
},
{
"id": "rivertalent14263.adaptiveEnergyUsageState",
"version": 1
},
{
"id": "battery",
"version": 1
}
],
"categories": [
{
"name": "Battery",
"categoryType": "manufacturer"
}
],
"optional": false
},
{
"id": "discharge",
"label": "discharge",
"capabilities": [
{
"id": "powerConsumptionReport",
"version": 1
},
{
"id": "powerMeter",
"version": 1
}
],
"categories": [
{
"name": "Other",
"categoryType": "manufacturer"
}
],
"optional": false
},
{
"id": "charge",
"label": "charge",
"capabilities": [
{
"id": "powerConsumptionReport",
"version": 1
},
{
"id": "powerMeter",
"version": 1
}
],
"categories": [
{
"name": "Other",
"categoryType": "manufacturer"
}
],
"optional": false
}
],
"createTime": "2024-07-16T12:40:18.632Z",
"profile": {
"id": "4f9998dc-e672-4baf-8521-5e9b853fc978"
},
"app": {
"installedAppId": "e798c0a6-3e3b-4299-8463-438fc3f1e6b3",
"externalId": "TESLABATTERY_1689188152863574",
"profile": {
"id": "4f9998dc-e672-4baf-8521-5e9b853fc978"
}
},
"type": "ENDPOINT_APP",
"restrictionTier": 0,
"allowed": null,
"executionContext": "CLOUD",
"relationships": []
}
],
"_links": {}
}

View File

@@ -1893,6 +1893,37 @@
'via_device_id': None,
})
# ---
# name: test_devices[tesla_powerwall]
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',
'd2595c45-df6e-41ac-a7af-8e275071c19b',
),
}),
'labels': set({
}),
'manufacturer': None,
'model': None,
'model_id': None,
'name': 'Powerwall',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': None,
'via_device_id': None,
})
# ---
# name: test_devices[tplink_p110]
DeviceRegistryEntrySnapshot({
'area_id': None,

View File

@@ -13969,6 +13969,56 @@
'state': '20',
})
# ---
# name: test_all_entities[tesla_powerwall][sensor.powerwall_battery-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': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.powerwall_battery',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.BATTERY: 'battery'>,
'original_icon': None,
'original_name': 'Battery',
'platform': 'smartthings',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'd2595c45-df6e-41ac-a7af-8e275071c19b_main_battery_battery_battery',
'unit_of_measurement': '%',
})
# ---
# name: test_all_entities[tesla_powerwall][sensor.powerwall_battery-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'battery',
'friendly_name': 'Powerwall Battery',
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'sensor.powerwall_battery',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '35',
})
# ---
# name: test_all_entities[tplink_p110][sensor.spulmaschine_energy-entry]
EntityRegistryEntrySnapshot({
'aliases': set({