diff --git a/configurations/home-assistant/configuration.yaml b/configurations/home-assistant/configuration.yaml index ae2a0c9..ca6ef14 100644 --- a/configurations/home-assistant/configuration.yaml +++ b/configurations/home-assistant/configuration.yaml @@ -11,3 +11,77 @@ http: use_x_forwarded_for: true trusted_proxies: - 172.16.0.0/12 + +# ---- 1. Track a running monthly average of the EPEX day-ahead price ---- +# (Replace sensor.nordpool_kwh_be_eur_3_10_0 with your actual Nord Pool entity ID) +sensor: + - platform: statistics + name: "Epex Monthly Average" + entity_id: sensor.nordpool_kwh_be_eur_3_10_0 + state_characteristic: mean + max_age: + days: 31 + sampling_size: 9999 + +# ---- 2. Apply Mega's formula and add the fixed cost components ---- +template: + - sensor: + - name: "Mega Energy Price" + unique_id: mega_energy_price + unit_of_measurement: "€/kWh" + state: > + {% set epex = states('sensor.epex_monthly_average') | float(0) %} + {% set excl_vat = epex * 1.085 %} + {% set incl_vat = excl_vat * 1.06 %} + {{ incl_vat | round(5) }} + + - name: "Mega All-in Price" + unique_id: mega_allin_price + unit_of_measurement: "€/kWh" + state: > + {% set energy = states('sensor.mega_energy_price') | float(0) %} + {% set green_power = 0.01554 %} + {% set distribution = 0.066985 %} + {% set excise = 0.0503288 %} + {% set energy_contribution = 0.0020417 %} + {{ (energy + green_power + distribution + excise + energy_contribution) | round(5) }} + - sensor: + - name: "Mega Injection Price" + unique_id: mega_injection_price + unit_of_measurement: "€/kWh" + state: > + {% set epex_spp = states('sensor.epex_spp_monthly_average') | float(0) %} + {% set price = (epex_spp * 0.96) - 1 %} + {{ [price, 0] | max | round(5) }} + + - sensor: + - name: "Cistern Water Height" + unique_id: cistern_water_height + unit_of_measurement: "mm" + state_class: measurement + state: > + {% set sensor_offset = 290 %} {# distance (mm) from sensor to tank bottom #} + {% set distance = states('sensor.regenput_sensor_distance') | float(0) %} + {% set height = sensor_offset - distance %} + {{ [ [height, 0] | max, sensor_offset] | min | round(1) }} + + - name: "Cistern Volume" + unique_id: cistern_volume + unit_of_measurement: "L" + device_class: volume + state_class: measurement + state: > + {% set diameter = 1450 %} {# mm #} + {% set radius = diameter / 2 %} + {% set height = states('sensor.cistern_water_height') | float(0) %} + {% set volume_mm3 = 3.14159265 * (radius ** 2) * height %} + {{ (volume_cm3 / 1000000) | round(1) }} {# convert mm³ to liters #} + + - name: "Cistern Fill Percentage" + unique_id: cistern_fill_percentage + unit_of_measurement: "%" + state_class: measurement + state: > + {% set sensor_offset = 290 %} {# same as above, = full tank height #} + {% set height = states('sensor.cistern_water_height') | float(0) %} + {{ (height / sensor_offset * 100) | round(1) }}