This commit is contained in:
Johannes Braun
2023-01-22 14:19:18 +01:00
parent e3c9f10f7c
commit 4a07637018
2 changed files with 15 additions and 6 deletions

View File

@@ -24,6 +24,7 @@ class Entity(object):
self.condTemplate = entity_input_config.get("state_template") self.condTemplate = entity_input_config.get("state_template")
self.assumedState = entity_input_config.get("assumed_state", False) self.assumedState = entity_input_config.get("assumed_state", False)
self.stype = entity_input_config.get("type") self.stype = entity_input_config.get("type")
self.value = entity_input_config.get("value")
self.data = entity_input_config.get("data", {}) self.data = entity_input_config.get("data", {})
self.entity_input_config = entity_input_config self.entity_input_config = entity_input_config
@@ -243,3 +244,4 @@ class LuiBackendConfig(object):
def get_card_by_uuid(self, uuid): def get_card_by_uuid(self, uuid):
return self._config_card_table.get(uuid) return self._config_card_table.get(uuid)

View File

@@ -162,6 +162,11 @@ class LuiPagesGen(object):
colorOverride = item.colorOverride colorOverride = item.colorOverride
name = item.nameOverride name = item.nameOverride
uuid = item.uuid uuid = item.uuid
# check ha template for name
if item.nameOverride is not None and ("{" in item.nameOverride and "}" in item.nameOverride):
name = apis.ha_api.render_template(item.nameOverride)
# type of the item is the string before the "." in the entityId # type of the item is the string before the "." in the entityId
entityType = entityId.split(".")[0] entityType = entityId.split(".")[0]
@@ -296,9 +301,6 @@ class LuiPagesGen(object):
elif entityType == "script": elif entityType == "script":
entityTypePanel = "button" entityTypePanel = "button"
value = get_translation(self._locale, "frontend.ui.card.script.run") value = get_translation(self._locale, "frontend.ui.card.script.run")
override = item.entity_input_config.get("action_name")
if override is not None:
value = override
elif entityType == "lock": elif entityType == "lock":
entityTypePanel = "button" entityTypePanel = "button"
value = get_translation(self._locale, "frontend.ui.card.lock.lock") if entity.state == "unlocked" else get_translation(self._locale, "frontend.ui.card.lock.unlock") value = get_translation(self._locale, "frontend.ui.card.lock.lock") if entity.state == "unlocked" else get_translation(self._locale, "frontend.ui.card.lock.unlock")
@@ -349,10 +351,11 @@ class LuiPagesGen(object):
if type(item.stype) == int and len(entity.attributes.forecast) >= item.stype: if type(item.stype) == int and len(entity.attributes.forecast) >= item.stype:
fdate = dp.parse(entity.attributes.forecast[item.stype]['datetime']).astimezone() fdate = dp.parse(entity.attributes.forecast[item.stype]['datetime']).astimezone()
global babel_spec global babel_spec
if babel_spec is not None: dateformat = "E" if item.nameOverride is None else item.nameOverride
name = babel.dates.format_date(fdate, "E", locale=self._locale) name = babel.dates.format_date(fdate, dateformat, locale=self._locale)
else: else:
name = fdate.strftime('%a') dateformat = "%a" if item.nameOverride is None else item.nameOverride
name = fdate.strftime(dateformat)
icon_id = get_icon_ha(entityId, stateOverwrite=entity.attributes.forecast[item.stype]['condition']) icon_id = get_icon_ha(entityId, stateOverwrite=entity.attributes.forecast[item.stype]['condition'])
value = f'{entity.attributes.forecast[item.stype].get("temperature", "")}{unit}' value = f'{entity.attributes.forecast[item.stype].get("temperature", "")}{unit}'
color = self.get_entity_color(entity, ha_type=entityType, stateOverwrite=entity.attributes.forecast[item.stype]['condition'], overwrite=colorOverride) color = self.get_entity_color(entity, ha_type=entityType, stateOverwrite=entity.attributes.forecast[item.stype]['condition'], overwrite=colorOverride)
@@ -360,6 +363,10 @@ class LuiPagesGen(object):
value = f'{get_attr_safe(entity, "temperature", "")}{unit}' value = f'{get_attr_safe(entity, "temperature", "")}{unit}'
else: else:
name = "unsupported" name = "unsupported"
# Overwrite for value
ovalue = item.value
if ovalue is not None:
value = apis.ha_api.render_template(ovalue)
return f"~{entityTypePanel}~{entityId}~{icon_id}~{color}~{name}~{value}" return f"~{entityTypePanel}~{entityId}~{icon_id}~{color}~{name}~{value}"
def generate_entities_page(self, navigation, heading, items, cardType, tempUnit): def generate_entities_page(self, navigation, heading, items, cardType, tempUnit):