You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Coopérnico Base - Tarifário Bi-horário (ciclo diário)
template:
sensor:
- unique_id: coopernico_spot_price_bihorariounit_of_measurement: '€/MWh'availability: "{{ has_value('sensor.omie_spot_price_pt') }}"state_class: measurementstate: > {% set PM = states('sensor.omie_spot_price_pt')|float -%} {% set MAJ = states('sensor.omie_adjustment_price_pt')|float(0) -%} {% set CGS = 4 -%} {% set k = 10 -%} {% set FP = 0.15 -%} {% set TAR_vazio = 9.2 -%} {% set TAR_fora_vazio = 50.2 -%} {% set TAR = TAR_vazio if now().hour < 8 or now().hour > 21 else TAR_fora_vazio -%} {{ ((PM + CGS + k)*(1 + FP) + TAR) | round(2) }} {{ ((PM + CGS + k)*(1 + FP) + MAJ + TAR) | round(2) }}attributes:
friendly_name: "Coopérnico Base (tarifário bi-horário)"formula: "(PM+CGS+K)*(1+FP)+TAR"formula: "(PM+CGS+K)*(1+FP)+MIBEL+TAR"PM: "{{ states('sensor.omie_spot_price_pt')|float }}"MIBEL: "{{ states('sensor.omie_adjustment_price_pt')|float(None) }}"CGS: "{{ 4 | float }}"k: "{{ 10 | float }}"FP: "{{ 0.15 | float }}"TAR_vazio: "{{ 9.2 }}"TAR_fora_vazio: "{{ 50.2 }}"today_hours: > {% set CGS = 4 -%} {% set k = 10 -%} {% set FP = 0.15 -%} {% set TAR_vazio = 9.2 -%} {% set TAR_fora_vazio = 50.2 -%} {% set ns = namespace(hourly_data=[]) %} {% for h, PM in state_attr('sensor.omie_spot_price_pt', 'today_hours').items() -%} {% for h, PM in state_attr('sensor.omie_spot_price_pt', 'today_hours').items() -%} {% set MAJ = state_attr('sensor.omie_adjustment_price_pt', 'today_hours').get(h, None) | float(0) -%} {% set TAR = TAR_vazio if h.hour < 8 or h.hour > 21 else TAR_fora_vazio -%} {% if PM == None %} {% set price=PM %} {% else %} {% set TAR = TAR_vazio if h.hour < 8 or h.hour > 21 else TAR_fora_vazio -%} {% set price=((PM + CGS + k)*(1 + FP) + TAR) | round(2) %} {% set price=((PM + CGS + k)*(1 + FP) + MAJ + 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 k = 10 -%} {% set FP = 0.15 -%} {% set TAR_vazio = 9.2 -%} {% set TAR_fora_vazio = 50.2 -%} {% set ns = namespace(hourly_data=[]) %} {% for h, PM in state_attr('sensor.omie_spot_price_pt', 'tomorrow_hours').items() -%} {% if PM == None %} {% set MAJ = state_attr('sensor.omie_adjustment_price_pt', 'tomorrow_hours').get(h, None) | float(0) -%} {% set TAR = TAR_vazio if h.hour < 8 or h.hour > 21 else TAR_fora_vazio -%} {% if PM == None or MAJ == None %} {% set price=PM %} {% else %} {% set TAR = TAR_vazio if h.hour < 8 or h.hour > 21 else TAR_fora_vazio -%} {% set price=((PM + CGS + k)*(1 + FP) + TAR) | round(2) %} {% set price=((PM + CGS + k)*(1 + FP) + MAJ + TAR) | round(2) %} {% endif %} {% set ns.hourly_data=ns.hourly_data + [(h.isoformat(), price)] %} {% endfor -%} {{ dict(ns.hourly_data) }}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters