Support for thirdparty grid carbon footprint

The history is a pretty simple chart also, but the calculations/sensors under it are a little complicated and only applicable to our house (they have a variety of assumptions and various components for emissions prior to our full electrification and to calculate emissions when we are charging our EV from DC chargers on the road or at other locations).

type: custom:apexcharts-card
apex_config:
  legend:
    show: false
graph_span: 30d
span:
  end: day
stacked: true
header:
  title: Emissions - Daily History (Today's Numbers)
  show: true
  show_states: true
  colorize_states: true
yaxis:
  - id: gCO2eq
    decimals: 0
    apex_config:
      forceNiceScale: true
      title:
        text: kgCO2eq
series:
  - entity: sensor.emissions_created_cumulative
    name: Created
    type: column
    color: grey
    float_precision: 1
    transform: return x/1000;
    unit: kgCO2eq
    opacity: 0.5
    statistics:
      type: sum
      period: day
    group_by:
      duration: 1d
      start_with_last: true
      func: diff
  - entity: sensor.emissions_avoided_cumulative
    name: Displaced
    type: column
    color: green
    float_precision: 1
    transform: return x/1000;
    unit: kgCO2eq
    invert: true
    opacity: 0.5
    statistics:
      type: sum
      period: day
    group_by:
      duration: 1d
      start_with_last: true
      func: diff
  - entity: sensor.emissions_net_cumulative
    name: Net
    type: line
    color: teal
    float_precision: 1
    transform: return x/1000;
    unit: kgCO2eq
    statistics:
      type: min
      period: day
    show:
      datalabels: true
    group_by:
      duration: 1d
      start_with_last: true
      func: diff

sensor.emissions_created_cumulative and sensor.emissions_avoided_cumulative

  #Emissions Avoided/Created
  - platform: integration
    source: sensor.emissions_created
    name: emissions_created_cumulative
  - platform: integration
    source: sensor.emissions_avoided
    name: emissions_avoided_cumulative

sensor.emissions_net_cumulative

      - name: "emissions_net_cumulative"
        unique_id: "emissions_net_cumulative"
        state_class: measurement
        unit_of_measurement: gCO2eq
        state: "{{ ((states('sensor.emissions_created_cumulative') | float(0)) ) - ((states('sensor.emissions_avoided_cumulative') | float(0)) ) }}"

oh, the sensors call it avoiding co2eq but the charts label it as displaced.

Hopefully that can get you to somewhere of less a horrible place (or if your setup is less horrible than mine then please share back).

1 Like