mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Adjust system info for lovelace with multiple dashboards (#44796)
This commit is contained in:
parent
de780c6d35
commit
766f89f338
@ -16,6 +16,7 @@ DEFAULT_ICON = "hass:view-dashboard"
|
||||
CONF_MODE = "mode"
|
||||
MODE_YAML = "yaml"
|
||||
MODE_STORAGE = "storage"
|
||||
MODE_AUTO = "auto-gen"
|
||||
|
||||
LOVELACE_CONFIG_FILE = "ui-lovelace.yaml"
|
||||
CONF_RESOURCES = "resources"
|
||||
|
@ -1,8 +1,10 @@
|
||||
"""Provide info to system health."""
|
||||
import asyncio
|
||||
|
||||
from homeassistant.components import system_health
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
||||
from .const import DOMAIN
|
||||
from .const import CONF_MODE, DOMAIN, MODE_AUTO, MODE_STORAGE, MODE_YAML
|
||||
|
||||
|
||||
@callback
|
||||
@ -16,6 +18,30 @@ def async_register(
|
||||
async def system_health_info(hass):
|
||||
"""Get info for the info page."""
|
||||
health_info = {"dashboards": len(hass.data[DOMAIN]["dashboards"])}
|
||||
health_info.update(await hass.data[DOMAIN]["dashboards"][None].async_get_info())
|
||||
health_info.update(await hass.data[DOMAIN]["resources"].async_get_info())
|
||||
|
||||
dashboards_info = await asyncio.gather(
|
||||
*[
|
||||
hass.data[DOMAIN]["dashboards"][dashboard].async_get_info()
|
||||
for dashboard in hass.data[DOMAIN]["dashboards"]
|
||||
]
|
||||
)
|
||||
|
||||
modes = set()
|
||||
for dashboard in dashboards_info:
|
||||
for key in dashboard:
|
||||
if isinstance(dashboard[key], int):
|
||||
health_info[key] = health_info.get(key, 0) + dashboard[key]
|
||||
elif key == CONF_MODE:
|
||||
modes.add(dashboard[key])
|
||||
else:
|
||||
health_info[key] = dashboard[key]
|
||||
|
||||
if MODE_STORAGE in modes:
|
||||
health_info[CONF_MODE] = MODE_STORAGE
|
||||
elif MODE_YAML in modes:
|
||||
health_info[CONF_MODE] = MODE_YAML
|
||||
else:
|
||||
health_info[CONF_MODE] = MODE_AUTO
|
||||
|
||||
return health_info
|
||||
|
Loading…
x
Reference in New Issue
Block a user