@@ -78,10 +78,9 @@ export class DayAheadPrices extends ConfigComponent<"day_ahead_prices/config", {
78
78
}
79
79
80
80
get_price_timeframe ( ) {
81
- let config = API . get ( "day_ahead_prices/config" ) ;
82
81
let time = new Date ( ) ;
83
82
let s = ""
84
- if ( config . resolution == 0 ) {
83
+ if ( this . state . resolution == 0 ) {
85
84
time . setMilliseconds ( Math . floor ( time . getMilliseconds ( ) / 1000 ) * 1000 ) ;
86
85
time . setSeconds ( Math . floor ( time . getSeconds ( ) / 60 ) * 60 ) ;
87
86
time . setMinutes ( Math . floor ( time . getMinutes ( ) / 15 ) * 15 ) ;
@@ -105,13 +104,10 @@ export class DayAheadPrices extends ConfigComponent<"day_ahead_prices/config", {
105
104
return ;
106
105
}
107
106
108
- let state = API . get ( "day_ahead_prices/state" ) ;
109
- let prices = API . get ( "day_ahead_prices/prices" ) ;
110
- let config = API . get ( "day_ahead_prices/config" ) ;
111
107
let data : UplotData ;
112
108
113
109
// If we have not got any prices yet, use empty data
114
- if ( prices . prices . length == 0 ) {
110
+ if ( this . state . prices . prices . length == 0 ) {
115
111
data = {
116
112
keys : [ ] ,
117
113
names : [ ] ,
@@ -135,12 +131,12 @@ export class DayAheadPrices extends ConfigComponent<"day_ahead_prices/config", {
135
131
update_timestamp : 0 ,
136
132
use_timestamp : 0
137
133
}
138
- let resolution_multiplier = prices . resolution == 0 ? 15 : 60
139
- for ( let i = 0 ; i < prices . prices . length ; i ++ ) {
140
- data . values [ 0 ] . push ( prices . first_date * 60 + i * 60 * resolution_multiplier ) ;
141
- data . values [ 1 ] . push ( prices . prices [ i ] / 1000.0 ) ;
142
- data . values [ 2 ] . push ( config . grid_costs_and_taxes / 1000.0 ) ;
143
- data . values [ 3 ] . push ( config . supplier_markup / 1000.0 ) ;
134
+ let resolution_multiplier = this . state . prices . resolution == 0 ? 15 : 60
135
+ for ( let i = 0 ; i < this . state . prices . prices . length ; i ++ ) {
136
+ data . values [ 0 ] . push ( this . state . prices . first_date * 60 + i * 60 * resolution_multiplier ) ;
137
+ data . values [ 1 ] . push ( this . state . prices . prices [ i ] / 1000.0 ) ;
138
+ data . values [ 2 ] . push ( this . state . grid_costs_and_taxes / 1000.0 ) ;
139
+ data . values [ 3 ] . push ( this . state . supplier_markup / 1000.0 ) ;
144
140
}
145
141
}
146
142
@@ -193,11 +189,11 @@ export class DayAheadPrices extends ConfigComponent<"day_ahead_prices/config", {
193
189
/>
194
190
</ FormRow >
195
191
< FormRow label = { __ ( "day_ahead_prices.content.grid_fees_and_taxes" ) } label_muted = { __ ( "day_ahead_prices.content.optional_muted" ) } >
196
- < InputFloat value = { dap . grid_costs_and_taxes } onValue = { this . set ( ' grid_costs_and_taxes' ) } digits = { 3 } unit = { 'ct/kWh' } max = { 99000 } min = { 0 } />
192
+ < InputFloat value = { dap . grid_costs_and_taxes } onValue = { ( v ) => { this . setState ( { grid_costs_and_taxes : v } , function ( ) { this . update_uplot ( ) } ) } } digits = { 3 } unit = { 'ct/kWh' } max = { 99000 } min = { 0 } />
197
193
< div class = "invalid-feedback" > { __ ( "day_ahead_prices.content.price_invalid" ) } </ div >
198
194
</ FormRow >
199
195
< FormRow label = { __ ( "day_ahead_prices.content.electricity_provider_surcharge" ) } label_muted = { __ ( "day_ahead_prices.content.optional_muted" ) } >
200
- < InputFloat value = { dap . supplier_markup } onValue = { this . set ( ' supplier_markup' ) } digits = { 3 } unit = { 'ct/kWh' } max = { 99000 } min = { 0 } />
196
+ < InputFloat value = { dap . supplier_markup } onValue = { ( v ) => { this . setState ( { supplier_markup : v } , function ( ) { this . update_uplot ( ) } ) } } digits = { 3 } unit = { 'ct/kWh' } max = { 99000 } min = { 0 } />
201
197
< div class = "invalid-feedback" > { __ ( "day_ahead_prices.content.price_invalid" ) } </ div >
202
198
</ FormRow >
203
199
< FormRow label = { __ ( "day_ahead_prices.content.electricity_provider_base_fee" ) } label_muted = { __ ( "day_ahead_prices.content.optional_muted" ) } >
0 commit comments