diff --git a/README.md b/README.md
index 6d840f36f..c83a8de43 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
Material Symbols for Home Assistant
-**Material Symbols for Home Assistant** is a collection of 13,616 Google Material Symbols for use within Home Assistant. It uses the icon-set produced and maintained by [iconify](https://github.com/iconify/icon-sets).
+**Material Symbols for Home Assistant** is a collection of 13,693 Google Material Symbols for use within Home Assistant. It uses the icon-set produced and maintained by [iconify](https://github.com/iconify/icon-sets).
There is a [Icon Finder Tool](https://beecho01.github.io/material-symbols-iconfinder/) to help you select the correct icon. Simply type in what you're looking for, click the icon of choice, and the icon entry for home assistant will be copied to your clipboard (e.g., `m3o:light`). The copied text can be pasted for use in your YAML configuration or into you UI frontend interface.
@@ -17,7 +17,7 @@ There is a [Icon Finder Tool](https://beecho01.github.io/material-symbols-iconfi
> ### Breaking Changes
> - **Repository Structure**: The repository and installation have transitioned from a "Lovelace" repository (v1.X.X) to an "Integration" repository (202X.X.X+). Users should reinstall from the new integration repository to avoid compatibility issues.
> - **Icon Prefix Migration**: The icon prefix has transitioned from m3s, which previously contained all icon styles, to individual prefixes based on style. Each style now has its unique prefix (e.g., m3o for outlined, m3r for rounded). Refer to the documentation for the complete list of prefixes.
-> - **Reduction in Available Icons**: The number of available icons has been reduced from ~18,600 to 13,616.
+> - **Reduction in Available Icons**: The number of available icons has been reduced from ~18,600 to 13,693.
---
diff --git a/custom_components/material_symbols/__init__.py b/custom_components/material_symbols/__init__.py
index 0f6ddb131..7ef1128fd 100644
--- a/custom_components/material_symbols/__init__.py
+++ b/custom_components/material_symbols/__init__.py
@@ -1,40 +1,67 @@
import logging
+import json
+from os import path, walk
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.components.frontend import add_extra_js_url
from homeassistant.components.http import StaticPathConfig
+from homeassistant.components.http.view import HomeAssistantView
LOGGER = logging.getLogger(__name__)
+NAME = "Material Symbols"
DOMAIN = "material_symbols"
-VERSION = "2024.11.17"
+VERSION = "2024.11.22-b1"
-DATA_EXTRA_MODULE_URL = "frontend_extra_module_url"
-LOADER_URL = f"/{DOMAIN}/material_symbols.js"
-LOADER_PATH = f"custom_components/{DOMAIN}/material_symbols.js"
ICONS_URL = f"/{DOMAIN}"
+LOADER_URL = f"/{DOMAIN}/material_symbols.js"
ICONS_PATH = f"custom_components/{DOMAIN}/data"
+LOADER_PATH = f"custom_components/{DOMAIN}/material_symbols.js"
+
+class ListingView(HomeAssistantView):
+
+ requires_auth = False
+
+ def __init__(self, url, iconset_path, hass, iconset_prefix):
+ self.url = url
+ self.name = f"api:{DOMAIN}:icons:{iconset_prefix}"
+ self.iconset_path = iconset_path
+ self.hass = hass
+
+ async def get(self, request):
+ icons_list = await self.hass.async_add_executor_job(
+ self.get_icons_list, self.iconset_path
+ )
+ return self.json(icons_list)
+
+ def get_icons_list(self, iconset_path):
+ icons = []
+ for dirpath, dirnames, filenames in walk(iconset_path):
+ relative_dir = path.relpath(dirpath, iconset_path)
+ for fn in filenames:
+ if fn.endswith(".svg"):
+ icon_name = path.join(relative_dir, fn[:-4]).replace(path.sep, '/')
+ icons.append({"name": icon_name})
+ return icons
async def async_setup(hass: HomeAssistant, config):
- # Register the JS loader file
await hass.http.async_register_static_paths(
[StaticPathConfig(LOADER_URL, hass.config.path(LOADER_PATH), True)]
)
add_extra_js_url(hass, LOADER_URL)
- # Define icon set folders and register their static paths
iconset_prefixes = ["m3o", "m3of", "m3r", "m3rf", "m3s", "m3sf"]
for iconset_prefix in iconset_prefixes:
+ icons_url = f"{ICONS_URL}/{iconset_prefix}"
+ icons_path = hass.config.path(f"{ICONS_PATH}/{iconset_prefix}")
+ icons_list_url = f"{icons_url}/icons.json"
+
await hass.http.async_register_static_paths(
- [
- StaticPathConfig(
- f"{ICONS_URL}/{iconset_prefix}",
- hass.config.path(f"{ICONS_PATH}/{iconset_prefix}"),
- True,
- )
- ]
+ [StaticPathConfig(icons_url, icons_path, True)]
+ )
+ hass.http.register_view(
+ ListingView(icons_list_url, icons_path, hass, iconset_prefix)
)
-
return True
async def async_setup_entry(hass, entry):
@@ -51,5 +78,5 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry,
title="Material Symbols"
)
- LOGGER.info("Migrating Material Symbols config entry.")
+ LOGGER.info("Migrated Material Symbols config entry to version 2.")
return True
\ No newline at end of file
diff --git a/custom_components/material_symbols/config_flow.py b/custom_components/material_symbols/config_flow.py
index 7cff9c067..52bace3f0 100644
--- a/custom_components/material_symbols/config_flow.py
+++ b/custom_components/material_symbols/config_flow.py
@@ -2,7 +2,7 @@
from homeassistant import config_entries
-_LOGGER = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
DOMAIN = "material_symbols"
diff --git a/custom_components/material_symbols/manifest.json b/custom_components/material_symbols/manifest.json
index 9db80faad..0069c05db 100644
--- a/custom_components/material_symbols/manifest.json
+++ b/custom_components/material_symbols/manifest.json
@@ -8,5 +8,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/beecho01/material-symbols/issues",
"requirements": [],
- "version": "2024.11.17"
+ "version": "2024.11.22-b1"
}
\ No newline at end of file
diff --git a/custom_components/material_symbols/material_symbols.js b/custom_components/material_symbols/material_symbols.js
index d6bec7f61..145b8b61a 100644
--- a/custom_components/material_symbols/material_symbols.js
+++ b/custom_components/material_symbols/material_symbols.js
@@ -111,9 +111,9 @@
});
console.info(
- "%c MATERIAL SYMBOLS %c %c 2024.11.17 ",
+ "%c MATERIAL SYMBOLS %c %c 2024.11.22-b1 ",
'@import url("https://fonts.googleapis.com/css2?family=Roboto");background-color:#1FBEF2;color:#FFFFFF;padding:3px 43px 2px 8px;border-radius:999vh;border:5px solid #1FBEF2;font-family:"Roboto", sans-serif;margin-top:18px',
'@import url("https://fonts.googleapis.com/css2?family=Roboto");background-color:#FFFFFF;color:#1FBEF2;padding:3px 8px 2px 0;border-radius:999vh 0 0 999vh;border:0;font-family:"Roboto", sans-serif;margin-left:-94px',
'@import url("https://fonts.googleapis.com/css2?family=Roboto");background-color:#FFFFFF;color:#1FBEF2;padding:3px 9px 2px 0;border-radius:0 999vh 999vh 0;border:0;font-family:"Roboto", sans-serif;margin-left:-1px;margin-bottom:18px'
);
-})();
+})();
\ No newline at end of file