Add diagnostics support to roku (#64729)
parent
74c16b977d
commit
e3900f0c0a
|
@ -0,0 +1,27 @@
|
|||
"""Diagnostics support for Roku."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import RokuDataUpdateCoordinator
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator: RokuDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
return {
|
||||
"entry": {
|
||||
"data": {
|
||||
**config_entry.data,
|
||||
},
|
||||
"unique_id": config_entry.unique_id,
|
||||
},
|
||||
"data": coordinator.data.as_dict(),
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
{
|
||||
"app": {
|
||||
"app_id": null,
|
||||
"name": "Roku",
|
||||
"screensaver": false,
|
||||
"version": null
|
||||
},
|
||||
"apps": [
|
||||
{
|
||||
"app_id": "11",
|
||||
"name": "Roku Channel Store",
|
||||
"screensaver": false,
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"app_id": "12",
|
||||
"name": "Netflix",
|
||||
"screensaver": false,
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"app_id": "13",
|
||||
"name": "Amazon Video on Demand",
|
||||
"screensaver": false,
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"app_id": "14",
|
||||
"name": "MLB.TV®",
|
||||
"screensaver": false,
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"app_id": "26",
|
||||
"name": "Free FrameChannel Service",
|
||||
"screensaver": false,
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"app_id": "27",
|
||||
"name": "Mediafly",
|
||||
"screensaver": false,
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"app_id": "28",
|
||||
"name": "Pandora",
|
||||
"screensaver": false,
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"app_id": "74519",
|
||||
"name": "Pluto TV - It's Free TV",
|
||||
"screensaver": false,
|
||||
"version": "5.2.0"
|
||||
}
|
||||
],
|
||||
"channel": null,
|
||||
"channels": [],
|
||||
"info": {
|
||||
"brand": "Roku",
|
||||
"device_location": null,
|
||||
"device_type": "box",
|
||||
"ethernet_mac": "b0:a7:37:96:4d:fa",
|
||||
"ethernet_support": true,
|
||||
"headphones_connected": false,
|
||||
"model_name": "Roku 3",
|
||||
"model_number": "4200X",
|
||||
"name": "My Roku 3",
|
||||
"network_name": null,
|
||||
"network_type": "ethernet",
|
||||
"serial_number": "1GU48T017973",
|
||||
"supports_airplay": false,
|
||||
"supports_find_remote": false,
|
||||
"supports_private_listening": false,
|
||||
"version": "7.5.0",
|
||||
"wifi_mac": "b0:a7:37:96:4d:fb"
|
||||
},
|
||||
"media": null,
|
||||
"state": {
|
||||
"at": "2022-01-23T21:05:03.154737",
|
||||
"available": true,
|
||||
"standby": false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
"""Tests for the diagnostics data provided by the Roku integration."""
|
||||
import json
|
||||
|
||||
from aiohttp import ClientSession
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
|
||||
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSession,
|
||||
init_integration: MockConfigEntry,
|
||||
):
|
||||
"""Test diagnostics for config entry."""
|
||||
diagnostics_data = json.loads(load_fixture("roku/roku3-diagnostics-data.json"))
|
||||
|
||||
result = await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
||||
|
||||
assert isinstance(result, dict)
|
||||
assert isinstance(result["entry"], dict)
|
||||
assert result["entry"]["data"] == {"host": "192.168.1.160"}
|
||||
assert result["entry"]["unique_id"] == "1GU48T017973"
|
||||
|
||||
assert isinstance(result["data"], dict)
|
||||
assert result["data"]["app"] == diagnostics_data["app"]
|
||||
assert result["data"]["apps"] == diagnostics_data["apps"]
|
||||
assert result["data"]["channel"] == diagnostics_data["channel"]
|
||||
assert result["data"]["channels"] == diagnostics_data["channels"]
|
||||
assert result["data"]["info"] == diagnostics_data["info"]
|
||||
assert result["data"]["media"] == diagnostics_data["media"]
|
||||
|
||||
data_state = result["data"]["state"]
|
||||
assert isinstance(data_state, dict)
|
||||
assert data_state["available"] == diagnostics_data["state"]["available"]
|
||||
assert data_state["standby"] == diagnostics_data["state"]["standby"]
|
Loading…
Reference in New Issue