Hi Daniel
So the corrected YAML after changing to a floating point instead of integer as above is:
- trigger:
- platform: time
at: "00:00:01"
sensor:
- name: Electricity Standing Charge
unique_id: electricity_standing_charge
unit_of_measurement: 'kWh'
device_class: energy
state_class: total_increasing
state: "{{ states('sensor.electricity_standing_charge') | float(0) + 1.2059 }}"
- trigger:
- platform: time
at: "00:00:01"
sensor:
- name: Gas Standing Charge
unique_id: gas_standing_charge
unit_of_measurement: 'kWh'
device_class: energy
state_class: total_increasing
state: "{{ states('sensor.gas_standing_charge') | float(0) + 2.766 }}"
This code is in my template.yaml file. I also noticed for my gas one i was using the electricity unit cost this entire time haha so also changed that!
The trigger part tells it to run at a time which is set to “00:00:01”
The sensor is device_class energy with measurement set to kWh so that it will be usable in the Energy dashboard. The state_class also needs to be total_increasing.
The code then takes the standing charge sensor (itself) and adds a kwH value to it. This value is determined by the unit cost of your energy vs your standing charge cost. i.e. how many units of electricity costs the same as the standing charge. i.e. as above, 1.2059 x my unit rate ends up being the cost of my electricity standing charge.
I do the same for another sensor for gas and then add both to the energy dashboard.
So at 00:00:01 each night both sensors add the desired KwH usage that works out to be the cost of the standing charges.
The unit is already known to the energy dashboard from when you add your main energy input.
Does that make ANY sense? Took me a moment to remember how i’d done it!