I bought HA to use it to monitor and control my Solar PV system. The feature that ‘sold’ it to me was the integrated Solar Forecast - however I have found it to be not entirely accurate and of little practical use as we can’t get at the data.
The big question for Solar Forecasting is not ‘how to get it’ but ‘what to do with it once you have it’. I was inspired by
https://community.home-assistant.io/t/forecast-solar-predict-when-output-power-will-be-above-predefined-level/424348
to start working on Solar Forecast, with a view to answering this very question - to decide when output power will be above a predefined level.
Getting the API calls to work was the easy bit. Next was a graph, and that is what sensor.fc_table provides. As you have answered - this holds all the values in arrays in the sensor attributes and therefore was designed to run almost directly into apex charts. I had not used apex charts before, but it was not that difficult once I got my head around the data_generator bit. Still don’t know quite how it works, but it does.
type: custom:apexcharts-card
graph_span: 3d
span:
end: day
offset: +1d
header:
show: true
title: 'Solar Forecast: yesterday - today - tomorrow'
now:
show: true
label: now
show:
last_updated: true
series:
- entity: sensor.fc_table
data_generator: |
return entity.attributes.fchours.map((fchr, index) => {
return [new Date(fchr).getTime(), entity.attributes.fcwatts[index]];
});
curve: smooth
name: Forecast
show:
in_header: false
legend_value: false
stroke_width: 2
color: orange
- entity: sensor.fc_table
data_generator: |
return entity.attributes.fchours.map((fchr, index) => {
return [new Date(fchr).getTime(), entity.attributes.fcold[index]];
});
curve: smooth
name: History
show:
in_header: false
legend_value: false
stroke_width: 2
color: magenta
- entity: sensor.fc_table
data_generator: |
return entity.attributes.fchours.map((fchr, index) => {
return [new Date(fchr).getTime(), entity.attributes.fcactual[index]];
});
curve: smooth
name: Actual
show:
in_header: false
legend_value: false
stroke_width: 2
color: blue
- entity: sensor.fc_table
data_generator: |
return entity.attributes.fchours.map((fchr, index) => {
return [new Date(fchr).getTime(), entity.attributes.fcwh[index]];
});
curve: smooth
name: Energy
show:
in_header: false
legend_value: false
stroke_width: 2
color: green
My next objective is to get the time to start an appliance given a required power level. This is where FC energy estimate sensor comes in. The state value is my estimate of the total daily energy, and the attributes hold the power table as well as the hour of start, stop, and maximum. If there are humps in the day there will also be one or more minimums.
I have got as far as being able to provide in HA an array of events for a given power level, and even sorting this for the largest duration if there are more than one - this returns ‘start’ and ‘stop’ as hh:mm, and duration in minutes. I am trying to extend this to working out, for a given power, earliest start time, and minimum duration, a return that says when the period starts, when to switch on the device, and how long you have left. Doing the unpicking of the power array in HA has defeated me, so I am now looking at using Node-RED to do the work, based on an API call from HA back to Node-RED with the query parameters - power, start, duration, with a return object containing switching states and times. Still work in progress, and I am looking to first fine-tune my forecast to better match my actual.
Hope you find the code of use!