implement new cardpower format

This commit is contained in:
joBr99
2023-01-30 21:17:28 +01:00
parent d6bcdddae6
commit ec97030cbc

View File

@@ -629,25 +629,14 @@ class LuiPagesGen(object):
def generate_power_page(self, navigation, heading, items):
command = f"entityUpd~{heading}~{navigation}"
for item in items:
command += self.generate_entities_item(item, "cardEntities")
speed = 0
if apis.ha_api.entity_exists(item.entityId):
entity = apis.ha_api.get_entity(item.entityId)
icon_color = self.get_entity_color(entity, overwrite=item.colorOverride)
icon = get_icon_ha(item.entityId, overwrite=item.iconOverride)
speed = 0
if float(entity.state) > 0:
speed = str(item.entity_input_config.get("speed", 1))
speed = apis.ha_api.render_template(speed)
unit = get_attr_safe(entity, "unit_of_measurement", "")
value = f"{entity.state} {unit}"
# Overwrite for value
ovalue = item.value
if ovalue is not None:
value = apis.ha_api.render_template(ovalue)
command += f"~{icon_color}~{icon}~{speed}~{value}"
elif item.entityId == "delete":
command += f"~~~~"
else:
command += f"~17299~{get_icon_id('mdi:alert-circle-outline')}~~"
command += f"~{speed}"
self._send_mqtt_msg(command)
def render_card(self, card, send_page_type=True):