Skip to content

Commit

Permalink
Move to UrlManager
Browse files Browse the repository at this point in the history
  • Loading branch information
vigonotion committed Apr 29, 2021
1 parent 8d81081 commit 9008a8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions custom_components/simpleicons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,51 @@

DOMAIN = "simpleicons"

DATA_EXTRA_MODULE_URL = 'frontend_extra_module_url'
ICONS_URL = '/'+DOMAIN+'/'
ICON_FILES = {
'simpleicons': 'si.js'
}
DATA_EXTRA_MODULE_URL = "frontend_extra_module_url"
ICONS_URL = "/" + DOMAIN + "/"
ICON_FILES = {"simpleicons": "si.js"}


async def async_setup(hass, config):
hass.http.register_static_path(
f"/{DOMAIN}/si.js",
hass.config.path(f"custom_components/{DOMAIN}/data/si.js"),
True
True,
)

if DOMAIN not in config:
return True

hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}
)
hass.config_entries.flow.async_init(DOMAIN, context={"source": SOURCE_IMPORT})
)

register_modules(hass)
return True


async def async_setup_entry(hass, config_entry):
config_entry.add_update_listener(_update_listener)
register_modules(hass)
return True


async def async_remove_entry(hass, config_entry):
register_modules(hass)
return True


async def _update_listener(hass, config_entry):
register_modules(hass)
return True


def register_modules(hass):
if DATA_EXTRA_MODULE_URL not in hass.data:
hass.data[DATA_EXTRA_MODULE_URL] = set()
hass.data[DATA_EXTRA_MODULE_URL] = UrlManager()
url_set = hass.data[DATA_EXTRA_MODULE_URL]

for k,v in ICON_FILES.items():
url_set.discard(ICONS_URL+v)
#if k in modules and modules[k] != False:
url_set.add(ICONS_URL+v)
for k, v in ICON_FILES.items():
url_set.remove(ICONS_URL + v)
# if k in modules and modules[k] != False:
url_set.add(ICONS_URL + v)
4 changes: 2 additions & 2 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "simpleicons",
"render_readme": true,
"homeassistant": "0.110.0b0",
"homeassistant": "2021.5.0b1",
"zip_release": true,
"filename": "hass-simpleicons.zip"
}
}

0 comments on commit 9008a8a

Please sign in to comment.