mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Add diagnostics support to Schlage (#103347)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
7671ab0bb7
commit
22306bd309
23
homeassistant/components/schlage/diagnostics.py
Normal file
23
homeassistant/components/schlage/diagnostics.py
Normal file
@ -0,0 +1,23 @@
|
||||
"""Diagnostics support for Schlage."""
|
||||
|
||||
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 SchlageDataUpdateCoordinator
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator: SchlageDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
# NOTE: Schlage diagnostics are already redacted.
|
||||
return {
|
||||
"locks": [ld.lock.get_diagnostics() for ld in coordinator.data.locks.values()]
|
||||
}
|
@ -5,5 +5,5 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/schlage",
|
||||
"iot_class": "cloud_polling",
|
||||
"requirements": ["pyschlage==2023.10.0"]
|
||||
"requirements": ["pyschlage==2023.11.0"]
|
||||
}
|
||||
|
@ -2007,7 +2007,7 @@ pysabnzbd==1.1.1
|
||||
pysaj==0.0.16
|
||||
|
||||
# homeassistant.components.schlage
|
||||
pyschlage==2023.10.0
|
||||
pyschlage==2023.11.0
|
||||
|
||||
# homeassistant.components.sensibo
|
||||
pysensibo==1.0.36
|
||||
|
@ -1514,7 +1514,7 @@ pyrympro==0.0.7
|
||||
pysabnzbd==1.1.1
|
||||
|
||||
# homeassistant.components.schlage
|
||||
pyschlage==2023.10.0
|
||||
pyschlage==2023.11.0
|
||||
|
||||
# homeassistant.components.sensibo
|
||||
pysensibo==1.0.36
|
||||
|
23
tests/components/schlage/test_diagnostics.py
Normal file
23
tests/components/schlage/test_diagnostics.py
Normal file
@ -0,0 +1,23 @@
|
||||
"""Test Schlage diagnostics."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_added_config_entry: MockConfigEntry,
|
||||
mock_lock: Mock,
|
||||
) -> None:
|
||||
"""Test Schlage diagnostics."""
|
||||
mock_lock.get_diagnostics.return_value = {"foo": "bar"}
|
||||
diag = await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, mock_added_config_entry
|
||||
)
|
||||
assert diag == {"locks": [{"foo": "bar"}]}
|
Loading…
x
Reference in New Issue
Block a user