-
Notifications
You must be signed in to change notification settings - Fork 7
Iberdrola simples indexado
Luis Miranda edited this page May 29, 2024
·
3 revisions
template:
sensor:
- unique_id: iberdrola_spot_price_simples
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 MFRR = 3.206 -%}
{% set Q = 21 -%}
{% set FP = 1.1674 -%}
{% set TAE = 36.5 if now().date().isoformat() < '2024-06-01' else 62.5 -%}
{{ (PM * FP + Q + TAE + MFRR) | round(2) }}
attributes:
friendly_name: "Iberdrola Simples indexado"
formula: "PM*FP+Q+TAE+MFRR"
PM: "{{ states('sensor.omie_spot_price_pt')|float }}"
MFRR: "{{ 3.206 }}"
Q: "{{ 21 }}"
FP: "{{ 1.1674 }}"
TAE: "{{ 36.5 if now().date().isoformat() < '2024-06-01' else 62.5 }}"
today_hours: >
{% set MFRR = 4 -%}
{% set Q = 21 -%}
{% set FP = 1.1674 -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, PM in state_attr('sensor.omie_spot_price_pt', 'today_hours').items() -%}
{% set TAE = 36.5 if h.date().isoformat() < '2024-06-01' else 62.5 -%}
{% if PM == None %}
{% set price=PM %}
{% else %}
{% set price=(PM * FP + Q + TAE + MFRR) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}
tomorrow_hours: >
{% set MFRR = 3.206 -%}
{% set Q = 21 -%}
{% set FP = 1.1674 -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, PM in state_attr('sensor.omie_spot_price_pt', 'tomorrow_hours').items() -%}
{% set TAE = 36.5 if h.date().isoformat() < '2024-06-01' else 62.5 -%}
{% if PM == None %}
{% set price=PM %}
{% else %}
{% set price=(PM * FP + Q + TAE + MFRR) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}