System Depreciation calculator?

Hello, I am trying to create an entity / a calculation module that will be given: A total price of what I have spend so far in my system, 2. The current price of one Kwh and give me 3 numbers:

  1. Kwh made TOTAL * xxx curent price of grid Kwh = how much money system has made
  2. Money spend - money made = money remaining to make
  3. Money spend / xxx curent price of grid Kwh = X kwh - Kwh made = Kwh remaining.

I tried chat gpt and it gave me to create a few templates but it’s so confusing.

{{ (states(‘input_number.money_spend_fb’)|float(0) - (states(‘sensor.your_entity’)|float(0) * states(‘input_number.kwh_price’)|float(0))) | max(0) | round(2) }}

{% set cost = states(‘input_number.total_spend_fb’)|float(0) %}
{% set price = states(‘input_number.number.kwh_price’)|float(0) %}
{% set prod = states(‘sensor.your_entity’)|float(0) %}
{{ ((cost - (prod * price)) / (price if price > 0 else 1)) | max(0) | round(0) }}

Is there something ready to use?

Wouldn’t you need to get the product of current production and current price, then accrue that over time? Otherwise you are overvaluing previous production when the price was lower and vice versa.


It would help us to help you if you…

  1. Provide the entity ID’s for the value you already have. Remember that we can’t know what you don’t tell us… and it looks like some, or maybe all, of the entity ID’s in the AI-created templates aren’t real.
  2. Clarify what part is confusing you or where you a stuck.

Price is relatively at the same level. Around 0,27 per Kwh. I understand your concern but I don’t mind this.

edit: I already have something like that in excel. But it would be nice to have something integrated. Screenshot: (most fields in screenshot are translated)

edit 2:

Well…I have created something. I don’t know how it works but it calculates really close.

I created these with the help of chat gpt:

The problem with calculating I think it is I can’t find the proper sensor for total PV production. But I am looking into it.