1 """Support for Honeywell (US) Total Connect Comfort climate systems."""
3 from dataclasses
import dataclass
5 from aiohttp.client_exceptions
import ClientConnectionError
13 async_create_clientsession,
14 async_get_clientsession,
19 CONF_COOL_AWAY_TEMPERATURE,
20 CONF_HEAT_AWAY_TEMPERATURE,
24 UPDATE_LOOP_SLEEP_TIME = 5
25 PLATFORMS = [Platform.CLIMATE, Platform.SENSOR, Platform.SWITCH]
27 MIGRATE_OPTIONS_KEYS = {CONF_COOL_AWAY_TEMPERATURE, CONF_HEAT_AWAY_TEMPERATURE}
32 hass: HomeAssistant, config_entry: ConfigEntry
34 if not MIGRATE_OPTIONS_KEYS.intersection(config_entry.data):
36 hass.config_entries.async_update_entry(
39 k: v
for k, v
in config_entry.data.items()
if k
not in MIGRATE_OPTIONS_KEYS
42 **config_entry.options,
43 **{k: config_entry.data.get(k)
for k
in MIGRATE_OPTIONS_KEYS},
49 """Set up the Honeywell thermostat."""
52 username = config_entry.data[CONF_USERNAME]
53 password = config_entry.data[CONF_PASSWORD]
55 if len(hass.config_entries.async_entries(DOMAIN)) > 1:
60 client = aiosomecomfort.AIOSomeComfort(username, password, session=session)
63 await client.discover()
65 except aiosomecomfort.device.AuthError
as ex:
69 aiosomecomfort.device.ConnectionError,
70 aiosomecomfort.device.ConnectionTimeout,
71 aiosomecomfort.device.SomeComfortError,
72 ClientConnectionError,
76 "Failed to initialize the Honeywell client: Connection error"
80 for location
in client.locations_by_id.values():
81 for device
in location.devices_by_id.values():
82 devices[device.deviceid] = device
85 _LOGGER.debug(
"No devices found")
88 hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = data
89 await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
91 config_entry.async_on_unload(config_entry.add_update_listener(update_listener))
96 async
def update_listener(hass: HomeAssistant, config_entry: ConfigEntry) ->
None:
97 """Update listener."""
98 await hass.config_entries.async_reload(config_entry.entry_id)
102 """Unload the config and platforms."""
103 unload_ok = await hass.config_entries.async_unload_platforms(
104 config_entry, PLATFORMS
107 hass.data[DOMAIN].pop(config_entry.entry_id)
113 """Shared data for Honeywell."""
116 client: aiosomecomfort.AIOSomeComfort
117 devices: dict[str, aiosomecomfort.device.Device]
None _async_migrate_data_to_options(HomeAssistant hass, ConfigEntry config_entry)
None update_listener(HomeAssistant hass, ConfigEntry config_entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry config_entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry config_entry)
aiohttp.ClientSession async_create_clientsession()
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)