Calculate (sum) two entities to one sensor

Hi @darryl12123 - what I do to debug these type of issues is to use the template editor under developer tools (You should see Developer Tools on the left hand side of Home Assistant UI). Then select Template from the tabs. Home Assistant uses Jinja2 templating. Then copy the value_template into the template editor window. On the right hand side you see the result of the templating code. If there is an error it will show up in red, explaining where you went wrong.

This worked for me:

{{ states("sensor.energy_consumption_tarif_1") |float + states("sensor.energy_consumption_tarif_2") | float }}

…it displayed 0.0 - as obviously I dont have those sensors.

sensor:
  - platform: template
    sensors:
        energie_verbruik_totaal:
            friendly_name: "Energie Verbruik (totaal)"
            unit_of_measurement: 'kWh'
            value_template: '{{ states("sensor.energy_consumption_tarif_1") |float + states("sensor.energy_consumption_tarif_2") | float }}'

HTH

5 Likes