load locations to prevent 'unknown error occurred'

This commit is contained in:
Austin Mroczek
2021-11-06 21:16:36 +00:00
parent c56b064ce7
commit 28b8984be5

View File

@@ -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