Add "Solar Cost Saving" option to native Energy Dashboard

Similar as the existing compensation (money) tracker for Return to Grid I would like to be able to see how much my investment in Solar panels has payed off over time. Monetarily speaking. Return On Investment.

“How much would I have payed for my consumed solar energy if I instead needed to buy it from the grid”. “Will it yield as much money as the sales guy promised me in their proposal.” “You will get your money back in x years”.

I think it could work almost exactly as the Return to Grid functionality. I already have a sensor that calculates this based on my current grid price. But it would be nice to get this into the Energy Dashboard accumulated over time.

Sure it feels good to save our climate and it would feel even better to know when my investment has payed of financially. Speaking like a true capitalist :money_mouth_face:

I’m specifically looking into calculating this. I have all the data available but I don’t know (yet) how to put all the numbers together in HA

I would also like this feature. Just add a tariff for “self consumed solar” (or take it from the comsumption tariff)

I have a bit of complexity as my electricity buy/ sell prices changes every five minute.

I calculate this as follows:

Benefit/ saving in $/hr.

    - name: Solar Benefit
      unit_of_measurement: $/h
      state: >
       {{states('sensor.apf_solar2house')|float(0) * states('sensor.amber_general_price')|float(0)/1000
       + states('sensor.apf_solar2batt')|float(0) * states('sensor.amber_feed_in_price')|float(0)/1000
       + states('sensor.apf_solar2grid')|float(0) * states('sensor.amber_feed_in_price')|float(0)/1000}}

    - name: Battery Benefit
      unit_of_measurement: $/h
      state: >
        {{states('sensor.apf_batt2grid')|float(0) * states('sensor.amber_feed_in_price')|float(0)/1000
        - states('sensor.apf_grid2batt')|float(0) * states('sensor.amber_general_price')|float(0)/1000
        - states('sensor.apf_solar2batt')|float(0) * states('sensor.amber_feed_in_price')|float(0)/1000
        + states('sensor.apf_batt2house')|float(0) * states('sensor.amber_general_price')|float(0)/1000}}

    - name: battery+solar benefit
      unit_of_measurement: $/h
      state: >
        {{states('sensor.battery_benefit')|float(0) + states('sensor.solar_benefit')|float(0)}}

Then a Riemann Sum integration to calculate total $ savings:

Then a utility meter to calcuclate savings as $/ day $/month…

Same for the battery savings $/ day

Then add them together to get a savings for battery+solar $/ month

Pretty up results with ApexCharts
image

14 Likes

Thank you for your work, markpurcell,
but I don’t understand your Configuration.
I mean, I get the idea, but I am wondering what value is in the sensor apf_solar2house: Current Watt, kWh in total? Why does it get divided by 1000?
And I was wondering, how is your Solar Benefit Integral configured (settings)?

Thanks for helping me out :grinning:

apf_solar2house is in W, but amber_general_price is in $/ kWh so I need to divide by 1000 to get $/ Wh

1 Like

Ah okay, that makes sense. Thank you for the explanation :ok_hand:.
So, for the Riemann-Summenintegral, it would be Left Riemann sum, no Metric Prefix and Time h (hours)?

Yes, but give it a go and see if the data is making sense for you.

Isn’t this a duplicate of
Calculate/Display cost savings from self consumed solar energy?

However, I have voted for both of them…

Thanks for sharing this @markpurcell, I’ve been able to use this to help me put together some stats :+1:

1 Like

I think this is an excellent idea for the native energy dashboard to include.

Hi @markpurcell , thanks for the excellent guide!
I was able to follow it and create the sensors & helpers, but struggle with the Apex Chart.
I don’t suppose you’d be willing to share the code for that?

I have extended the charts a little so here is the update:

FB_IMG_1676406289102

type: custom:apexcharts-card
graph_span: 11d
span:
  end: day
stacked: true
header:
  show: true
  title: Battery & Solar Savings
  show_states: true
  colorize_states: true
