-
Notifications
You must be signed in to change notification settings - Fork 6
Coopérnico Base Bi horário
Luis Miranda edited this page May 29, 2024
·
14 revisions
template:
sensor:
- unique_id: coopernico_spot_price_bihorario
unit_of_measurement: '€/MWh'
availability: "{{ has_value('sensor.omie_spot_price_pt') }}"
state_class: measurement
state: >
{% set PM = states('sensor.omie_spot_price_pt')|float -%}
{% set CGS = 4 -%}
{% set TSE = 2.893 -%}
{% set k = 10 -%}
{% set FP = 0.16 -%}
{% set TAR_vazio = 9.2 if now().date().isoformat() < '2024-06-01' else 15.7 -%}
{% set TAR_fora_vazio = 50.2 if now().date().isoformat() < '2024-06-01' else 86 -%}
{% set TAR = TAR_vazio if now().hour < 8 or now().hour > 21 else TAR_fora_vazio -%}
{{ ((PM + CGS + TSE + k)*(1 + FP) + TAR) | round(2) }}
attributes:
friendly_name: "Coopérnico Base (tarifário bi-horário)"
formula: "(PM+CGS+TSE+k)x(1+FP)+TAR"
PM: "{{ states('sensor.omie_spot_price_pt')|float }}"
CGS: "{{ 4 }}"
TSE: "{{ 2.893 }}"
k: "{{ 10 }}"
FP: "{{ 0.16 }}"
TAR_vazio: "{{ 9.2 if now().date().isoformat() < '2024-06-01' else 15.7 }}"
TAR_fora_vazio: "{{ 50.2 if now().date().isoformat() < '2024-06-01' else 86 }}"
today_hours: >
{% set CGS = 4 -%}
{% set TSE = 2.893 -%}
{% set k = 10 -%}
{% set FP = 0.16 -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, PM in state_attr('sensor.omie_spot_price_pt', 'today_hours').items() -%}
{% set TAR_vazio = 9.2 if h.date().isoformat() < '2024-06-01' else 15.7 %}
{% set TAR_fora_vazio = 50.2 if h.date().isoformat() < '2024-06-01' else 86 %}
{% set TAR = TAR_vazio if h.hour < 8 or h.hour > 21 else TAR_fora_vazio -%}
{% if PM == None %}
{% set price=PM %}
{% else %}
{% set price=((PM + CGS + TSE + k)*(1 + FP) + TAR) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}
tomorrow_hours: >
{% set CGS = 4 -%}
{% set TSE = 2.893 -%}
{% set k = 10 -%}
{% set FP = 0.16 -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, PM in state_attr('sensor.omie_spot_price_pt', 'tomorrow_hours').items() -%}
{% set TAR_vazio = 9.2 if h.date().isoformat() < '2024-06-01' else 15.7 %}
{% set TAR_fora_vazio = 50.2 if h.date().isoformat() < '2024-06-01' else 86 %}
{% set TAR = TAR_vazio if h.hour < 8 or h.hour > 21 else TAR_fora_vazio -%}
{% if PM == None %}
{% set price=PM %}
{% else %}
{% set price=((PM + CGS + TSE + k)*(1 + FP) + TAR) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}