1 """The Bryant Evolution integration."""
3 from __future__
import annotations
7 from evolutionhttp
import BryantEvolutionLocalClient
16 from .const
import CONF_SYSTEM_ZONE, DOMAIN
18 PLATFORMS: list[Platform] = [Platform.CLIMATE]
20 type BryantEvolutionLocalClients = dict[tuple[int, int], BryantEvolutionLocalClient]
21 type BryantEvolutionConfigEntry = ConfigEntry[BryantEvolutionLocalClients]
22 _LOGGER = logging.getLogger(__name__)
26 """Return whether we can reach the device at the given filename."""
29 return await client.read_current_temperature()
is not None
33 hass: HomeAssistant, entry: BryantEvolutionConfigEntry
35 """Set up Bryant Evolution from a config entry."""
38 sam_uid = names.sam_device_uid(entry)
39 device_registry = dr.async_get(hass)
40 device_registry.async_get_or_create(
41 config_entry_id=entry.entry_id,
42 identifiers={(DOMAIN, sam_uid)},
43 manufacturer=
"Bryant",
44 name=
"System Access Module",
49 if not any(sz[0] == sys_id
for sz
in entry.data[CONF_SYSTEM_ZONE]):
51 "Skipping system %s because it is not configured for this integration: %s",
53 entry.data[CONF_SYSTEM_ZONE],
56 device_registry.async_get_or_create(
57 config_entry_id=entry.entry_id,
58 identifiers={(DOMAIN, names.system_device_uid(sam_uid, sys_id))},
59 via_device=(DOMAIN, names.sam_device_uid(entry)),
60 manufacturer=
"Bryant",
61 name=f
"System {sys_id}",
65 entry.runtime_data = {}
66 for sz
in entry.data[CONF_SYSTEM_ZONE]:
68 client = await BryantEvolutionLocalClient.get_client(
69 sz[0], sz[1], entry.data[CONF_FILENAME]
72 raise ConfigEntryNotReady
73 entry.runtime_data[
tuple(sz)] = client
74 except FileNotFoundError
as f:
75 raise ConfigEntryNotReady
from f
76 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
81 hass: HomeAssistant, entry: BryantEvolutionConfigEntry
83 """Unload a config entry."""
84 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, BryantEvolutionConfigEntry entry)
bool _can_reach_device(BryantEvolutionLocalClient client)
bool async_unload_entry(HomeAssistant hass, BryantEvolutionConfigEntry entry)