View difference between Paste ID: jSzJakXJ and z5DByNuc
SHOW: | | - or go back to the newest paste.
1
type: vertical-stack
2
cards:
3
  - type: markdown
4
    content: >
5
      Hej, {{user}}!
6
7
       <ha-icon icon="mdi:power-plug"></ha-icon>El koster lige nu **{{ (state_attr('sensor.energi_data_service',
8
      'current_price'))|replace('.',',')}}** kr.  - det er **{{
9
      (state_attr('sensor.energi_data_service', 'current_price') | float * 100
10
      /  (state_attr('sensor.energi_data_service', 'today_mean') | float * 100
11
      )| float * 100 ) | round (2)|replace('.',',')}} %** sammenlignet med andre
12
      timer i dag.
13
14
15
      Hvis du vil vaske i dag, så er de billigste timer:
16
17
      {% set l=(state_attr('sensor.energi_data_service', 'raw_today'
18
      )|sort(attribute='price')) %} 
19
20
      {% set h=(state_attr('sensor.energi_data_service', 'raw_today'
21
      )|sort(reverse=true, attribute='price')) %} 
22
23
      <ha-icon icon="mdi:clock-check"></ha-icon>
24
      &nbsp;&nbsp;&nbsp;&nbsp;Billigste time {{ l[0].hour.time()}}, Pris: {{
25
      l[0].price|replace('.',',')}} kr.
26
27
      <ha-icon icon="mdi:clock-check"></ha-icon> 2. billigste time {{
28
      l[1].hour.time() }}, Pris: {{ l[1].price|replace('.',',')}} kr.
29
30
      <ha-icon icon="mdi:clock-check"></ha-icon> 3. billigste time {{
31
      l[2].hour.time() }}, Pris: {{ l[2].price|replace('.',',')}} kr.
32
33
      <ha-icon icon="mdi:clock-check"></ha-icon> 4. billigste time {{
34
      l[3].hour.time() }}, Pris: {{ l[3].price|replace('.',',')}} kr.
35
36
      <ha-icon icon="mdi:clock-check"></ha-icon> 5. billigste time {{
37
      l[4].hour.time() }}, Pris: {{ l[4].price|replace('.',',')}} kr.
38
39
40
      Disse er de dyreste timer:
41
42
43
      <ha-icon icon="mdi:clock-alert"></ha-icon> &nbsp;&nbsp;&nbsp;&nbsp;Dyreste
44
      time {{ h[0].hour.time()}}, Pris: {{ h[0].price|replace('.',',')}} kr.
45
46
      <ha-icon icon="mdi:clock-alert"></ha-icon> 2. dyreste time {{
47
      h[1].hour.time() }}, Pris: {{ h[1].price|replace('.',',')}} kr.
48
49
      <ha-icon icon="mdi:clock-alert"></ha-icon> 3. dyreste time {{
50
      h[2].hour.time() }}, Pris: {{ h[2].price|replace('.',',')}} kr.
51
52
      <ha-icon icon="mdi:clock-alert"></ha-icon> 4. dyreste time {{
53
      h[3].hour.time() }}, Pris: {{ h[3].price|replace('.',',')}} kr.
54
55
      <ha-icon icon="mdi:clock-alert"></ha-icon> 5. dyreste time {{
56
      h[4].hour.time() }}, Pris: {{ h[4].price|replace('.',',')}} kr.
57
58
      Gennemsnitsprisen i dag er: **{{ (state_attr('sensor.energi_data_service',
59
      'today_mean'))|round(3)|replace('.',',')}}** kr. 
60
61
62
        <ha-icon icon="mdi:cash-multiple"></ha-icon> Du sparer  **{{(((state_attr('sensor.energi_data_service',
63
      'today_mean')) - l[0].price) /  (state_attr('sensor.energi_data_service',
64
      'today_mean'))| float * 100 ) | round (2)|replace('.',',')}} %** ved at
65
      vaske i den billigste time  i forhold til dagens gennemsnit.
66
67
      Eller **{{((h[0].price - l[0].price) /  h[0].price| float * 100 ) | round
68
      (2)|replace('.',',')}} %** i forhold til den dyreste time! <ha-icon
69
      icon="mdi:alert"></ha-icon> 
70
    title: Elpris i dag
71
  - type: gauge
