-
Notifications
You must be signed in to change notification settings - Fork 6
Repsol Leve sem Mais bihorário
Luis Miranda edited this page May 29, 2024
·
3 revisions
template:
sensor:
- unique_id: repsol_spot_price_bihorario
unit_of_measurement: '€/MWh'
availability: "{{ has_value('sensor.omie_spot_price_pt') }}"
state_class: measurement
state: >
{% set OMIE = states('sensor.omie_spot_price_pt')|float -%}
{% set Perdas = 0.15 -%}
{% set FA = 1.03 -%}
{% set QTarifa = 14.79 -%}
{% 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 -%}
{{ ((OMIE)*(1 + Perdas)*FA + QTarifa + TAR) | round(2) }}
attributes:
friendly_name: "Repsol Indexado (tarifário bi-horário)"
formula: "(OMIE)*(1 + Perdas)*FA + QTarifa + TAR"
OMIE: "{{ states('sensor.omie_spot_price_pt')|float }}"
Perdas: "{{ 0.15 }}"
FA: "{{ 1.03 }}"
QTarifa: "{{ 14.79 }}"
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 Perdas = 0.15 -%}
{% set FA = 1.03 -%}
{% set QTarifa = 14.79 -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, OMIE 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 OMIE == None %}
{% set price=OMIE %}
{% else %}
{% set price=((OMIE)*(1 + Perdas)*FA + QTarifa + TAR) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}
tomorrow_hours: >
{% set Perdas = 0.15 -%}
{% set FA = 1.03 -%}
{% set QTarifa = 14.79 -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, OMIE 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 OMIE == None %}
{% set price=OMIE %}
{% else %}
{% set price=((OMIE)*(1 + Perdas)*FA + QTarifa + TAR) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}