Coopérnico Base Simples - luuuis/hass_omie GitHub Wiki
Coopérnico Base - Tarifário Simples

template:
sensor:
- unique_id: coopernico_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 CGS = 4 -%}
{% set TSE = 2.893 -%}
{% set k = 10 -%}
{% set FP = 0.16 -%}
{% set TAR = 60.0 if now().date().isoformat() < '2025-06-01' else 60.0 -%}
{{ ((PM + CGS + TSE + k)*(1 + FP) + TAR) | round(2) }}
attributes:
friendly_name: "Coopérnico Base (tarifário simples)"
formula: "(PM+CGS+TSE+K)*(1+FP)+TAR"
PM: "{{ states('sensor.omie_spot_price_pt')|float }}"
CGS: "{{ 4 }}"
TSE: "{{ 2.893 }}"
k: "{{ 10 }}"
FP: "{{ 0.16 }}"
TAR: "{{ 60.0 if now().date().isoformat() < '2025-06-01' else 60.0 }}"
today_hours: >
{% set CGS = 4 -%}
{% set TSE = 2.893 -%}
{% set k = 10 -%}
{% set FP = 0.15 -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, PM in state_attr('sensor.omie_spot_price_pt', 'today_hours').items() -%}
{% set TAR = 60.0 if h.date().isoformat() < '2025-06-01' else 60.0 -%}
{% 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.15 -%}
{% set ns = namespace(hourly_data=[]) %}
{% for h, PM in state_attr('sensor.omie_spot_price_pt', 'tomorrow_hours').items() -%}
{% set TAR = 60.0 if h.date().isoformat() < '2025-06-01' else 60.0 -%}
{% 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) }}