How can i create new entities based on two other entities

Hello, i want to know how much power produces two Solar Inverter - so i have two entitites:

  • SN: 3013071145 daily_yield
  • SN: 3013937245 daily_yield

How can i create a new entities with added the two values.

Thank a lot for your help.

Create a Min/Max Helper to add the values of the two entities.

Go to Settings > Devices & Services > Helpers > Create Helper.

Select Min/Max.

For Statistic Characteristic select Sum.

Pick your two sensor entities, provide a name, etc, click Submit.

1 Like

Cool, this works well :).

Thanks a lot for your help.

1 Like

@123: One other question, is it possible to calculate more? The value works well - but is in Watt, i need it in Kilowatt (e.g. EntA + EntB = SUM/1000). Is this possible?

Thanks a lot again for help :).

It’s possible but not with a Helper.

Create a Template Sensor with the following configuration (replace the example’s entity names with your own):

template:
  - sensor:
      - name: Total Solar Power
        state: "{{ (states('sensor.ent_a') | float(0) + states('sensor.ent_b') | float(0)) / 1000 }}"
        unit_of_measurement: 'kW'
3 Likes

@123 : Thanks a lot - sounds good, i try this.

Ups, where i have to create the template sensor?!?

Thanks a lot for your help.

Look at the contents of your configuration.yaml file.

If it does not contain a template: key then simply copy-paste the example into it. Save the file and then go to Developer Tools > YAML and run Check Configuration. If it reports no errors, run Reload Template Entities. The sensor should then appear in Developer Tools > States.

If the file does contain a template: key, the installation instructions will be different and will depend on what is already present in or under the key. Let me know if that’s the case.

@123 : Thanks again for your fast reply.

Thats what i have tested (copy to the bottom of the file) - configuration check gives me an error, but now it works fine.

But how can i use this now, did i have to create a new entitie and add the template to this, or did i have now a new enttitie with the name Total Solar Power?

I’m sorry for my questions, but i’m new to HA and this is totaly other in the configuration then my old System.

Thanks for your help and understanding :).

If it reported an error what did you do to fix it?

The error comes at a first try and checking the config with the developer tools. After a second try it works well and service restartet without error.

But i don’t know how i can show the template or the value from the templater.

Go to Developer Tools > States and search for sensor.total_solar_power (or whatever is the name that you called the sensor).

1 Like

Cool, now it works.

Thanks a lot for your help again :).

1 Like

@123 : Hi, i got a question - i didn’t finde samples on Web. Is it possible to create multiple sensor - and if yes, how is the format?

This is not accepted:

Template:
  - sensor:
      - name: Total Solar Power
        state: "{{ (states('sensor.ent_a') | float(0) + states('sensor.ent_b') | float(0)) / 1000 }}"
        unit_of_measurement: 'kW'
      - name: StringA in KW
        state: "{{ (states('sensor.ent_a') | float(0) / 1000 }}"
        unit_of_measurement: 'kW'
      - name: StringB in KW
        state: "{{ (sstates('sensor.ent_b') | float(0)) / 1000 }}"
        unit_of_measurement: 'kW'

Can you please help me?

Change this line:

Template:

to this:

template:

Other than that, there’s nothing wrong with the rest of it, except for the sstates in the third sensor’s template. It should be states not sstates.

@123 : Hi, maybe you (or someone other) can help me - i have this in my configuration.yaml:

template:
    - sensor:
      - name: pv_beide_strings
        state: "{{ (states('sensor.sn_3013071145_grid_power') | float(0) + states('sensor.sn_3013937245_grid_power') | float(0))}}"
        unit_of_measurement: 'W'
      - name: pv_wr_link_grid_kw
        state: "{{ (states('sensor.sn_3013071145_grid_power') | float(0) /1000)}}"
        unit_of_measurement: 'kWh'
      - name: pv_wr_rechts_grid_kw
        state: "{{ (states('sensor.sn_3013937245_grid_power') | float(0) /1000)}}"
        unit_of_measurement: 'kWh'

The Restart of the Service works without any error - but i could find the new entitites (search at devices and entitites), and can not add this to an card.

Whats the error? How can i solve them?!?

Thanks for any help.

Check the log for errors.

Also, check if you already have this line in your configuration.yaml file:

template: !include templates.yaml

Thanks a lot Taras, never knew this was possible with HA. Works great the sum

I just created a community account to Thank You ! Works great.

1 Like

Why are people using a template when this is so simple to set up as a Helper.

I use the “Group” helper with the “sum” type to group/add up multiple power monitor sensors to output a new “total-power-usage” sensor - All in the GUI very simple.