Combine values of three sensor

Hi,
I’m new to Home assistant.
I need help to sum the values of sensor.
I have pzm004 for 3 phase. i have values of each phase and want to add the 3 phase consumption together.
Gone thru all the available documents but no luck.
the following are the entities to sum the values.
sensor.phase_1_energy_power, sensor.phase_2_energy_power, sensor.phase_3_energy_power

Thanks & Regards,

Aslam

How about something like the following:

value_template: “{{ states(‘sensor.phase_1_energy_power’) | float + states(‘sensor.phase_2_energy_power’) | float + states(‘sensor.phase_3_energy_power’) | float }}”

Hi Gumbo,
i have the following error,

Invalid config for [sensor.template]: invalid slug KSEB (try kseb) for dictionary value @ data[‘sensors’]. Got OrderedDict([(‘KSEB’, OrderedDict([(‘value_template’, ‘“{{ states(‘sensor.phase_1_energy_power’) | float + states(‘sensor.phase_2_energy_power’) | float + states(‘sensor.phase_3_energy_power’) | float }}”’), (‘entity_id’, ‘sensor.float’), (‘friendly_name’, ‘KSEB’), (‘unit_of_measurement’, ‘Watt’)]))]). (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/

my config is
sensor:

  • platform: template
    sensors:
    KSEB:
    value_template: “{{ states(‘sensor.phase_1_energy_power’) | float + states(‘sensor.phase_2_energy_power’) | float + states(‘sensor.phase_3_energy_power’) | float }}”
    entity_id: sensor.float
    friendly_name: ‘KSEB’
    unit_of_measurement: “Watt”

where is KSEB is mentioned as my electricity provider.

Thanks & Regards,

Aslam

Please format your pasted code correctly. See point 11: How to help us help you - or How to ask a good question

However from looking at your unformatted code and the error, this is the likely culprit:

Capital letters in the friendly name are ok but not for the sensor id/name

platform: template
  sensors:
    KSEB: ### <------- Change this to lower case letters
      value_template: "{{ states('sensor.phase_1_energy_power') | float + states('sensor.phase_2_energy_power') | float + states('sensor.phase_3_energy_power') | float }}"
      entity_id: 
        - sensor.phase_1_energy_power
        - sensor.phase_2_energy_power
        - sensor.phase_3_energy_power
      friendly_name: 'KSEB'
      unit_of_measurement: 'Watt'

Thanks Tom,
Again i have error

Configuration invalidCHECK CONFIG

Error loading /config/configuration.yaml: mapping values are not allowed here in “/config/configuration.yaml”, line 35, column 10
Please help

Thanks & Regards,

Aslam

it worked like a charm.
config:

sensor:
platform: template
sensors:
kseb:
value_template: “{{ states(‘sensor.phase_1_energy_power’) | float + states(‘sensor.phase_2_energy_power’) | float + states(‘sensor.phase_3_energy_power’) | float }}”
entity_id:
- sensor.phase_1_energy_power
- sensor.phase_2_energy_power
- sensor.phase_3_energy_power
friendly_name: ‘kseb’
unit_of_measurement: ‘Watt’

Thanks for the support.

Aslam

You have an indentation problem at the line specified (or one above/below it).

Post your properly formatted code if you can’t spot it.

Hi Tom,

Yep, it was. corrected as follows.
sensor:
platform: template
sensors:
kseb:
value_template: “{{ states(‘sensor.phase_1_energy_power’) | float + states(‘sensor.phase_2_energy_power’) | float + states(‘sensor.phase_3_energy_power’) | float }}”
entity_id:
- sensor.phase_1_energy_power
- sensor.phase_2_energy_power
- sensor.phase_3_energy_power
friendly_name: ‘kseb’
unit_of_measurement: ‘Watt’
Now its working.

Thanks a lot.

Aslam

Great but you really need to work out how to format your posts properly. That tells us nothing.

Have a read of point 11 here: How to help us help you - or How to ask a good question

Great.

I have a suggestion. There is no proper tutorial for the home assistant. All the documents are good but not for the beginners. If possible it will be great a video tutorial for those stuffs.

Thanks & Regards,

Aslam

Yeah there is. Follow all the way through with this:

There are hundreds.

Search for what you specifically want to do with home assistant. Make sure you watch a recent one. Things are changing quickly at the moment.

1 Like