I didn’t use things or items, just a rule.
This rule checks the forecast production for the day and if it is low, heats the water by gas.
rule SolarForecast
when
Time cron "0 0 6 ? * MON,TUE,WED,THU,FRI *" or // 6am weekdays
Time cron "0 0 7 ? * SUN,SAT *" // 7am weekends
then
val String forecastJSON = sendHttpGetRequest("https://api.solcast.com.au/rooftop_sites/xxxxx/forecasts?format=json&hours=18&api_key=yyyyy")
// logWarn("rules.SolarForecast", "Solcast: "+forecastJSON)
var Number Sum = 0
for (var i = 0 ; i < (35) ; i++) { //for each HH forecast
var Number Power = (Double::parseDouble(transform("JSONPATH", "$.forecasts["+i+"].pv_estimate", forecastJSON))) //extract the rate and convert to a number
Sum = Sum + Power // Add the value to the sum
// logWarn("rules.SolarForecast", "Power: "+Power.toString+" Sum: "+Sum.toString)
}
Sum = Sum / 2.11 // Estimated constant to account for periods being HH and correction factor
logWarn("rules.SolarForecast", "Forecast Sum: "+Sum.toString)
Solar_forecast.sendCommand(Sum)
if (Sum < 8 ) {
Hot_Water_Boost.sendCommand(2) // Set hot water on for two hours
logWarn("rules.SolarForecast", "Hot water boosted by low solar forecast")
}
end
If you sum up the average production for each half hour period, you need to half it to get to kWh. I’ve also found having looked at how this is performing, I needed to slightly correct the result so there is a correction factor included, which you may need to adjust.
There are a couple of commented out logging functions that you can use during testing to make sure it’s working as expected.
You need to replace xxxxx and yyyyy in the URL with your site ID and API key respectively. Both can be found by logging into the Solcast web portal.