mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Add per-device diagnostics to Sonos (#64912)
This commit is contained in:
parent
10efeb2935
commit
cb571d86be
@ -6,8 +6,9 @@ from typing import Any
|
|||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.device_registry import DeviceEntry
|
||||||
|
|
||||||
from .const import DATA_SONOS
|
from .const import DATA_SONOS, DOMAIN
|
||||||
from .speaker import SonosSpeaker
|
from .speaker import SonosSpeaker
|
||||||
|
|
||||||
MEDIA_DIAGNOSTIC_ATTRIBUTES = (
|
MEDIA_DIAGNOSTIC_ATTRIBUTES = (
|
||||||
@ -63,6 +64,23 @@ async def async_get_config_entry_diagnostics(
|
|||||||
return payload
|
return payload
|
||||||
|
|
||||||
|
|
||||||
|
async def async_get_device_diagnostics(
|
||||||
|
hass: HomeAssistant, config_entry: ConfigEntry, device: DeviceEntry
|
||||||
|
) -> dict[str, Any] | None:
|
||||||
|
"""Return diagnostics for a device."""
|
||||||
|
uid = next(
|
||||||
|
(identifier[1] for identifier in device.identifiers if identifier[0] == DOMAIN),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
if uid is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if (speaker := hass.data[DATA_SONOS].discovered.get(uid)) is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return await async_generate_speaker_info(hass, speaker)
|
||||||
|
|
||||||
|
|
||||||
async def async_generate_media_info(
|
async def async_generate_media_info(
|
||||||
hass: HomeAssistant, speaker: SonosSpeaker
|
hass: HomeAssistant, speaker: SonosSpeaker
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user