This commit is contained in:
Johannes
2023-04-19 17:39:02 +02:00
committed by GitHub
parent d5aa040d05
commit 88874ea7b8

View File

@@ -6900,15 +6900,19 @@ icons = {
import apis
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:
return ma_name.replace("text:","")
if "ha:" in ma_name:
splitted_string = ma_name.replace("ha:","").rpartition('}')
template_string = f"{splitted_string[0]}{splitted_string[1]}"
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]}"
if "ha-i:" in ma_name:
ma_name = apis.ha_api.render_template(ma_name.replace("ha-i:",""))
ma_name = ma_name.replace("mdi:","")
if ma_name in icons:
return icons[ma_name]