1
mirror of https://github.com/home-assistant/core synced 2024-10-04 07:58:43 +02:00

Add query data to google assistant diagnostic (#78828)

This commit is contained in:
Joakim Plate 2022-09-20 17:05:10 +02:00 committed by GitHub
parent 4f31f28e67
commit 924bffc7d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -11,7 +11,11 @@ from homeassistant.helpers.typing import ConfigType
from .const import CONF_SECURE_DEVICES_PIN, CONF_SERVICE_ACCOUNT, DATA_CONFIG, DOMAIN
from .http import GoogleConfig
from .smart_home import async_devices_sync_response, create_sync_response
from .smart_home import (
async_devices_query_response,
async_devices_sync_response,
create_sync_response,
)
TO_REDACT = [
"uuid",
@ -32,9 +36,11 @@ async def async_get_config_entry_diagnostics(
yaml_config: ConfigType = data[DATA_CONFIG]
devices = await async_devices_sync_response(hass, config, REDACTED)
sync = create_sync_response(REDACTED, devices)
query = await async_devices_query_response(hass, config, devices)
return {
"config_entry": async_redact_data(entry.as_dict(), TO_REDACT),
"yaml_config": async_redact_data(yaml_config, TO_REDACT),
"sync": async_redact_data(sync, TO_REDACT),
"query": async_redact_data(query, TO_REDACT),
}

View File

@ -130,6 +130,11 @@ async def async_devices_query(hass, data, payload):
context=data.context,
)
return await async_devices_query_response(hass, data.config, payload_devices)
async def async_devices_query_response(hass, config, payload_devices):
"""Generate the device serialization."""
devices = {}
for device in payload_devices:
devid = device["id"]
@ -139,7 +144,7 @@ async def async_devices_query(hass, data, payload):
devices[devid] = {"online": False}
continue
entity = GoogleEntity(hass, data.config, state)
entity = GoogleEntity(hass, config, state)
try:
devices[devid] = entity.query_serialize()
except Exception: # pylint: disable=broad-except

View File

@ -80,6 +80,12 @@ async def test_diagnostics(hass: core.HomeAssistant, hass_client: Any):
},
],
},
"query": {
"devices": {
"switch.ac": {"on": False, "online": True},
"switch.decorative_lights": {"on": True, "online": True},
}
},
"yaml_config": {
"expose_by_default": True,
"exposed_domains": [