View difference between Paste ID: FwakQFhE and cqcLFuLF
SHOW: | | - or go back to the newest paste.
1
template:
2
  - sensor:
3
    - name: "Electricity Cost"
4
      unique_id: electricity_cost
5
      device_class: monetary
6
      unit_of_measurement: "kr/kWh"
7
      state: >
8
        {{ 1.25 * (float(states('sensor.eloverblik_tariff_sum')) + float(states('sensor.nordpool'))) }}
9
      attributes:
10
        today: >
11
          {% if state_attr('sensor.eloverblik_tariff_sum', 'hourly') and state_attr('sensor.nordpool', 'today') %}
12
            {% set ns = namespace (prices=[]) %}
13
            {% for h in range(24) %}
14
              {% set ns.prices = ns.prices + [(1.25 * (float(state_attr('sensor.eloverblik_tariff_sum', 'hourly')[h]) + float(state_attr('sensor.nordpool', 'today')[h]))) | round(5)] %}
15
            {% endfor %}
16
            {{ ns.prices }}
17
          {% endif %}
18
        tomorrow: >
19
          {% if state_attr('sensor.eloverblik_tariff_sum', 'hourly') and state_attr('sensor.nordpool', 'tomorrow') %}
20
            {% set ns = namespace (prices=[]) %}
21
            {% for h in range(24) %}
22
              {% set ns.prices = ns.prices + [(1.25 * (float(state_attr('sensor.eloverblik_tariff_sum', 'hourly')[h]) + float(state_attr('sensor.nordpool', 'tomorrow')[h]))) | round(5)] %}
23
            {% endfor %}
24
            {{ ns.prices }}
25
          {% endif %}