From 28b8984be5b1c8839fc8077d8d59bdba97eacc38 Mon Sep 17 00:00:00 2001 From: Austin Mroczek Date: Sat, 6 Nov 2021 21:16:36 +0000 Subject: [PATCH] load locations to prevent 'unknown error occurred' --- homeassistant/components/totalconnect/config_flow.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/homeassistant/components/totalconnect/config_flow.py b/homeassistant/components/totalconnect/config_flow.py index f3550722de5..45985bd0563 100644 --- a/homeassistant/components/totalconnect/config_flow.py +++ b/homeassistant/components/totalconnect/config_flow.py @@ -4,6 +4,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.exceptions import HomeAssistantError from .const import CONF_USERCODES, DOMAIN @@ -88,6 +89,14 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): }, ) else: + # Force the loading of locations using I/O + number_locations = await self.hass.async_add_executor_job( + self.client.get_number_locations, + ) + if number_locations < 1: + raise HomeAssistantError( + "There are no locations enabled or available for this TotalConnect user." + ) for location_id in self.client.locations: self.usercodes[location_id] = None