44For more details about this component, please refer to
55https://github.com/custom-components/readme
66"""
7+
78from __future__ import annotations
89
910import asyncio
1718import yaml
1819from homeassistant import config_entries
1920from homeassistant .core import callback , HomeAssistant
21+ from homeassistant .components .hassio import is_hassio , get_supervisor_info # type: ignore
2022from homeassistant .helpers .template import AllStates
2123from homeassistant .loader import Integration , IntegrationNotFound , async_get_integration
2224from homeassistant .setup import async_get_loaded_integrations
@@ -100,7 +102,7 @@ async def convert_lovelace(hass: HomeAssistant):
100102 """Convert the lovelace configuration."""
101103 if os .path .exists (hass .config .path (".storage/lovelace" )):
102104 content = (
103- json .loads (await read_file (hass , ".storage/lovelace" ) or {} )
105+ json .loads (await read_file (hass , ".storage/lovelace" ) or "{}" )
104106 .get ("data" , {})
105107 .get ("config" , {})
106108 )
@@ -132,7 +134,9 @@ async def write_file(
132134 def write ():
133135 with open (hass .config .path (path ), "w" ) as open_file :
134136 if as_yaml :
135- yaml .dump (content , open_file , default_flow_style = False , allow_unicode = True )
137+ yaml .dump (
138+ content , open_file , default_flow_style = False , allow_unicode = True
139+ )
136140 else :
137141 open_file .write (content )
138142
@@ -189,9 +193,9 @@ def get_hacs_components(hass: HomeAssistant):
189193
190194@callback
191195def get_ha_installed_addons (hass : HomeAssistant ) -> List [Dict [str , Any ]]:
192- if not hass . components . hassio . is_hassio ():
196+ if is_hassio (hass ):
193197 return []
194- supervisor_info = hass . components . hassio . get_supervisor_info ()
198+ supervisor_info = get_supervisor_info (hass )
195199
196200 if supervisor_info :
197201 return supervisor_info .get ("addons" , [])
@@ -218,14 +222,14 @@ def get_repository_name(repository) -> str:
218222async def get_custom_integrations (hass : HomeAssistant ):
219223 """Return a list with custom integration info."""
220224 custom_integrations = []
221- configured_integrations : List [
222- Integration | IntegrationNotFound | BaseException
223- ] = await asyncio . gather (
224- * [
225- async_get_integration ( hass , domain )
226- for domain in async_get_loaded_integrations ( hass )
227- ] ,
228- return_exceptions = True ,
225+ configured_integrations : List [Integration | IntegrationNotFound | BaseException ] = (
226+ await asyncio . gather (
227+ * [
228+ async_get_integration ( hass , domain )
229+ for domain in async_get_loaded_integrations ( hass )
230+ ],
231+ return_exceptions = True ,
232+ )
229233 )
230234
231235 for integration in configured_integrations :
0 commit comments