Skip to content

Commit 3d7becc

Browse files
authored
Remove dependency to get_hacs() method, which was removed in hacs 0.19.0 (#14)
1 parent ee259a4 commit 3d7becc

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

custom_components/readme/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from homeassistant.setup import async_get_loaded_integrations
2323
from jinja2 import Template
2424

25+
2526
from .const import DOMAIN, DOMAIN_DATA, LOGGER, STARTUP_MESSAGE
2627

2728
CONFIG_SCHEMA = vol.Schema(
@@ -150,7 +151,7 @@ async def service_generate(_call):
150151
await convert_lovelace(hass)
151152

152153
custom_components = await get_custom_integrations(hass)
153-
hacs_components = get_hacs_components()
154+
hacs_components = get_hacs_components(hass)
154155

155156
variables = {
156157
"custom_components": custom_components,
@@ -170,21 +171,17 @@ async def service_generate(_call):
170171
hass.services.async_register(DOMAIN, "generate", service_generate)
171172

172173

173-
def get_hacs_components():
174-
try:
175-
from custom_components.hacs.share import get_hacs
176-
except ImportError:
174+
def get_hacs_components(hass: HomeAssistant):
175+
if (hacs := hass.data.get("hacs")) is None:
177176
return []
178177

179-
hacs = get_hacs()
180-
181178
return [
182179
{
183180
**repo.data.to_json(),
184181
"name": get_repository_name(repo),
185182
"documentation": f"https://github.com/{repo.data.full_name}",
186183
}
187-
for repo in hacs.repositories or [] if repo.data.installed
184+
for repo in hacs.repositories.list_downloaded or []
188185
]
189186

190187

hacs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"filename": "readme.zip",
66
"homeassistant": "2021.5.0",
77
"hide_default_branch": true,
8-
"render_readme": true
8+
"render_readme": true,
9+
"hacs": "0.19.1"
910
}

0 commit comments

Comments
 (0)