@@ -127,15 +127,16 @@ bool PriceService::isExportPricesDifferentFromImport() {
127127}
128128
129129float PriceService::getPricePoint (uint8_t direction, uint8_t point) {
130- float value = getFixedPrice (direction, point * getResolutionInMinutes () / 60 );
130+ float value = getFixedPrice (direction, point);
131131 if (value == PRICE_NO_VALUE) value = getEnergyPricePoint (direction, point);
132132 if (value == PRICE_NO_VALUE) return PRICE_NO_VALUE;
133133
134134 tmElements_t tm;
135135 time_t ts = time (nullptr );
136- breakTime (tz ->toLocal (ts), tm);
136+ breakTime (entsoeTz ->toLocal (ts), tm);
137137 tm.Hour = tm.Minute = tm.Second = 0 ;
138- breakTime (makeTime (tm) + (point * SECS_PER_MIN * getResolutionInMinutes ()), tm);
138+ ts = entsoeTz->toUTC (makeTime (tm)) + (point * SECS_PER_MIN * getResolutionInMinutes ());
139+ breakTime (tz->toLocal (ts), tm);
139140
140141 for (uint8_t i = 0 ; i < priceConfig.size (); i++) {
141142 PriceConfig pc = priceConfig.at (i);
@@ -162,15 +163,14 @@ float PriceService::getPricePoint(uint8_t direction, uint8_t point) {
162163
163164float PriceService::getCurrentPrice (uint8_t direction) {
164165 time_t ts = time (nullptr );
165- tmElements_t tm;
166- breakTime (tz->toLocal (ts), tm);
167166 uint8_t pos = getCurrentPricePointIndex ();
168167
169168 return getPricePoint (direction, pos);
170169}
171170
172171float PriceService::getEnergyPricePoint (uint8_t direction, uint8_t point) {
173172 uint8_t pos = point;
173+
174174 float multiplier = 1.0 ;
175175 uint8_t numberOfPointsToday = 24 ;
176176 if (today != NULL ) {
@@ -206,10 +206,10 @@ float PriceService::getPriceForRelativeHour(uint8_t direction, int8_t hour) {
206206 time_t ts = time (nullptr );
207207 tmElements_t tm;
208208
209- breakTime (tz ->toLocal (ts), tm);
210- int8_t targetHour = tm.Hour + hour;
209+ breakTime (entsoeTz ->toLocal (ts), tm);
210+ uint8_t targetHour = tm.Hour + hour;
211211 tm.Hour = tm.Minute = tm.Second = 0 ;
212- time_t startOfDay = tz ->toUTC (makeTime (tm));
212+ time_t startOfDay = entsoeTz ->toUTC (makeTime (tm));
213213
214214 if ((ts + (hour * SECS_PER_HOUR)) < startOfDay) {
215215 return PRICE_NO_VALUE;
@@ -235,15 +235,15 @@ float PriceService::getPriceForRelativeHour(uint8_t direction, int8_t hour) {
235235 return valueSum / valueCount;
236236}
237237
238- float PriceService::getFixedPrice (uint8_t direction, int8_t hour ) {
238+ float PriceService::getFixedPrice (uint8_t direction, int8_t point ) {
239239 time_t ts = time (nullptr );
240240
241241 tmElements_t tm;
242+ breakTime (entsoeTz->toLocal (ts), tm);
243+ tm.Hour = tm.Minute = tm.Second = 0 ;
244+ ts = entsoeTz->toUTC (makeTime (tm)) + (point * SECS_PER_MIN * getResolutionInMinutes ());
242245 breakTime (tz->toLocal (ts), tm);
243- tm.Hour = hour;
244- tm.Minute = 0 ;
245- tm.Second = 0 ;
246- breakTime (makeTime (tm), tm);
246+ tm.Minute = tm.Second = 0 ;
247247
248248 float value = PRICE_NO_VALUE;
249249 for (uint8_t i = 0 ; i < priceConfig.size (); i++) {
@@ -760,6 +760,6 @@ bool PriceService::timeIsInPeriod(tmElements_t tm, PriceConfig pc) {
760760uint8_t PriceService::getCurrentPricePointIndex () {
761761 time_t ts = time (nullptr );
762762 tmElements_t tm;
763- breakTime (tz ->toLocal (ts), tm);
763+ breakTime (entsoeTz ->toLocal (ts), tm);
764764 return ((tm.Hour * 60 ) + tm.Minute ) / getResolutionInMinutes ();
765765}
0 commit comments