Add diagnostics to LiteJet (#86600)
This commit is contained in:
parent
7ddb467ba6
commit
bbed1099d5
3 changed files with 42 additions and 0 deletions
22
homeassistant/components/litejet/diagnostics.py
Normal file
22
homeassistant/components/litejet/diagnostics.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
"""Support for LiteJet diagnostics."""
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from pylitejet import LiteJet
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
async def async_get_config_entry_diagnostics(
|
||||||
|
hass: HomeAssistant, entry: ConfigEntry
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
"""Return diagnostics for LiteJet config entry."""
|
||||||
|
system: LiteJet = hass.data[DOMAIN]
|
||||||
|
return {
|
||||||
|
"loads": list(system.loads()),
|
||||||
|
"button_switches": list(system.button_switches()),
|
||||||
|
"scenes": list(system.scenes()),
|
||||||
|
"connected": system.connected,
|
||||||
|
}
|
|
@ -68,5 +68,6 @@ def mock_litejet():
|
||||||
|
|
||||||
mock_lj.start_time = dt_util.utcnow()
|
mock_lj.start_time = dt_util.utcnow()
|
||||||
mock_lj.last_delta = timedelta(0)
|
mock_lj.last_delta = timedelta(0)
|
||||||
|
mock_lj.connected = True
|
||||||
|
|
||||||
yield mock_lj
|
yield mock_lj
|
||||||
|
|
19
tests/components/litejet/test_diagnostics.py
Normal file
19
tests/components/litejet/test_diagnostics.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
"""The tests for the litejet component."""
|
||||||
|
from . import async_init_integration
|
||||||
|
|
||||||
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||||
|
|
||||||
|
|
||||||
|
async def test_diagnostics(hass, hass_client, mock_litejet):
|
||||||
|
"""Test getting the LiteJet diagnostics."""
|
||||||
|
|
||||||
|
config_entry = await async_init_integration(hass)
|
||||||
|
|
||||||
|
diag = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
||||||
|
|
||||||
|
assert diag == {
|
||||||
|
"loads": [1, 2],
|
||||||
|
"button_switches": [1, 2],
|
||||||
|
"scenes": [1, 2],
|
||||||
|
"connected": True,
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue