I have a rather simple need:
I would like to add three distinct svg files to the list of Icons that I can choose in the HA GUI when selecting an Entity-Icon.
For this, I have copied the files to /config/www:
ls -l /config/www/*.svg
-rwxrwxrwx 1 hassio hassio 689 Dec 3 23:07 /config/www/fts_window_1w.svg
-rwxrwxrwx 1 hassio hassio 1830 Dec 3 23:07 /config/www/fts_window_1w_open.svg
-rwxrwxrwx 1 hassio hassio 872 Dec 3 23:07 /config/www/fts_window_1w_tilt.svg
And I have restarted HA.
I would now expect to find these icons when scolling down the list of Icons of an Entity. But I do not.
I have set the debug level of the frontent to debug homeassistant.components.frontend: debug, but I see no related errors in the Log.
What am I doing wrong?
I understand that there is also entity_picture. But I would expect that the above should also work, shouldn’t it?
That’s not an addon, that’s an integration. You can use custom icons in custom fields if you know the HTML anywhere in the UI that supports html. If you want them specifically on your entity, you need to use the integration.
SVG files can change your view into the contained elements. Some SVG software adds bogus x/y offsets in the file which trip up the icons presented in HA.
If you use inkscape and export your svg file as SVG Optimized, it will remove all the extra fluff that’s not really needed. SVG Optimized is also best for websites because the files are smaller than regular SVGs.
Replaced the original svg file with an optimized one.
Restarted HA - but still a solid rectangle instead of a HA icon.
Cleared Chrome cache - now see this:
Seems to be a part of the icon.
The svg file contains
<svg width="500" height="500"
Shall I edit to 24px?
Believed that icons are fit automatically…
Anyway, is it normal to NOT fit svg icons to standard “–mdc-icon-size”?
Assume a person creates a card with increased STANDARD icons by changing “–mdc-icon-size” - and icons are properly resized.
So it is strange that custom icons should be initially resized first.
The “rectangle only” issue is simply due to the fact that your original image background is not processed and seen as an element of the image, rendered in the same color as the rest.
When I started with HA, I combed the HA forum for solutions, tried a number of tools, but didn’t find anything simple and efficient. Maybe I missed something but after further research on the web, I ended up trying Adobe Illustrator, which is by far the most efficient way I found to process and add your own icons in HA.
No need to resize to a specific height/width, you just load your image, trace, ungroup, clean and save as SVG.
Literally took me 2min to process your image.
Give it a try if you have access to a license. Works like a charm.
This is unclear for me.
The “rectangle” icon was displayed before a so-called “optimization” performed by this tool.
Then I saw only an image which seems to be a top-left corner of the icon - and this could be explained by “target box = 24х24, source svg = 500x500”.
As for a particular SW like Adobe Illustrator - thanks for the advice, but what I need is an understanding of the issue.
Even after a manual edit of SVG file
I still see after HA reboot & clearing a browser cache
The SVG file contains a path.
I believed that this path is defined in relative coordinates - i.e. no need to edit the path for a different viewport.
Will keep an eye on the thread as I’d also be interested to better understand where the issue comes from.
It’s a personal preference, but the reason I chose to go the Illustrator route was to avoid all of the 3rd party optimization, image size concerns, path edition, etc…
Take an image you like and convert it with one piece of software. no coding. WYSIWYG. period.
Managing custom svg icons / vector images shouldn’t be more difficult than managing png’ , jpg’ or gif’ and that’s what I get with Illustrator.
Always open to better ways to do things so will be watching
Which is working well as it is in… that Visualization Software. It is equally displayed in a browser.
I am happy to use one software (e.g. Inkscape) to convert it. But what do I need to change?