This commit is contained in:
joBr99
2023-01-14 15:14:11 +01:00
parent ebe1d82924
commit c177e2d639
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):

51
docs/card-power.md Normal file
View File

@@ -0,0 +1,51 @@
# Power Card (v3.9 and higher)
![card-power](img/card-power.png)
```yaml
cards:
- type: cardPower
title: Power Test
entities:
- entity: sensor.today_energy
- entity: delete
- entity: sensor.today_energy
speed: 3
- entity: sensor.today_energy
speed: -1
- entity: sensor.today_energy
speed: -2
- entity: sensor.today_energy
speed: -3
- entity: sensor.today_energy
speed: 1
- entity: sensor.today_energy
speed: 1
```
The first two entities are shown in the middle of the card, all other entities are used around it.
List of supported config keys of this card:
key | optional | type | default | description
-- | -- | -- | -- | --
`type` | False | string | `None` | Used by navigate items
`entities` | False | complex | `None` | contains entities of the card
`title` | True | string | `None` | Title of the Page
`key` | True | string | `None` | Used by navigate items
List of supported entitiy types for this page:
- sensor
Some details about speed:
It is possible to calculate the speed though home assistant templates, this allows to link the speed to something within your homeassistant.
If you got a proper configuration for that, feel free to share it, would be a good addition to the documentation.
```
- entity: sensor.today_energy
speed: '{{ range(-3, 3) | random }}'
```

BIN
docs/img/card-power.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB