-
Notifications
You must be signed in to change notification settings - Fork 13
/
npf.yaml
156 lines (152 loc) · 4.14 KB
/
npf.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
type: custom:apexcharts-card
now:
show: true
label: now
graph_span: 5d
experimental:
color_threshold: true
apex_config:
grid:
show: true
borderColor: dimgray
strokeDashArray: 4
chart:
height: 192px
legend:
showForSingleSeries: false
show: false
plotOptions:
bar:
borderRadius: 0
yaxis:
decimalsInFloat: 1
forceNiceScale: true
xaxis:
labels:
datetimeFormatter:
minute: HH:mm
day: ddd
all_series_config:
show:
offset_in_name: true
header:
title: Nordpool spot FI ¢/kWh, VAT
show: true
show_states: true
colorize_states: true
span:
start: day
series:
- entity: sensor.nordpool_kwh_fi_eur_3_10_0
name: Today ¢/kWh
type: column
float_precision: 1
stroke_width: 0
opacity: 1
show:
in_header: false
legend_value: false
extremas: true
data_generator: |
return entity.attributes.raw_today.map((start, index) => {
return [new Date(start["start"]).getTime(), entity.attributes.raw_today[index]["value"]*125.5];
});
color: '#aaaaaa'
color_threshold:
- value: 0
color: lime
- value: 5
color: green
- value: 10
color: orange
- value: 15
color: red
- value: 20
color: darkred
- value: 30
color: purple
- entity: sensor.nordpool_kwh_fi_eur_3_10_0
name: Tomorrow ¢/kWh
type: column
float_precision: 1
opacity: 1
unit: ¢/kWh
stroke_width: 0
data_generator: |
return entity.attributes.raw_tomorrow.map((entry) => {
return [new Date(entry.start), entry.value*125.5];
});
color_threshold:
- value: 0
color: lime
- value: 5
color: green
- value: 10
color: orange
- value: 15
color: red
- value: 20
color: darkred
- value: 30
color: purple
show:
legend_value: false
in_header: false
extremas: true
- entity: sensor.nordpool_kwh_fi_eur_3_10_0
name: Prediction ¢/kWh
type: column
float_precision: 1
stroke_width: 0
opacity: 1
unit: ¢/kWh
show:
in_header: false
legend_value: false
extremas: false
color_threshold:
- value: 0
color: lime
- value: 5
color: green
- value: 10
color: orange
- value: 15
color: red
- value: 20
color: darkred
- value: 30
color: black
data_generator: |
const processData = async () => {
const now = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const todayTimestamp = today.getTime();
const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
const tomorrowTimestamp = tomorrow.getTime();
const dayAfterTomorrow = new Date(tomorrow);
dayAfterTomorrow.setDate(dayAfterTomorrow.getDate() + 1);
const dayAfterTomorrowTimestamp = dayAfterTomorrow.getTime();
// Fetch prediction data
const response = await fetch('https://raw.githubusercontent.com/vividfog/nordpool-predict-fi/main/deploy/prediction.json');
const predictionData = await response.json();
// Filter prediction data based on the logic
const filteredPredictionData = predictionData.filter(([timestamp, value]) => {
const dateTimestamp = new Date(timestamp).getTime();
// Exclude today's data
if (dateTimestamp >= todayTimestamp && dateTimestamp < tomorrowTimestamp) {
return false;
}
// Conditionally include tomorrow's data based on current time
if (dateTimestamp >= tomorrowTimestamp && dateTimestamp < dayAfterTomorrowTimestamp) {
return now.getHours() < 14;
}
// Always include data from day after tomorrow onwards
return dateTimestamp >= dayAfterTomorrowTimestamp;
});
// Sort by timestamp just in case
filteredPredictionData.sort((a, b) => a[0] - b[0]);
return filteredPredictionData.map(([timestamp, value]) => [parseInt(timestamp), value]);
};
return processData();