Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- today_ranks: >
- {% set handled = namespace(list=[]) %}
- {% set break = namespace(found=0) %}
- {% set rank = namespace(slot=0) %}
- {% set time = namespace(slot=0) %}
- {% set output = namespace(value=[]) %}
- {% for price in state_attr("sensor.shf_electricity_price_now", "today_prices") %}
- {% set time.slot = loop.index0 %}
- {% for price2 in state_attr("sensor.shf_electricity_price_now", "today_prices")|sort %}
- {% if price==price2 and break.found==0 %}
- {% set rank.slot = loop.index0 %}
- {% for x in handled.list %}
- {% if rank.slot==handled.list[loop.index0] %}
- {% set break.found=2 %}
- {% endif %}
- {% endfor %}
- {% if break.found==0 %}
- {% set output.value = output.value + [loop.index] %}
- {% set handled.list = handled.list + [rank.slot] %}
- {% set break.found=1 %}
- {% elif break.found==2 %}
- {% set break.found=0 %}
- {% endif %}
- {% endif %}
- {% endfor %}
- {% set break.found=0 %}
- {% endfor %}
- {{output.value}}
- tomorrow_ranks: >
- {% set handled = namespace(list=[]) %}
- {% set break = namespace(found=0) %}
- {% set rank = namespace(slot=0) %}
- {% set time = namespace(slot=0) %}
- {% set output = namespace(value=[]) %}
- {% for price in state_attr("sensor.shf_electricity_price_now", "tomorrow_prices") %}
- {% set time.slot = loop.index0 %}
- {% for price2 in state_attr("sensor.shf_electricity_price_now", "tomorrow_prices")|sort %}
- {% if price==price2 and break.found==0 %}
- {% set rank.slot = loop.index0 %}
- {% for x in handled.list %}
- {% if rank.slot==handled.list[loop.index0] %}
- {% set break.found=2 %}
- {% endif %}
- {% endfor %}
- {% if break.found==0 %}
- {% set output.value = output.value + [loop.index] %}
- {% set handled.list = handled.list + [rank.slot] %}
- {% set break.found=1 %}
- {% elif break.found==2 %}
- {% set break.found=0 %}
- {% endif %}
- {% endif %}
- {% endfor %}
- {% set break.found=0 %}
- {% endfor %}
- {{output.value}}
Advertisement
Add Comment
Please, Sign In to add comment