Use helper to create graph for combined entities

Hi all,

I would like to combine the Active power readings from my 2 aqara power plugs so they can be implemented in the graph card in my dashboard.

The 2 entities are summed through a template in Automations and I was pointed in the direction of using a helper. As I haven’t used Yaml/helpers before I’m unsure on what my next step should be.

I would assume the helper will help me store legacy readings which in turn allows me to make the graph ?

What does this mean exactly? If you are using an automation with a template to sum them, what do you do with them then…?

From what you have posted, it seems you need a Template sensor not a helper.

How would I do that if you don’t mind me asking?

I’ve made a template with the following:

  - sensor:
      - name: "Energy consumption"
        unit_of_measurement: "W"
        state: >
          {% set study = states('sensor.lumi_lumi_plug_maeu01_active_power_2') | float %}
          {% set livingroom = states('sensor.lumi_lumi_plug_maeu01_active_power') | float %}

          {{ ((study + livingroom*) / 2) | round(1, default=0) }}

I’m not sure if it’s correct, but saved it under config/Power_consumption. The two entities I’d like to sum are Äctive_power 1 & 2. I’m not fully sure what the "set study & "“set Livingroom” do as I took it from the example article you linked. I assumed those were the zones.

I would setup the last part slightly differently, but you should make sure to at least set defaults for your float() filters and set state_class: measurement so that your data is graph-able.

Also, you must have a : after “template”.

  - sensor:
      - name: "Energy consumption"
        state_class: measurement
        unit_of_measurement: "W"
        state: >
          {% set study = states('sensor.lumi_lumi_plug_maeu01_active_power_2') | float(0) %}
          {% set livingroom = states('sensor.lumi_lumi_plug_maeu01_active_power') | float(0) %}
          {{ (study, livingroom) | average | round (1,0) }}