diff --git a/homeassistant/components/google_assistant/diagnostics.py b/homeassistant/components/google_assistant/diagnostics.py index 6cfaec99f6e..fd4347ddd2c 100644 --- a/homeassistant/components/google_assistant/diagnostics.py +++ b/homeassistant/components/google_assistant/diagnostics.py @@ -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), } diff --git a/homeassistant/components/google_assistant/smart_home.py b/homeassistant/components/google_assistant/smart_home.py index 75a3fd76b9b..c034e5fc6ca 100644 --- a/homeassistant/components/google_assistant/smart_home.py +++ b/homeassistant/components/google_assistant/smart_home.py @@ -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 diff --git a/tests/components/google_assistant/test_diagnostics.py b/tests/components/google_assistant/test_diagnostics.py index 13721c17f88..99a091f0bdc 100644 --- a/tests/components/google_assistant/test_diagnostics.py +++ b/tests/components/google_assistant/test_diagnostics.py @@ -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": [