Hi all.
We need to combine the totals of multiple sensors to meter the kWh going into our battery system, I have created the following sensor in sensors.yaml
# Sum of all MPPT chargers + ESS kWh to create total battery in
- platform: template
sensors:
total_battery_in:
friendly_name: "Battery kWh in"
unit_of_measurement: "kWh"
device_class: energy
value_template: "{{ (states('sensor.ESS_kWh')|float + states('sensor.mppt_1_yield_total')|float + states('sensor.mppt_2_yield_total')|float + states('sensor.mppt_3_yield_total')|float + states('sensor.mppt_4_yield_total')|float )}}"
I have then added the following in customize.yaml
sensor.total_battery_in:
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
However the sensor still does not appear on the energy dashboard.
I apologise if this seems a simple question to you all, I am very new to this and any help would be greatly appreciated.
Two of your items are already declared in the template sensor, so they shouldn’t need to be declared again in customization. I’m unfamiliar with the energy portion, but what happens when you declare state_class in the template sensor? Otherwise, the spacing on the template sensor needs to be corrected.
# Sum of all MPPT chargers + ESS kWh to create total battery in
- platform: template
sensors:
total_battery_in:
friendly_name: "Battery kWh in"
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
value_template: "{{ (states('sensor.ESS_kWh')|float + states('sensor.mppt_1_yield_total')|float + states('sensor.mppt_2_yield_total')|float + states('sensor.mppt_3_yield_total')|float + states('sensor.mppt_4_yield_total')|float )}}"
Hi thanks for that, I understand what you mean about declaring twice so I’ll sort that out.
Also if I try to declare state_class in the template sensor, when I check the configuration is says that state_class is not allowed in template sensors.
I should have mentioned that the sensor works ok in the rest of home assistant just not on the energy dashboard.
I see where you have changed the spacing, but when I try this the file editor reports a bad indentation