implement ha: alias for icons #464 (#492)

implements a new icon type that can be used to display home assistant templates
This commit is contained in:
joBr99
2022-10-01 00:10:01 +02:00
committed by GitHub
parent 32e58e5fe3
commit f70ffa168c
5 changed files with 42 additions and 24 deletions

View File

@@ -18,7 +18,12 @@ with open(os.path.join(__location__, "../../../apps/nspanel-lovelace-ui/luibacke
f.write(f" '{name}': '{iconchar}',\n")
f.write("}\n")
f.write("""
import apis
def get_icon_id(ma_name):
if "text:" in ma_name:
return ma_name.replace("text:","")
if "ha:" in ma_name:
return apis.ha_api.render_template(ma_name.replace("ha:",""))
ma_name = ma_name.replace("mdi:","")
if ma_name in icons:
return icons[ma_name]