Adding values of different entities

Hello all. I have a solar system with multiple (3) SMA inverters. I have a card showing the output of each, but I wanted to create a 4 display for total, or even a glance card on its own for total of the three inverters. How would I do this in lovelace glance card for example? This is what I have now for each of them:

type: glance
entities:
  - entity: sensor.pv_power1
    icon: 'mdi:solar-power'
    name: Inverter 1
  - entity: sensor.pv_power2
    icon: 'mdi:solar-power'
    name: Inverter 2
  - entity: sensor.pv_power3
    icon: 'mdi:solar-power'
    name: Inverter 3
title: Solar System Output

Create a template sensor to add them together and then add that new senor to your UI same as you did the other 3. Template sensor example below.

sensor:
  - platform: template
    sensors:
      solar_power_total:
        friendly_name: "Total Solar Power"
        unit_of_measurement: 'W'
        value_template: "{{(states('sensor.pv_power1')|float) + (states('sensor.pv_power2')|float) + (states('sensor.pv_power3')|float)}}"
1 Like

Wow, that was fast. That makes total sense but since I’m a newbie at this I never went down that route. Looks good.

Wait it has an error, mapping values not allowed in here (config.yaml). It doesn’t like template

Sorry, OK now. It was an indentation issue when I copied and pasted. The little things get you.

YAML can be the death of a thousand cuts. A good text editor really helps. The VScode addon will alert you of a lot of errors and is pretty good at showing spacing. It also autocompletes entity IDs and some other nice tricks.

If you don’t run hassio or just want it on another computer you can add it to any vscode instance

https://marketplace.visualstudio.com/items?itemName=keesschollaart.vscode-home-assistant

Thanks, I’m using the addon that lets you edit it right from the webpage. Seems OK for now.

Hi,

I finally did manage to get no errors in de configuration.yaml and am able to output the variable in a sensor on the dashboard. However the sum doesn’t sum up the two sensor values and just writes down the first of the two sensor values instead of adding them up. Can someone shed a light on this?

sensor:
  - platform: template
    sensors:
        energie_opbrengst_totaal:
            friendly_name: "Energie Opbrengst (totaal)"
            unit_of_measurement: 'kWh'
            value_template: '{{ states("sensor.solaredge_current_power") | float + states("entity:sensor.solaredge_woonhuis_current_power") | float }}'
  - platform: template
    sensors:
        energie_opbrengst_garage:
            friendly_name: "Energie Opbrengst (garage)"
            unit_of_measurement: 'kWh'
            value_template: '{{ states("sensor.solaredge_current_power") | float }}'
  - platform: template
    sensors:
        energie_opbrengst_woonhuis:
            friendly_name: "Energie Opbrengst (woonhuis)"
            unit_of_measurement: 'kWh'
            value_template: '{{ states("sensor.solaredge_current_power") | float }}'

1 Like
states("entity:sensor.solaredge_woonhuis_current_power")
        ^^^^^^^
       Remove this.
1 Like