-
Notifications
You must be signed in to change notification settings - Fork 7
Ibelectra Solução Família simples
Luis Miranda edited this page May 29, 2024
·
6 revisions
template:
sensor:
- unique_id: ibelectra_familia_simples
unit_of_measurement: '€/MWh'
availability: "{{ state_attr('sensor.omie_spot_price_pt', 'today_average') != None }}"
state_class: measurement
state: >
{% set OMIE = state_attr('sensor.omie_spot_price_pt', 'today_average') -%}
{% set CGS = state_attr(this.entity_id, 'CGS') -%}
{% set Perdas = state_attr(this.entity_id, 'Perdas') -%}
{% set k = state_attr(this.entity_id, 'k') -%}
{% set TAR = state_attr(this.entity_id, 'TAR') -%}
{% set FTS = state_attr(this.entity_id, 'FTS') -%}
{% if None in [CGS, Perdas, k, TAR, FTS] %}
{{ None }}
{% else %}
{{ ((OMIE+CGS)*(1+Perdas)+k+TAR+FTS) | round(2) }}
{% endif %}
attributes:
friendly_name: "Ibelectra Solução Familia (tarifário simples)"
formula: (OMIE+CGS)*(1+Perdas)+k+TAR+FTS
OMIE: "{{ state_attr('sensor.omie_spot_price_pt', 'today_average') }}"
CGS: "{{ 7 }}"
Perdas: "{{ 0.1604 }}"
k: "{{ 3.5 }}"
TAR: "{{ 36.5 if now().date().isoformat() < '2024-06-01' else 62.50 }}"
FTS: "{{ 0 if now().date().isoformat() < '2024-06-20' else 2.893 }}"
today_hours: >
{% set OMIE = state_attr('sensor.omie_spot_price_pt', 'today_average') -%}
{% set CGS = state_attr(this.entity_id, 'CGS') -%}
{% set Perdas = state_attr(this.entity_id, 'Perdas') -%}
{% set k = state_attr(this.entity_id, 'k') -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h in state_attr('sensor.omie_spot_price_pt', 'today_hours') -%}
{% set TAR = 36.5 if h.date().isoformat() < '2024-06-01' else 62.50 -%}
{% set FTS = 0 if h.date().isoformat() < '2024-06-20' else 2.893 -%}
{% if None in [OMIE, CGS, Perdas, k, TAR, FTS] %}
{% set price = None %}
{% else %}
{% set price=((OMIE+CGS)*(1+Perdas)+k+TAR+FTS) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}
tomorrow_hours: >
{% set OMIE = state_attr('sensor.omie_spot_price_pt', 'tomorrow_average') -%}
{% set CGS = state_attr(this.entity_id, 'CGS') -%}
{% set Perdas = state_attr(this.entity_id, 'Perdas') -%}
{% set k = state_attr(this.entity_id, 'k') -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h in state_attr('sensor.omie_spot_price_pt', 'tomorrow_hours') -%}
{% set TAR = 36.5 if h.date().isoformat() < '2024-06-01' else 62.50 -%}
{% set FTS = 0 if h.date().isoformat() < '2024-06-20' else 2.893 -%}
{% if None in [OMIE, CGS, Perdas, k, TAR, FTS] %}
{% set price=None %}
{% else %}
{% set price=((OMIE+CGS)*(1+Perdas)+k+TAR+FTS) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}