hass-core/homeassistant/components/reolink/util.py
starkillerOG 834f3810d3
Check new IP of Reolink camera from DHCP (#99381)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-09-02 21:00:33 +02:00

23 lines
734 B
Python

"""Utility functions for the Reolink component."""
from __future__ import annotations
from homeassistant import config_entries
from homeassistant.core import HomeAssistant
from . import ReolinkData
from .const import DOMAIN
def has_connection_problem(
hass: HomeAssistant, config_entry: config_entries.ConfigEntry
) -> bool:
"""Check if a existing entry has a connection problem."""
reolink_data: ReolinkData | None = hass.data.get(DOMAIN, {}).get(
config_entry.entry_id
)
connection_problem = (
reolink_data is not None
and config_entry.state == config_entries.ConfigEntryState.LOADED
and reolink_data.device_coordinator.last_update_success
)
return connection_problem