Add query data to google assistant diagnostic (#78828)
parent
4f31f28e67
commit
924bffc7d0
|
@ -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),
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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": [
|
||||
|
|
Loading…
Reference in New Issue