@@ -78,10 +78,9 @@ export class DayAheadPrices extends ConfigComponent<"day_ahead_prices/config", {
7878 }
7979
8080 get_price_timeframe ( ) {
81- let config = API . get ( "day_ahead_prices/config" ) ;
8281 let time = new Date ( ) ;
8382 let s = ""
84- if ( config . resolution == 0 ) {
83+ if ( this . state . resolution == 0 ) {
8584 time . setMilliseconds ( Math . floor ( time . getMilliseconds ( ) / 1000 ) * 1000 ) ;
8685 time . setSeconds ( Math . floor ( time . getSeconds ( ) / 60 ) * 60 ) ;
8786 time . setMinutes ( Math . floor ( time . getMinutes ( ) / 15 ) * 15 ) ;
@@ -105,13 +104,10 @@ export class DayAheadPrices extends ConfigComponent<"day_ahead_prices/config", {
105104 return ;
106105 }
107106
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" ) ;
111107 let data : UplotData ;
112108
113109 // 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 ) {
115111 data = {
116112 keys : [ ] ,
117113 names : [ ] ,
@@ -135,12 +131,12 @@ export class DayAheadPrices extends ConfigComponent<"day_ahead_prices/config", {
135131 update_timestamp : 0 ,
136132 use_timestamp : 0
137133 }
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 ) ;
144140 }
145141 }
146142
@@ -193,11 +189,11 @@ export class DayAheadPrices extends ConfigComponent<"day_ahead_prices/config", {
193189 />
194190 </ FormRow >
195191 < 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 } />
197193 < div class = "invalid-feedback" > { __ ( "day_ahead_prices.content.price_invalid" ) } </ div >
198194 </ FormRow >
199195 < 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 } />
201197 < div class = "invalid-feedback" > { __ ( "day_ahead_prices.content.price_invalid" ) } </ div >
202198 </ FormRow >
203199 < FormRow label = { __ ( "day_ahead_prices.content.electricity_provider_base_fee" ) } label_muted = { __ ( "day_ahead_prices.content.optional_muted" ) } >
0 commit comments