Hi,
Still learning after years of HA. Getting deeper into templating. Would some of you mind taking a look at the code I came up with for summing up all current power consumption in the house for any entity labeled Power
and with a device class of power
? Can this be further shortened?
Here we go:
{{ expand(label_entities(label_id('Power')))
|rejectattr('state', 'in', ['unavailable','unknown'])
|selectattr('attributes.device_class', 'eq', 'power')
|map(attribute='state')
|map('float')
|list
|sum
|round(0)
}} W
As a followup to that logic, I don’t assume any UI cards (other than markup) allow for label based selection of entities to be included or listed - would be so powerful to select entities by label - like automations can.
Any help is very much appreciated!