mirror of
				https://github.com/Akkudoktor-EOS/EOS.git
				synced 2025-11-04 08:46:20 +00:00 
			
		
		
		
	Fix electricity price prediction. (#295)
The electricity price prediction provided prices in Eurocent/ kWh despite claiming the price to be in €/ kWh. Also the addition of charges was not possible. Now prices are provided in €/kWh. Charges can be configured by the `elecprice_charges` configuration option. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
		@@ -7,5 +7,8 @@ from akkudoktoreos.config.configabc import SettingsBaseModel
 | 
			
		||||
 | 
			
		||||
class ElecPriceCommonSettings(SettingsBaseModel):
 | 
			
		||||
    elecprice_provider: Optional[str] = Field(
 | 
			
		||||
        default=None, description="Electicity price provider id of provider to be used."
 | 
			
		||||
        default=None, description="Electricity price provider id of provider to be used."
 | 
			
		||||
    )
 | 
			
		||||
    elecprice_charges: Optional[float] = Field(
 | 
			
		||||
        default=None, ge=0, description="Electricity price charges (€/kWh)."
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
@@ -204,22 +204,24 @@ class ElecPriceAkkudoktor(ElecPriceProvider):
 | 
			
		||||
        elecprice_cache_file.seek(0)
 | 
			
		||||
        self.elecprice_8days = np.load(elecprice_cache_file)
 | 
			
		||||
 | 
			
		||||
        # Get elecprice_charges
 | 
			
		||||
        charges = self.config.elecprice_charges if self.config.elecprice_charges else 0.0
 | 
			
		||||
 | 
			
		||||
        for i in range(values_len):
 | 
			
		||||
            original_datetime = akkudoktor_data.values[i].start
 | 
			
		||||
            dt = to_datetime(original_datetime, in_timezone=self.config.timezone)
 | 
			
		||||
            akkudoktor_value = akkudoktor_data.values[i]
 | 
			
		||||
            price = akkudoktor_value.marketpriceEurocentPerKWh / 100 + charges
 | 
			
		||||
 | 
			
		||||
            if compare_datetimes(dt, self.start_datetime).lt:
 | 
			
		||||
                # forecast data is too old
 | 
			
		||||
                self.elecprice_8days[dt.hour, dt.day_of_week] = (
 | 
			
		||||
                    akkudoktor_value.marketpriceEurocentPerKWh
 | 
			
		||||
                )
 | 
			
		||||
                self.elecprice_8days[dt.hour, dt.day_of_week] = price
 | 
			
		||||
                continue
 | 
			
		||||
            self.elecprice_8days[dt.hour, 7] = akkudoktor_value.marketpriceEurocentPerKWh
 | 
			
		||||
            self.elecprice_8days[dt.hour, 7] = price
 | 
			
		||||
 | 
			
		||||
            record = ElecPriceDataRecord(
 | 
			
		||||
                date_time=dt,
 | 
			
		||||
                elecprice_marketprice=akkudoktor_value.marketpriceEurocentPerKWh,
 | 
			
		||||
                elecprice_marketprice=price,
 | 
			
		||||
            )
 | 
			
		||||
            self.append(record)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user