Startup fails if ISY is still starting up
I had a power outage today and things didn't startup in the right order which resulted in the below.
The failure was transient as it just happened that hass started up while the isy was starting (which would probably be a common thing during a power event)
2022-09-26 01:38:01.303 ERROR (MainThread) [pyisy] ISY Reported an Invalid Command Received.
2022-09-26 01:38:01.382 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry House (192.168.106.67) for isy994
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/isy994/__init__.py", line 197, in async_setup_entry
_categorize_programs(hass_isy_data, isy.programs)
File "/usr/src/homeassistant/homeassistant/components/isy994/helpers.py", line 332, in _categorize_programs
folder = programs.get_by_name(f"{DEFAULT_PROGRAM_STRING}{platform}")
File "/usr/local/lib/python3.10/site-packages/pyisy/programs/__init__.py", line 323, in get_by_name
for i in range(len(self.addresses)):
TypeError: object of type 'NoneType' has no len()
``
I don't know of any way to detect via REST if the ISY is still loading.
I can handle this error (the defaults in the init function arguments should be =[] not =None), but that may also lead to an issue where the ISY loads "successfully" but doesn't actually load one of the modules because it receives a partial/empty response.
I'll fix the init function definitions when I get a chance.
Thinking about this we might just want to catch it in hass and retry since even if we could determine if the isy is loading it doesn't mean it's still loading on the next request as it would be race prone
I added a check in HA in the mean time
Martin suggested wrapping the problem in a named exception
https://github.com/home-assistant/core/pull/79163#discussion_r981992598