ohadbenita
(Ohad Benita)
January 8, 2025, 9:14am
1
Hi all,
I’m trying to create a utility meter for daily & monthly energy usage and costs, for that I added configuration for the following entities:
input_number:
kwh_cost_gross:
name: kWh Cost Gross
initial: 0.64
min: 0.5
max: 1
step: 0.01
unit_of_measurement: "ILS/kWh"
template:
- sensor:
- name: "Clinic energy consumption"
unit_of_measurement: "kWh"
state: >
{{ states('sensor.shellypmminig3_dcda0cb4cd38_energy') | float(0) +
states('sensor.shellypmminig3_dcda0cb5af10_energy') | float(0) +
states('sensor.shellyplus2pm_c4d8d557f404_switch_0_energy') | float(0) +
states('sensor.shellyplus2pm_c4d8d557f404_switch_1_energy') | float(0)
}}
- name: "Clinic Monthly Energy Cost"
unit_of_measurement: "ILS"
state: >
{{ (states('sensor.clinic_monthly_energy') | float(0) * states('input_number.kwh_cost_gross') | float) | round(2) }}
utility_meter:
clinic_daily_energy:
source: sensor.clinic_energy_consumption
cycle: daily
clinic_monthly_energy:
source: sensor.clinic_energy_consumption
cycle: monthly
The thing with this configuration is that the monthly energy sensor keeps going up and reaches numbers that don’t make sense. Would appreciate any lead on this.
ohadbenita
(Ohad Benita)
January 8, 2025, 9:43am
2
Found one of the issues to be the device class for the template sensor and updated as below:
template:
- sensor:
- name: "Clinic energy consumption"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
state: >
{{ states('sensor.shellypmminig3_dcda0cb4cd38_energy') | float(0) +
states('sensor.shellypmminig3_dcda0cb5af10_energy') | float(0) +
states('sensor.shellyplus2pm_c4d8d557f404_switch_0_energy') | float(0) +
states('sensor.shellyplus2pm_c4d8d557f404_switch_1_energy') | float(0)
}}
- name: "Clinic Monthly Energy Cost"
unit_of_measurement: "ILS"
state: >
{{ (states('sensor.clinic_monthly_energy') | float(0) * states('input_number.kwh_cost_gross') | float) | round(2) }}
ohadbenita
(Ohad Benita)
January 10, 2025, 1:08pm
3
This in fact didn’t help, would appreciate the community’s help on this
davidrapan
(David Rapaň)
January 24, 2025, 4:18pm
4
Don’t use default to 0 w/ float(0)
, just float
ohadbenita
(Ohad Benita)
January 24, 2025, 6:54pm
5
Thanks, unfortunately this didn’t help - the value of the aggregated sensor is indeed correct (it sums up the value of all other sensors correctly) but the utility meter shows unreasonably high values.
davidrapan
(David Rapaň)
January 24, 2025, 7:06pm
6
Try Combine the state of several sensors instead of template sensor.
And show graphs from all sensors (including utility meters).
ohadbenita
(Ohad Benita)
January 25, 2025, 8:42am
7
Where can I find this option?
davidrapan
(David Rapaň)
January 25, 2025, 11:30am
8
In UI > Settings > Devices & services > Helpers > CREATE HELPER
You can try to add Utility meters this way too.