Daily and Monthly cost
Closed this issue · 1 comments
MrSimpa commented
In the case of the graphs, I see that you also have a calculation based on daily and monthly costs. How do you get the balance for the previous months so that you can calculate the expenses? I am also interested in the past day, given that the data is "rarely" linked, I tried to do it at a specific time, e.g. 10 am to check the status according to the tariff for the previous day, but the status is usually "Unavailable".
frlequ commented
You can play with this, but keep in mind, that invoices can change significantly every month, so dont rely on it.
This is for monthly costs:
- sensor:
- name: "Energy Monthly Costs"
unit_of_measurement: "EUR"
state_class: total_increasing
availability: "{{ states('sensor.mojelektro_monthly_input_peak') not in ['unavailable', 'unknown', None] and states('sensor.mojelektro_monthly_input_offpeak') not in ['unavailable', 'unknown', None] and states('sensor.mojelektro_monthly_input') not in ['unavailable', 'unknown', None] }}"
device_class: monetary
state: >
{% set VT_kWh = float(states('sensor.mojelektro_monthly_input_peak')) %}
{% set MT_kWh = float(states('sensor.mojelektro_monthly_input_offpeak')) %}
{% set monthlyInput = VT_kWh + MT_kWh %}
{% set total_monthly_costs_neto = float(state_attr('sensor.energy_monthly_costs', 'total_monthly_costs_neto')) %}
{% set sodo_moc = float('0.796000') %}
{% set sodo_VT = float('0.043080') %}
{% set sodo_MT = float('0.033110') %}
{% set prispevki1 = float('0.000130') %}
{% set prispevki2 = float('0.000800') %}
{% set SPTE = float('0.0') %}
{% set prispevki3 = float('0.001530') %}
{% set mesecno_nadomestilo = float('1.99') %}
{% set jedrska_energija = float('0') %}
{% set popust1 = float('-1.00') %}
{% set popust_eko = float('-1.00') %}
{% set prispevki4T = 10 * sodo_moc %}
{% set sodo_neto = (VT_kWh * sodo_VT) + (MT_kWh * sodo_MT) + prispevki4T %}
{% set prispevki1T = (monthlyInput * prispevki1) %}
{% set prispevki2T = (monthlyInput * prispevki2 ) %}
{% set prispevki3T = (monthlyInput * prispevki3 ) %}
{% set prispevki5T = SPTE %}
{% set prispevki6T = (mesecno_nadomestilo ) + (jedrska_energija ) + (popust_eko ) %}
{% set eTotal = total_monthly_costs_neto + sodo_neto + prispevki1T + prispevki2T + prispevki5T + prispevki3T + prispevki6T %}
{{ (eTotal*1.22) | round(2) }}
attributes:
total_monthly_costs_vt_neto: >
{% set price_VT = float(0.162900) %}
{% set price_VT_regulated = float(0.118000) %}
{% set VT_kWh = float(states('sensor.mojelektro_monthly_input_peak')) %}
{% set VT_kWh_unregulated = (VT_kWh / 100 * 10) | round (0) %}
{% set total_monthly_VT_regulated = (VT_kWh - VT_kWh_unregulated) * price_VT_regulated %}
{% set total_monthly_VT_unregulated = VT_kWh_unregulated * price_VT %}
{% set total_monthly_VT_costs = total_monthly_VT_unregulated + total_monthly_VT_regulated %}
{{total_monthly_VT_costs | round(2) }}
total_monthly_costs_mt_neto: >
{% set price_MT = float(0.162900) %}
{% set price_MT_regulated = float(0.118000) %}
{% set MT_kWh = float(states('sensor.mojelektro_monthly_input_offpeak')) %}
{% set MT_kWh_unregulated = (MT_kWh / 100 * 10) | round (0) %}
{% set total_monthly_MT_regulated = (MT_kWh - MT_kWh_unregulated) * price_MT_regulated %}
{% set total_monthly_MT_unregulated = MT_kWh_unregulated * price_MT %}
{% set total_monthly_MT_costs = total_monthly_MT_unregulated + total_monthly_MT_regulated %}
{{total_monthly_MT_costs | round(2)}}
total_monthly_costs_neto: >
{% set total_monthly_VT_costs = float(state_attr('sensor.energy_monthly_costs', 'total_monthly_costs_vt_neto')) %}
{% set total_monthly_MT_costs = float(state_attr('sensor.energy_monthly_costs', 'total_monthly_costs_mt_neto')) %}
{% set total_monthly_costs_neto = (total_monthly_VT_costs + total_monthly_MT_costs) | round(2) %}
{{ total_monthly_costs_neto | round(2) }}
Daily is currently not correct, because it's 90% regulated and 10% not, but you can change energy price sensors accordingly:
- sensor:
- name: "Energy Price VT"
unit_of_measurement: "EUR/kWh"
state_class: total_increasing
device_class: monetary
state: "0.1750029"
- sensor:
- name: "Energy Price MT"
unit_of_measurement: "EUR/kWh"
state_class: total_increasing
device_class: monetary
state: "0.12499425"
- sensor:
- name: "Energy Daily Costs"
unit_of_measurement: "EUR"
state_class: total_increasing
device_class: monetary
availability: "{{ states('sensor.mojelektro_daily_input_peak') not in ['unavailable', 'unknown', None] and states('sensor.mojelektro_daily_input_offpeak') not in ['unavailable', 'unknown', None]}}"
state: >
{% set price_VT = (states('sensor.energy_price_VT')) %}
{% set price_MT = (states('sensor.energy_price_MT')) %}
{% set offpeak = (states('sensor.mojelektro_daily_input_offpeak')) %}
{% set peak = (states('sensor.mojelektro_daily_input_peak')) %}
{% set totalDailyOffPeak = (float(offpeak) * float(price_MT)) %}
{% set totalDailyPeak = (float(peak) * float(price_VT)) %}
{{ (totalDailyOffPeak + totalDailyPeak) | round(2) }}
attributes:
total_daily_peak: >
{% set price_VT = (states('sensor.energy_price_VT')) %}
{% set peak = (states('sensor.mojelektro_daily_input_peak')) %}
{% set totalDailyPeak = (float(peak) * float(price_VT)) %}
{{ totalDailyPeak | round(2) }}
total_daily_offpeak: >
{% set price_MT = (states('sensor.energy_price_MT')) %}
{% set offpeak = (states('sensor.mojelektro_daily_input_offpeak')) %}
{% set totalDailyOffPeak = (float(offpeak) * float(price_MT)) %}
{{ totalDailyOffPeak | round(2) }}