Hi,
I’ve been struggling with this for a long time now since moving from history stats to utility energy.
I have sonoff devices that control some electrical heating devices and am trying to calculate the daily and monthly costs based on fixed KWH tariffs.
- platform: template
sensors:
heating_kitchen_monthly:
friendly_name: "Kitchen heating cost monthly"
unit_of_measurement: '$'
value_template: >-
{{ ((states('sensor.kitchen_heating_monthly_energy_offpeak') | float) * (states('input_number.ute_offpeak_cost') | float )) | round(2) }}
- platform: template
sensors:
kitchen_heating_power:
friendly_name: "Kitchen Heating Power"
unit_of_measurement: 'W'
value_template: >-
{% if is_state('switch.sonoff_1000c7019c', 'on') %}
1100
{% else %}
0
{% endif %}
- platform: integration
source: sensor.kitchen_heating_power
name: kitchen_heating_energy
unit_prefix: k
round: 2
If I check these in the template developer tools I see a value of ‘0.82’
‘input_number.ute_offpeak_cost’ = 4.88
I am not sure how it is calculating this when the device has been ‘on’ for 1.76 hours at 1100 W. (I have tried setting this at 1.1 with unit ‘kwh’ also but then get a small number.
Not sure if I’m making myself clear here.
Here I need to see a calculation of 1.76 hours/1100W/4.88 pesos per kwh = 9.447 pesos
Why am I only seeing a value of 0.82 from the sensor:
{{ (states(‘sensor.kitchen_heating_daily_energy_offpeak’)) }} ?
Thanks!