-
Notifications
You must be signed in to change notification settings - Fork 7
Luzboa excedente indexado
Luis Miranda edited this page May 23, 2023
·
1 revision
template:
sensor:
- unique_id: luzboa_excedente_indexado
unit_of_measurement: '€/MWh'
state_class: measurement
state: >
{% set CG = 0.20 -%}
{% set PM = state_attr('sensor.omie_spot_price_pt', 'today_average') -%}
{{ (PM*(1-CG)) | round(2) }}
attributes:
friendly_name: "Luzboa excedente (indexado)"
formula: "PM * (1 – CG)"
PM: "{{ state_attr('sensor.omie_spot_price_pt', 'today_average') }}"
CG: "{{ 0.20 | float }}"
today_hours: >
{% set CG = 0.20 -%}
{% set PM = state_attr('sensor.omie_spot_price_pt', 'today_average') -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, _ in state_attr('sensor.omie_spot_price_pt', 'today_hours').items() -%}
{% if PM == None or MAJ == None %}
{% set price=PM %}
{% else %}
{% set price=(PM*(1-CG)) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}
tomorrow_hours: >
{% set CG = 0.20 -%}
{% set PM = state_attr('sensor.omie_spot_price_pt', 'tomorrow_average') -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, _ in state_attr('sensor.omie_spot_price_pt', 'tomorrow_hours').items() -%}
{% if PM == None or MAJ == None %}
{% set price=PM %}
{% else %}
{% set price=(PM*(1-CG)) | round(2) %}
{% endif %}
{% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %}
{% endfor -%}
{{ dict(ns.hourly_data) }}