mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-18 19:06:58 +01:00
fixes #867
This commit is contained in:
@@ -6900,15 +6900,19 @@ icons = {
|
|||||||
import apis
|
import apis
|
||||||
|
|
||||||
def get_icon_id(ma_name):
|
def get_icon_id(ma_name):
|
||||||
|
if isinstance(ma_name, re.Match):
|
||||||
|
ma_name = ma_name.group(0).replace('<I>', '').replace('</I>', '')
|
||||||
|
|
||||||
if "text:" in ma_name:
|
if "text:" in ma_name:
|
||||||
return ma_name.replace("text:","")
|
return ma_name.replace("text:","")
|
||||||
if "ha:" in ma_name:
|
if "ha:" in ma_name:
|
||||||
splitted_string = ma_name.replace("ha:","").rpartition('}')
|
splitted_string = ma_name.replace("ha:","").rpartition('}')
|
||||||
template_string = f"{splitted_string[0]}{splitted_string[1]}"
|
template_string = f"{splitted_string[0]}{splitted_string[1]}"
|
||||||
templates_result = apis.ha_api.render_template(template_string)
|
templates_result = apis.ha_api.render_template(template_string)
|
||||||
|
if isinstance(templates_result, str):
|
||||||
|
templates_result = re.sub(r"<I>.+?<\/I>", get_icon_id, templates_result)
|
||||||
return f"{templates_result}{splitted_string[2]}"
|
return f"{templates_result}{splitted_string[2]}"
|
||||||
if "ha-i:" in ma_name:
|
|
||||||
ma_name = apis.ha_api.render_template(ma_name.replace("ha-i:",""))
|
|
||||||
ma_name = ma_name.replace("mdi:","")
|
ma_name = ma_name.replace("mdi:","")
|
||||||
if ma_name in icons:
|
if ma_name in icons:
|
||||||
return icons[ma_name]
|
return icons[ma_name]
|
||||||
|
|||||||
Reference in New Issue
Block a user