Hello,
I would like to calculate the break even point of my solar system using template, so I can (nearly) know when my investment will pay off. I have an input helper that keeps track of how much I have earned with the solar system, another that stores how much I spend on the system.

so basically I want to calculate how much I have earned per pay on average and devide how much I spend on the system by this average income per day. This should give me the number of days it will take for my investment to pay off. Next step is to to add this number to the date I have installed the solar system. It seems that this last step does not work.
What am I doing wrong?

template:
- sensor:
- name: "PV Break Even Date"
unique_id: pv_break_even_date
state: >
{% set income = states('input_number.pv_amortisierung') | int %}
{% set costs = states('input_number.pv_gestehungskosten') | int %}
{% set days = (today_at() - strptime("28.06.2023", "%d.%m.%Y") | as_local).days %}
{% set daily = income / days %}
{% set total_days = (costs / daily)|int %}
{% set remaining_days = total_days - days %}
{{ (today_at() + timedelta(days=remaining_days)).date() }}