I am no expert at all and the only thing that is preventing me from updating is the lack of time.
I remember the reason at that time for not doing the next update was that something changed in the handling of groups so I couldn´t use my groups anymore. I guess I should have dealt with it anyway
You need the entity_id
list with old template configurations to get updates automatically if you are piecing together strings to make the entity_id’s in the templates. The old templates used to search the template code for valid entity_id’s and automatically register listeners that way. When you dynamically find entity_d’s in a template, that functionality is lost. So you must list out the entities manually. This was changed early 2020. Templates now register entity_id’s without users needing to specify an ‘update list’, even when piecing together entity_id’s.
Thanks for clearing this up
I have following configuration to sum the power of my plugs:
group:
wohnzimmer_strom_sensors:
name: Group Wohnzimmer Power
icon: mdi:lightning-bolt
all: true
entities:
- sensor.computer_energy_power
- sensor.computer_peripherie_energy_power
- sensor.tasmota_energy_power
- sensor.tasmota_energy_power_3
- sensor.ventilator_power
sensor:
- platform: template
sensors:
wohnzimmer_gesamt_power:
unique_id: wohnzimmer_gesamt_power
device_class: power
friendly_name: "Stromverbrauch Wohnzimmer (aktuell)"
value_template: >-
{{ expand('group.wohnzimmer_strom_sensors') | map(attribute='state') | map('float') | list | sum }}
unit_of_measurement: "W"
- platform: integration
unique_id: kueche_gesamt_energy
name: "Stromverbrauch Wohnzimmer (total)"
source: sensor.wohnzimmer_gesamt_power
unit_prefix: k
method: left
round: 2
The configuration works well, but only if all sensors are available. If one device is not available (because I removed it) the result is shown as “unavailable”.
My question is, how do I have to configure it so that 0 is used for the device that is currently offline?
how about creating a label “Energy” and sum up the power of all the sensors with that label. That way there should not be a problem if the label (group) contains one sensor more or less?
I tried to achiev this by creating a helper → template sensor, but could not get it to work so far. Any suggestions?
{% set total = 0 %}
{% for entity in states | selectattr('attributes.label', 'eq', 'Energy') %}
{% if entity.state | float(-1) >= 0 %}
{% set total = total + entity.state | float %}
{% endif %}
{% endfor %}
{{ total | round(2) }}