Add carbon footprint to energy dashboard

It would be great to add carbon footprint to the energy dashboard and accumulate per day/week/month in the same way as electricity & gas.

I think this requires multiplying the current ( non-cummulative ) electricity kWh by the current CO2 intensity and add the current ( non-cummulative ) gas kWh multiplied by 0.185 (default).

As far as I can see this is pretty hard to do ( impossible ? ) outside of a plugin.

Thanks.

Something official would be great. Here’s my hacked together version.
First, I simplified my problem by going all electric, so this won’t help with gas, directly.
But I have a template that seems to be working(ish), and goes both directions for my solar.

template:
  - sensor:
    - name: "CO2 Home Emission Intensity"
      unique_id: 00000000-0000-0000-0000-000000000000    ## Generate your own uuid
      unit_of_measurement: gCO2eq/s
      state: >
        {% set grams_co2_per_kwh = states('sensor.co2_signal_co2_intensity')|float('unknown') %}
        {% set elec_imported = states('sensor.import')|float('unknown') %}
        {% set elec_exported = states('sensor.export')|float('unknown') %}
        {% set grams_co2_per_wh = grams_co2_per_kwh / 1000 %}
        {% set grams_co2_per_ws = grams_co2_per_wh / 3600 %}
        {% set co2_emitted = grams_co2_per_ws * elec_imported %}
        {% set co2_grid_reduced = grams_co2_per_ws * elec_exported %}
        {% set co2_net_emitted = co2_emitted - co2_grid_reduced %}
        {{ co2_net_emitted }}

Electricity only, clearly not optimized. I’m pretty new, and barely understand templates.
This might not even do what I think it does.
But what I think it does is it measures CO2 grid intensity for my location from CO2Signal, measures my electricity imported, electricity exported, and then multiplies that by the grams_co2 per watt-second. Then it subtracts emitted from reduced and returns the net amount. (Edited to finish the sentence I left incomplete in the original post.)

One thing I haven’t been able to figure out is how to get it to show me what it’s doing daily. It just counts up or down from when I started it. I’d like it to show me more like it does with Solar, on an hourly or daily basis.
Something official would be great though, and I’d want it to include something similar to electricity use with solar: emitted - for grid power (or gas, or X) you used, and offset (for negative emmisions, like pushing power out to the grid) . Probably with better names.

3 Likes

Maybe a little bit late to the party, but I think I got a solution.
The problem with your sensor is, that it has no historical values.
I did create a template sensor calculating the current CO2 emission with this code:

{{ ( (states('sensor.co2_signal_co2_intensity') | float / 1000) * (states('sensor.grid_import_power') | float) ) | round(4)}}

which gives gCO2eq/h. Then I calculate the gCO2eq with the riemann sum integral. By now I have 3 calculations and I think with some tolerance my calculations seem to be right.
image
(“Bezug” means cosumed from grid and also there should be Wh not kWh)
I did the same for export and cosumed solar power.

2 Likes

This is a perfect solution!
I put in my sensor values and everything checks out perfectly.

Thanks for your Solution!