Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95419

Calculate (sum) two entities to one sensor

$
0
0

@darryl12123 wrote:

Hello,

I’m brand new to HA and learning a lot in a short time. A lot of issues I could find on the forum, but there is one thing I couldn’t figure out.

The situation:

I have a smart energy meter for power and gas usage, which I can read with a P1 cable to my raspberry pi 4 where HA is running on. I got the readings working from the meter which is really nice. The meter works with two tariffs, low and high. Unfortunately sensor “total energy consumption” is coming in without a value. So in the front-end of HA I see now “total energy consumption tarif 1” and “total energy consumption tarif 2”. The additional I want is this two added up so I have the total energy consumption.

Now I started searching how to do this. I know I have to make a “sensor” in the configuration.yaml file. But the question is the coding, still a noob in this. So I need to sum two entities, the outcome will be the new sensor.

This is what I have so far:

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

I’ve tried different variants but I keep getting an error, propably because the code is wrong:

  • Error loading /config/configuration.yaml: mapping values are not allowed here in “/config/configuration.yaml”, line 43, column 26
  • Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘:’) for dictionary value @ data[‘sensors’][‘energie_verbruik_totaal’][‘value_template’]. Got ‘{{ entity:sensor.energy_consumption_tarif_1 + entity:sensor.energy_consumption_tarif_2 }}’. (See ?, line ?).

Could someone help me pointing the correct direction, that would be great!

Cheers, Darryl.

Posts: 7

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95419

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>