mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Update nest diagnostics (#65141)
This commit is contained in:
parent
3829a81d15
commit
25e6d8858c
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from google_nest_sdm import diagnostics
|
||||||
from google_nest_sdm.device import Device
|
from google_nest_sdm.device import Device
|
||||||
from google_nest_sdm.device_traits import InfoTrait
|
from google_nest_sdm.device_traits import InfoTrait
|
||||||
from google_nest_sdm.exceptions import ApiException
|
from google_nest_sdm.exceptions import ApiException
|
||||||
@ -30,22 +31,14 @@ async def async_get_config_entry_diagnostics(
|
|||||||
return {"error": str(err)}
|
return {"error": str(err)}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
**diagnostics.get_diagnostics(),
|
||||||
"devices": [
|
"devices": [
|
||||||
get_device_data(device) for device in device_manager.devices.values()
|
get_device_data(device) for device in device_manager.devices.values()
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_device_data(device: Device) -> dict[str, Any]:
|
def get_device_data(device: Device) -> dict[str, Any]:
|
||||||
"""Return diagnostic information about a device."""
|
"""Return diagnostic information about a device."""
|
||||||
# Return a simplified view of the API object, but skipping any id fields or
|
# Library performs its own redaction for device data
|
||||||
# traits that include unique identifiers or personally identifiable information.
|
return device.get_diagnostics()
|
||||||
# See https://developers.google.com/nest/device-access/traits for API details
|
|
||||||
return {
|
|
||||||
"type": device.type,
|
|
||||||
"traits": {
|
|
||||||
trait: data
|
|
||||||
for trait, data in device.raw_data.get("traits", {}).items()
|
|
||||||
if trait not in REDACT_DEVICE_TRAITS
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Common libraries for test setup."""
|
"""Common libraries for test setup."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Generator
|
||||||
import copy
|
import copy
|
||||||
import shutil
|
import shutil
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -8,6 +9,7 @@ from unittest.mock import patch
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
from google_nest_sdm import diagnostics
|
||||||
from google_nest_sdm.auth import AbstractAuth
|
from google_nest_sdm.auth import AbstractAuth
|
||||||
from google_nest_sdm.device_manager import DeviceManager
|
from google_nest_sdm.device_manager import DeviceManager
|
||||||
import pytest
|
import pytest
|
||||||
@ -234,3 +236,10 @@ async def setup_platform(
|
|||||||
) -> PlatformSetup:
|
) -> PlatformSetup:
|
||||||
"""Fixture to setup the integration platform and subscriber."""
|
"""Fixture to setup the integration platform and subscriber."""
|
||||||
return setup_base_platform
|
return setup_base_platform
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def reset_diagnostics() -> Generator[None, None, None]:
|
||||||
|
"""Fixture to reset client library diagnostic counters."""
|
||||||
|
yield
|
||||||
|
diagnostics.reset()
|
||||||
|
@ -56,13 +56,21 @@ async def test_entry_diagnostics(hass, hass_client):
|
|||||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
||||||
"devices": [
|
"devices": [
|
||||||
{
|
{
|
||||||
"traits": {
|
"data": {
|
||||||
"sdm.devices.traits.Humidity": {"ambientHumidityPercent": 35.0},
|
"assignee": "**REDACTED**",
|
||||||
"sdm.devices.traits.Temperature": {
|
"name": "**REDACTED**",
|
||||||
"ambientTemperatureCelsius": 25.1
|
"parentRelations": [
|
||||||
|
{"displayName": "**REDACTED**", "parent": "**REDACTED**"}
|
||||||
|
],
|
||||||
|
"traits": {
|
||||||
|
"sdm.devices.traits.Info": {"customName": "**REDACTED**"},
|
||||||
|
"sdm.devices.traits.Humidity": {"ambientHumidityPercent": 35.0},
|
||||||
|
"sdm.devices.traits.Temperature": {
|
||||||
|
"ambientTemperatureCelsius": 25.1
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
"type": "sdm.devices.types.THERMOSTAT",
|
||||||
"type": "sdm.devices.types.THERMOSTAT",
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user