mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Simplify config entry check in SamsungTV (#116907)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
9807b2ec11
commit
9f9493c504
@ -7,6 +7,7 @@ from homeassistant.core import HomeAssistant, callback
|
|||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
from homeassistant.helpers.device_registry import DeviceEntry
|
from homeassistant.helpers.device_registry import DeviceEntry
|
||||||
|
|
||||||
|
from . import SamsungTVConfigEntry
|
||||||
from .bridge import SamsungTVBridge
|
from .bridge import SamsungTVBridge
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
@ -53,14 +54,10 @@ def async_get_client_by_device_entry(
|
|||||||
|
|
||||||
Raises ValueError if client is not found.
|
Raises ValueError if client is not found.
|
||||||
"""
|
"""
|
||||||
|
entry: SamsungTVConfigEntry | None
|
||||||
for config_entry_id in device.config_entries:
|
for config_entry_id in device.config_entries:
|
||||||
entry = hass.config_entries.async_get_entry(config_entry_id)
|
entry = hass.config_entries.async_get_entry(config_entry_id)
|
||||||
if (
|
if entry and entry.domain == DOMAIN and entry.state is ConfigEntryState.LOADED:
|
||||||
entry
|
|
||||||
and entry.state == ConfigEntryState.LOADED
|
|
||||||
and hasattr(entry, "runtime_data")
|
|
||||||
and isinstance(entry.runtime_data, SamsungTVBridge)
|
|
||||||
):
|
|
||||||
return entry.runtime_data
|
return entry.runtime_data
|
||||||
|
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user