I am trying to bend my head around how to calculate the return of investment for our solar panels.
Everything is working nicely with regards for the net export via the Energy dashboard, but I fail with the self consumed energy.
I have a total increasing template for the hourly kWh, the challenge is that I also have a hourly cost, so at the end of the hour I have to capture the consumption and multiply that with the current cost in turn to be added to the total increasing monitary sensor.
What is the best approach to extract the last hour of consumption, and when to calculate the cost, given that the tarif changes on the hour? At hh:55 or something like it?
sensor.solar_selfconsumed_power calculates the difference between produced power and power submitted to the grid [W]
sensor.solar_selfconsumed_energy uses the Riemann sum integral (left) to convert to kWh
- platform: template
sensors:
solar_selfconsumed_power:
friendly_name: Solpanel Egenförbrukad Kraft
value_template: "{{ (states('sensor.sma_solpaneler_grid_power')|float(0)) - ((states('sensor.power_produced')|float(0))*1000) }}"
unit_of_measurement: "W"
- platform: integration
name: Solpanel Egenförbrukad Energi
unique_id: solar_selfconsumed_energy
unit_prefix: k
unit_time: h
method: left
source: sensor.solar_selfconsumed_power
sensor.elkostnad is the hourly rate + fixed transfer cost from the grid, updated on the hour
sensor.solcell_besparing has two shortcomings, I need a delta sensor rather than the total_increasing, and it will be updated at the same time as the cost sensor is updated, giving an unpredicable outcome.
- sensor:
- name: "Elkostnad"
state: "{{ (states('sensor.nordpool_kwh_se3')|float(0)) + (states('sensor.elkostnad_natagare')|float(0)) }}"
availability: "{{ states('sensor.nordpool_kwh_se3') not in ['unavailable', 'unknown', 'none'] }}"
unit_of_measurement: "SEK/kWh"
device_class: monetary
- sensor:
- name: "Solcell Besparing"
state: "{{ states('sensor.solar_selfconsumed_energy')|float(0) * states('sensor.elkostnad')|float(0) }}"
availability: "{{ states('sensor.nordpool_kwh_se3') not in ['unavailable', 'unknown', 'none'] }}"
unit_of_measurement: "SEK"
device_class: monetary
state_class: total_increasing