This commit is contained in:
Johannes Braun
2023-01-14 15:14:11 +01:00
parent a8c32c3542
commit f38eb9923c
3 changed files with 65 additions and 9 deletions

View File

@@ -631,15 +631,20 @@ class LuiPagesGen(object):
def generate_power_page(self, navigation, heading, items):
command = f"entityUpd~{heading}~{navigation}"
for item in items:
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", "")
command += f"~{icon_color}~{icon}~{speed}~{entity.state} {unit}"
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", "")
command += f"~{icon_color}~{icon}~{speed}~{entity.state} {unit}"
elif item.entityId == "delete":
command += f"~~~~"
else:
command += f"~17299~{get_icon_id('mdi:alert-circle-outline')}~~"
self._send_mqtt_msg(command)
def render_card(self, card, send_page_type=True):