Update HA, add vacuum, grid cards, fixes
This commit is contained in:
50
custom_components/fontawesome/__init__.py
Normal file
50
custom_components/fontawesome/__init__.py
Normal file
@@ -0,0 +1,50 @@
|
||||
DOMAIN = "fontawesome"
|
||||
|
||||
DATA_EXTRA_MODULE_URL = 'frontend_extra_module_url'
|
||||
ICONS_URL = f'/{DOMAIN}/'
|
||||
ICON_FILES = {
|
||||
'regular': 'far.js',
|
||||
'solid': 'fas.js',
|
||||
'brands': 'fab.js',
|
||||
}
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
for f in ICON_FILES.values():
|
||||
hass.http.register_static_path(
|
||||
f"/{DOMAIN}/{f}",
|
||||
hass.config.path(f"custom_components/{DOMAIN}/data/{f}"),
|
||||
True
|
||||
)
|
||||
conf = config.get(DOMAIN)
|
||||
if not conf:
|
||||
return True
|
||||
register_modules(hass, conf)
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry):
|
||||
config_entry.add_update_listener(_update_listener)
|
||||
register_modules(hass, config_entry.options)
|
||||
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, config_entry.options)
|
||||
return True
|
||||
|
||||
|
||||
def register_modules(hass, modules):
|
||||
if DATA_EXTRA_MODULE_URL not in hass.data:
|
||||
hass.data[DATA_EXTRA_MODULE_URL] = set()
|
||||
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] is not False:
|
||||
url_set.add(ICONS_URL+v)
|
||||
Plik binarny nie jest wyświetlany.
49
custom_components/fontawesome/config_flow.py
Normal file
49
custom_components/fontawesome/config_flow.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import logging
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.core import callback
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@config_entries.HANDLERS.register("fontawesome")
|
||||
class FontawesomeConfigFlow(config_entries.ConfigFlow):
|
||||
async def async_step_user(self, user_input=None):
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
return self.async_create_entry(title="", data={})
|
||||
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(config_entry):
|
||||
return FontawesomeEditFlow(config_entry)
|
||||
|
||||
|
||||
class FontawesomeEditFlow(config_entries.OptionsFlow):
|
||||
def __init__(self, config_entry):
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(self, user_input=None):
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="init",
|
||||
data_schema=vol.Schema(
|
||||
{
|
||||
vol.Optional(
|
||||
"regular",
|
||||
default=self.config_entry.options.get("regular", False),
|
||||
): bool,
|
||||
vol.Optional(
|
||||
"solid",
|
||||
default=self.config_entry.options.get("solid", False),
|
||||
): bool,
|
||||
vol.Optional(
|
||||
"brands",
|
||||
default=self.config_entry.options.get("brands", False),
|
||||
): bool,
|
||||
}
|
||||
)
|
||||
)
|
||||
1
custom_components/fontawesome/data/fab.js
Normal file
1
custom_components/fontawesome/data/fab.js
Normal file
File diff suppressed because one or more lines are too long
1
custom_components/fontawesome/data/far.js
Normal file
1
custom_components/fontawesome/data/far.js
Normal file
File diff suppressed because one or more lines are too long
1
custom_components/fontawesome/data/fas.js
Normal file
1
custom_components/fontawesome/data/fas.js
Normal file
File diff suppressed because one or more lines are too long
9
custom_components/fontawesome/manifest.json
Normal file
9
custom_components/fontawesome/manifest.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"domain": "fontawesome",
|
||||
"name": "Fontawesome icons",
|
||||
"documentation": "",
|
||||
"dependencies": ["frontend"],
|
||||
"codeowners": [],
|
||||
"requirements": [],
|
||||
"config_flow": true
|
||||
}
|
||||
21
custom_components/fontawesome/translations/en.json
Normal file
21
custom_components/fontawesome/translations/en.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"config": {
|
||||
"title": "FontAwesome",
|
||||
"abort": {
|
||||
"single_instance_allowed": "Only a single configuration of FontAwesome is allowed."
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"step": {
|
||||
"init": {
|
||||
"title": "Icon sets",
|
||||
"description": "Which icon sets to include",
|
||||
"data": {
|
||||
"regular": "Include Regular icons (far:)",
|
||||
"solid": "Include Solid icons (fas:)",
|
||||
"brands": "Include Brand icons (fab:)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user