Vähän tuohon Miksuu viritykseen viitaten, miten saisi toimimaan vertailun spot vs kiinteä, niin että osaisi laskea molemmat suunnat (säästö / tappio) yhteen muuttajaan.
Alla configuration. yaml tiedostosta koodia. Kokeilin tuohon energy_cost_net_daily utility meteriin muuttaa Net consumption ja Delta values asetuksia, mutta ei tullut toivottua vaikutusta.
Tuo siis toimii, kun säästö tai tappio lasketaan omiin muuttujiinsa (eli energy_cost_loss_daily ja energy_cost_saving_daily näyttävät uskottavia arvoja), mutta millä nämä saa yhdistettyä?
Koodi:
utility_meter:
energy_cost_loss_daily:
source: sensor.energy_cost_quarterly_loss_incl_vat_and_margin
cycle: daily
energy_cost_loss_monthly:
source: sensor.energy_cost_quarterly_loss_incl_vat_and_margin
cycle: monthly
energy_cost_loss_yearly:
source: sensor.energy_cost_quarterly_loss_incl_vat_and_margin
cycle: yearly
energy_cost_saving_daily:
source: sensor.energy_cost_quarterly_sawing_incl_vat_and_margin
cycle: daily
energy_cost_saving_monthly:
source: sensor.energy_cost_quarterly_sawing_incl_vat_and_margin
cycle: monthly
energy_cost_saving_yearly:
source: sensor.energy_cost_quarterly_sawing_incl_vat_and_margin
cycle: yearly
energy_cost_net_daily:
source: sensor.energy_cost_quarterly_net
cycle: daily
energy_cost_net_monthly:
source: sensor.energy_cost_quarterly_net
cycle: monthly
energy_cost_net_yearly:
source: sensor.energy_cost_quarterly_net
cycle: yearly
template:
### tästä eteenpäin energy-cost-saving-calculator
### vertailua pörssisähkön ja kiinteän välillä
- sensor:
- name: "spot_price_incl_vat_and_margin"
unit_of_measurement: "cents"
state: >
{{ ((( states('sensor.nord_pool_fi_current_price') | float ) * (1 + (states('input_number.energy_vat_rate') | float / 100)) * 100) + (states('input_number.energy_margin') | float )) | round(3) }}
- sensor:
- name: "current_energy_price_incl_vat"
unit_of_measurement: "cents"
state: >
{{ ( states('input_number.energy_cost') | float ) * (1 + (states('input_number.energy_vat_rate') | float / 100)) | round(3) }}
- sensor:
- name: "energy_cost_quarterly_loss_incl_vat_and_margin"
unit_of_measurement: "€"
state: >
{% set fixed = states('sensor.current_energy_price_incl_vat') | float %}
{% set spot = states('sensor.spot_price_incl_vat_and_margin') | float %}
{% set consumption = states('sensor.quarterly_energy') | float %}
{% if fixed > spot %}
{{ ((fixed - spot) * consumption / 100) | round(4) }}
{% else %}
0
{% endif %}
- sensor:
- name: "energy_cost_quarterly_sawing_incl_vat_and_margin"
unit_of_measurement: "€"
state: >
{% set fixed = states('sensor.current_energy_price_incl_vat') | float %}
{% set spot = states('sensor.spot_price_incl_vat_and_margin') | float %}
{% set consumption = states('sensor.quarterly_energy') | float %}
{% if spot > fixed %}
{{ ((spot - fixed) * consumption / 100) | round(4) }}
{% else %}
0
{% endif %}
- sensor:
- name: "energy_cost_quarterly_net"
unit_of_measurement: "€"
state: >
{% set saving = states('sensor.energy_cost_quarterly_sawing_incl_vat_and_margin') | float %}
{% set loss = states('sensor.energy_cost_quarterly_loss_incl_vat_and_margin') | float %}
{{ (saving - loss) | round(4) }}