Skip to content

Commit

Permalink
Добавлена выгрузка диагностических данных
Browse files Browse the repository at this point in the history
  • Loading branch information
dext0r committed Apr 25, 2024
1 parent 17132c3 commit fecedf4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
24 changes: 24 additions & 0 deletions custom_components/yandex_station_intents/diagnostics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from typing import Any

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant

from . import Component
from .const import DOMAIN


async def async_get_config_entry_diagnostics(hass: HomeAssistant, entry: ConfigEntry) -> dict[str, Any]:
component: Component = hass.data[DOMAIN]
entry_data = component.entry_datas[entry.entry_id]

try:
scenarios: Any = await entry_data.quasar.async_get_scenarios()
except Exception as e:
scenarios = e

return {
"yaml_config": component.yaml_config,
"devices": entry_data.quasar.devices,
"scenarios": scenarios,
"intents": entry_data.intent_manager.intents,
}
14 changes: 9 additions & 5 deletions custom_components/yandex_station_intents/yandex_quasar.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,20 @@ async def async_get_intent_player_device_id(self) -> str | None:

return None

async def async_get_intents(self) -> dict[str, str]:
"""Получает список интенетов, которые управляются компонентом."""
_LOGGER.debug("Получение списка интентов")

async def async_get_scenarios(self) -> list[dict[str, Any]]:
r = await self._session.get(f"{URL_USER}/scenarios")
resp = await r.json()
assert resp["status"] == "ok", resp
assert isinstance(resp["scenarios"], list)

return resp["scenarios"]

async def async_get_intents(self) -> dict[str, str]:
"""Получает список интенетов, которые управляются компонентом."""
_LOGGER.debug("Получение списка интентов")

rv = {}
for scenario in resp["scenarios"]:
for scenario in await self.async_get_scenarios():
if INTENT_ID_MARKER not in scenario["name"]:
continue

Expand Down

0 comments on commit fecedf4

Please sign in to comment.