Update HA, add vacuum, grid cards, fixes

This commit is contained in:
Florian Brinker
2021-03-21 18:41:41 +01:00
rodzic 53c99e4509
commit fb3af71fe3
122 zmienionych plików z 12940 dodań i 1532 usunięć

Wyświetl plik

@@ -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.

Wyświetl plik

@@ -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,
}
)
)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Wyświetl plik

@@ -0,0 +1,9 @@
{
"domain": "fontawesome",
"name": "Fontawesome icons",
"documentation": "",
"dependencies": ["frontend"],
"codeowners": [],
"requirements": [],
"config_flow": true
}

Wyświetl plik

@@ -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:)"
}
}
}
}
}