-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f62e87e
Showing
16 changed files
with
4,335 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
custom_components/**/*.js binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
**/__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Tom Schneider | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# hass-simpleicons | ||
|
||
[](https://github.com/custom-components/hacs) | ||
|
||
Use free icons from the [simpleicons](https://simpleicons.com) set in Home Assistant. | ||
|
||
## Installation instructions | ||
|
||
- Install using [HACS](https://hacs.xyz) (Or copy the contents of `custom_components/simpleicons/` to `<your config dir>/custom_components/simpleicons/`.) | ||
|
||
- Restart Home Assistant | ||
|
||
- Go to your integrations configuration and add simpleicons | ||
|
||
## Usage | ||
|
||
Find the icon you want in the [gallery](http://simpleicons.org/). Click on an icon. This will download the icon. You don't need that file, just it's filename. | ||
|
||
The icon set is prefixed by: `si:`. Then comes the filename. | ||
|
||
So, | ||
|
||
- to get a facebook logo, use `si:facebook` | ||
- to get a zigbee logo, use `si:zigbee` | ||
- and so on | ||
|
||
The icons are useable anywhere in Home Assistant - not only in lovelace. | ||
|
||
## FAQ | ||
|
||
### Can I set this up in configure.yaml instead? | ||
|
||
Yes. | ||
|
||
```yaml | ||
simpleicons: | ||
``` | ||
## Special thanks | ||
This work is heavily based on [hass-fontawesome](https://github.com/thomasloven/hass-fontawesome) by Thomas Loven. Thank you! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"config": { | ||
"title": "Simple Icons", | ||
"abort": { | ||
"single_instance_allowed": "Es ist nur eine Instanz von Simple Icons erlaubt." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"config": { | ||
"title": "Simple Icons", | ||
"abort": { | ||
"single_instance_allowed": "Only a single configuration of simpleicons is allowed." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import homeassistant.components.frontend | ||
from homeassistant.components.frontend import _frontend_root | ||
|
||
from .custom_component_server import setup_view | ||
|
||
DOMAIN = "simpleicons" | ||
|
||
DATA_EXTRA_MODULE_URL = 'frontend_extra_module_url' | ||
ICONS_URL = '/'+DOMAIN+'/data/' | ||
ICON_FILES = { | ||
'simpleicons': 'si.js' | ||
} | ||
|
||
async def async_setup(hass, config): | ||
setup_view(hass, DOMAIN) | ||
conf = config.get(DOMAIN) | ||
if not conf: | ||
return True | ||
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() | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import logging | ||
import voluptuous as vol | ||
|
||
from homeassistant import config_entries | ||
from homeassistant.core import callback | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
@config_entries.HANDLERS.register("simpleicons") | ||
class simpleiconsConfigFlow(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={}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from aiohttp import web | ||
from homeassistant.components.http import HomeAssistantView | ||
import os.path | ||
|
||
def setup_view(hass, name): | ||
hass.http.register_view(CustomComponentServer(hass, name)) | ||
|
||
class CustomComponentServer(HomeAssistantView): | ||
|
||
requires_auth = False | ||
|
||
def __init__(self, hass, domain): | ||
self.name = domain+"_server" | ||
self.url = '/'+domain+'/{filename:.*}' | ||
self.config_dir = hass.config.path() | ||
self.domain = domain | ||
|
||
async def get(self, request, filename): | ||
path = os.path.join(self.config_dir, 'custom_components', self.domain, filename) | ||
filecontent = "" | ||
|
||
try: | ||
with open(path, mode="r", encoding="utf-8", errors="ignore") as localfile: | ||
filecontent = localfile.read() | ||
localfile.close() | ||
except Exception as exception: | ||
return web.Response(status=404) | ||
|
||
return web.Response(body=filecontent, content_type="text/javascript", charset="utf-8") |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"domain": "simpleicons", | ||
"name": "Simple Icons", | ||
"documentation": "", | ||
"dependencies": ["frontend"], | ||
"codeowners": [], | ||
"requirements": [], | ||
"config_flow": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "simpleicons", | ||
"render_readme": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const simpleIcons = require('simple-icons'); | ||
|
||
|
||
var x = 2 | ||
|
||
var svg = "<svg><defs>"; | ||
|
||
for(var icon of Object.entries(simpleIcons)) { | ||
var path = icon[1].path; | ||
var slug = icon[1].slug; | ||
|
||
var g = "<g id=\"" + slug + "\" viewBox=\"-1 -1 26 26\"><path d=\"" + path + "\"/></g>"; | ||
svg += g; | ||
} | ||
|
||
svg += "</defs></svg>" | ||
|
||
const iconset = document.createElement("ha-iconset-svg"); | ||
iconset.name="si"; | ||
iconset.size=1024; | ||
iconset.innerHTML = svg; | ||
document.body.appendChild(iconset); |
Oops, something went wrong.