As winter turned to spring my thoughts for my HEMS turned to thinking about how to adjust the operation of the HEMS in managing battery charging to account for anticipated solar production. Previously the HEMS was configured to buy a preset number of hours of charge from the grid each day, typically overnight when the power tends to be cheapest. Through 2019 as the seasons changed I periodically adjusted this figure to create headroom to store charge from the solar panels later in the day. However I would like to make this adjustment automatically day by day.
Late last year I came across solcast a website that predicts the output of solar panels. The user creates an account, describes their PV array (location, capacity and orientation), and can then download predictions via API.
The orange line shows the predicted output for the next few days, with the light grey area showing the confidence interval from 10 to 90%. As a prediction there’s a degree of uncertainty associated with the prediction as there is with a weather forecast. The 10% line shows that 1 day in 10 the output will be lower than the grey area, while the 90% line shows that 1 day in 10 then output will be higher than the grey area.
My original prediction were based on the orange line (the 50th percentile) where output was equally likely to be above or below this amount. However my risk on an incorrect prediction is not even. If I fail to buy enough power from the grid when the price is low then I risk paying up to 35p/kWh to buy when the price is high, whereas if I buy an unnecessary cheap kWh from the grid I may spend an unnecessary 5p/kWh on average. Thus I decided to take a more conservative position on risk to obtain the lowest cost position. I opted for a 20% risk, so 1 day in 5 I might underestimate my purchase from the grid reflecting the ratio of grid prices high:low. I estimated this 20th percentile assuming a normal distribution on the low side where the 20th percentile = 0.34 * 50th percentile + 0.66 * 10th percentile.
The process is as follows:
- download the data in a half-hourly format to be comparable to the half-hourly Agile electricity price data,
- calculate the 20th percentile from the 10th and 50th percentiles,
- count the number of half-hours in the 20th percentile data above a threshold that provides for charging the battery at full power,
- establish the earliest half hour when solar would charge the battery at full power,
- adjust the period for buying power from the grid by the period anticipated for solar charging (tomorrow a total of 7 hours is to be achieved by 6.5 hours from solar leaving 0.5 hours from the grid),
- adjust the end time for buying power from the grid to align with the earliest hour when the battery can charge at full power from solar.
The result of these calculations can be seen above. One half-hour of lowest price battery charging has been identified overnight to meet the requirement for charging from the grid. Normal HEMS behaviour has also identified several other periods of grid charging at lower cost during the day, but these are not counted towards the target for buying from the grid due to the potential for a double count of solar and grid charging during the day. (In a similar manner there are multiple start times during the afternoon when the dishwasher or washing machine can be run on grid power more cheaply than the optimal overnight start time.)
No explicit command from the HEMS is required to enable proportional charging of the battery from the solar panels when there is a solar surplus as 2 of the 3 used battery operating modes (normal and charge-only) have this capability, and the third mode force charges the battery. If the battery is force charged during solar surplus then the source of the energy will of course be the solar panels, but any shortfall will be met from the grid.
|Proportional to solar surplus
|Proportional to shortfall
|Used at high grid prices (today discharging enabled at > 8 p/kWh)
|Proportional to solar surplus
|Used at mid grid price to save stored energy for period of higher grid price (between 5 and 8 p/kWh today)
|Used at lower grid price to buy from grid (today buying at < 5p/kWh). If low price occurs at time with reasonable solar generation then use of solar output will happen automatically, with only any shortfall coming from the grid.