72
    entity: sensor.energi_data_service
73
    min: 0
74
    name: Nuværende kWh-pris
75
    severity:
76
      green: 1.5
77
      yellow: 3
78
      red: 4.5
79
    needle: true
80
    unit: kr/kWh
81
    max: 9
82
  - type: custom:config-template-card
83
    entities:
84
      - sensor.energi_data_service
85
      - sensor.historic_energy_price_percentiles
86
    config_templates: default
87
    variables:
88
      max_price_threshold: |
89
        () => {
90
          return states['sensor.historic_energy_price_percentiles'].attributes['99th']
91
        }
92
      get_yellow_threshold: |
93
        () => {
94
          return states['sensor.historic_energy_price_percentiles'].attributes['25th']
95
        }
96
      get_orange_threshold: |
97
        () => {
98
          return states['sensor.historic_energy_price_percentiles'].attributes['75th']
99
        }
100
      get_darkred_threshold: |
101
        () => {
102
          return states['sensor.historic_energy_price_percentiles'].attributes['95th']
103
        }
104
    card:
105
      type: custom:apexcharts-card
106
      graph_span: 132h
107
      span:
108
        end: day
109
        offset: +108h
110
      apex_config:
111
        chart:
112
          height: 200px
113
        grid:
114
          show: true
115
          borderColor: rgb(158, 158, 158)
116
          strokeDashArray: 2
117
        annotations:
118
          position: back
119
          yaxis:
120
            - 'y': 0
121
              y2: ${ get_yellow_threshold() }
122
              fillColor: rgb(76, 175, 80)
123
              strokeDashArray: 0
124
              borderColor: '#00000000'
125
            - 'y': ${ get_yellow_threshold() }
126
              y2: ${ get_orange_threshold() }
127
              fillColor: rgb(255, 193, 7)
128
              strokeDashArray: 0
129
              borderColor: '#00000000'
130
            - 'y': ${ get_orange_threshold() }
131
              y2: ${ get_darkred_threshold() }
132
              fillColor: rgb(255, 152, 0)
133
              strokeDashArray: 0
134
              borderColor: '#00000000'
135
            - 'y': ${ get_darkred_threshold() }
136
              y2: ${ max_price_threshold() }
137
              fillColor: rgb(244, 67, 54)
138
              strokeDashArray: 0
139
              borderColor: '#00000000'
140
            - 'y': ${ max_price_threshold() }
141
              y2: 100
142
              fillColor: rgb(255, 0, 0)
143
              strokeDashArray: 0
144
              borderColor: '#00000000'
145
      header:
146
        show: true
147
        title: Elpriser pr. time (DKK/kWh)
148
        show_states: true
149
        colorize_states: true
150
      now:
151
        label: Nu
152
        show: true
153
        color: black
154
      yaxis:
155
        - min: '|-0.5|'
156
          max: '|+0.5|'
157
          apex_config:
158
            tickAmount: 4
159
            forceNiceScale: false
160
            decimalsInFloat: 1
161
      series:
162
        - name: Nu
163
          entity: sensor.energi_data_service
164
          color: rgb(33, 150, 243)
165
          float_precision: 2
166
          data_generator: |
167
            return [[new Date(), entity.state]]
168
          show:
169
            in_chart: false
170
        - name: Current
171
          entity: sensor.energi_data_service
172
          stroke_width: 3
173
          float_precision: 2
174
          type: line
175
          color: rgb(33, 150, 243)
176
          extend_to: false
177
          show:
178
            in_header: false
179
          data_generator: |
180
            var today = entity.attributes.raw_today.map((start, index) => {
181
              return [new Date(start["hour"]).getTime(), entity.attributes.raw_today[index]["price"]];
182
            });
183
    
184
            var extradata = entity.attributes.forecast.map((start, index) => {
185
              return [new Date(start["hour"]).getTime(), entity.attributes.forecast[index]["price"]];
186
            });
187
    
188
            if (entity.attributes.tomorrow_valid) {
189
              var tomorrow = entity.attributes.raw_tomorrow.map((start, index) => {
190
                return [new Date(start["hour"]).getTime(), entity.attributes.raw_tomorrow[index]["price"]];
191
              });
192
              today = today.concat(tomorrow)
193
            }
194
    
195
            return today.concat(extradata)