series:
  - entity: sensor.solar_savings_daily
    type: column
    group_by:
      func: max
      duration: 1d
    show:
      in_header: false
      legend_value: false
  - entity: sensor.battery_savings_daily
    type: column
    group_by:
      func: max
      duration: 1d
    show:
      in_header: false
      legend_value: false
  - entity: sensor.amber_vs_dmo_savings_daily
    type: column
    group_by:
      func: max
      duration: 1d
    show:
      in_header: false
      legend_value: false
  - entity: sensor.abs_savings_daily
    name: Amber+Battery+Solar Savings
    type: line
    stroke_width: 0
    unit: $
    show:
      extremas: true
      in_header: false
      legend_value: false
    group_by:
      func: max
      duration: 1d
  - entity: sensor.abs_savings_monthly
    unit: $
    name: month todate Amber+Battery+Solar
    show:
      legend_value: false
      in_chart: false
  - entity: sensor.battery_savings_monthly
    unit: $
    name: month todate Battery
    show:
      legend_value: false
      in_chart: false
  - entity: sensor.solar_savings_monthly
    unit: $
    name: month todate solar
    show:
      legend_value: false
      in_chart: false
yaxis:
  - id: first
    decimals: 1
    max: 50
    min: 0
    apex_config:
      tickAmount: 2
      logarithmic: false
1 Like

This looks exactly like what i’m looking for.

However, i live in Denmark, where the cost of electricty changes for every hour. How would this be done with that?
I have a two sensors, one that always is the current cost, and one that is the current sales price of electricty.

My prices change every five minutes.

Were you able to follow my logic above?

1 Like

No sorry.
I’m very new to templates, which i’m guessing it is, your solution?

I have these sensors available

sensor.power_meter_consumption
sensor.inverter.daily_yield
sensor.power_meter_exported
sensor.energi_data_service - which is the current price of eletricity, updated every hour.
sensor.nettopower_salg - which is the current SALES price of eletricity, updated every hour.

Can your solution work with these sensors?
@markpurcell

Where do you create this

- name: Solar Benefit
      unit_of_measurement: $/h
      state: >
       {{states('sensor.apf_solar2house')|float(0) * states('sensor.amber_general_price')|float(0)/1000
       + states('sensor.apf_solar2batt')|float(0) * states('sensor.amber_feed_in_price')|float(0)/1000
       + states('sensor.apf_solar2grid')|float(0) * states('sensor.amber_feed_in_price')|float(0)/1000}}

    - name: Battery Benefit
      unit_of_measurement: $/h
      state: >
        {{states('sensor.apf_batt2grid')|float(0) * states('sensor.amber_feed_in_price')|float(0)/1000
        - states('sensor.apf_grid2batt')|float(0) * states('sensor.amber_general_price')|float(0)/1000
        - states('sensor.apf_solar2batt')|float(0) * states('sensor.amber_feed_in_price')|float(0)/1000
        + states('sensor.apf_batt2house')|float(0) * states('sensor.amber_general_price')|float(0)/1000}}

    - name: battery+solar benefit
      unit_of_measurement: $/h
      state: >
        {{states('sensor.battery_benefit')|float(0) + states('sensor.solar_benefit')|float(0)}}

EDIT:
I got something working.
I did this


  - platform: template
    sensors:
      solceller_besparelse:
        friendly_name: "Solcelle besparelse"    
        unit_of_measurement: DKK/h
        value_template: >
          {{states('sensor.solcelle_til_eget_brug')|float(0) * states('sensor.energi_data_service')|float(0)/1000
          + states('sensor.solar_grid_production')|float(0) * states('sensor.nettopower_salg')|float(0)/1000}}
        unique_id: solcelle_besparelse

But this is just a running sensor, it doesn’t calculate my total savings, just what i’m saving right now, this second.

image

EDIT2:
Think i got it, i didn’t know that rieman and utilty meter was helpers xD Never used them
If it doesn’t work, ill get back to you, thanks for the help!

1 Like

Sounds like you should be able to get something working.

Can you post the graphs for each sensor?

Sounds like you want meter_consumption * energi

1 Like

It looks like it’s working now.
There was just alot of new terms i didn’t know about, so i got confused.


I haven’t tried with the apex charts yet, but that’s just gui. As long as the data is there, i’ll manage :smiley:

I am also missing exactly what OP writes. Sad that this is still missing after 15 months. Wondering if there could be any reason not to have it? :thinking: