ok, so how would you graph forecast in kw? the energy dashboard shows kwh but I want kw
I tried to graph kw with apex charts, but it does seem off, though kwh forecast in the energy dashboard seems to be quite accurate.
I have two rooftop sites on solcast, and create a SQL sensors which basically dumps forceast into a string from database events table:
- platform: sql
db_url: insert_db_here
queries:
- name: Solcast Total Forecast Longterm
query: >
select 1 as state,
(select concat('[',GROUP_CONCAT(event_data), ']') from events where event_type='e6331e973645645f241487cf6fae74b9' group by event_type) as west,
(select concat('[',GROUP_CONCAT(event_data), ']') from events where event_type='9cd5fbc56a558d1907aa0423d5e2c308' group by event_type) as south
column: "state"
Which gives me sensor sensor.solcast_total_forecast_longterm
with two attributes south
and west
which contain json data, e.g:
state: 1
west: [{"period_end": "2022-02-09T13:00:00+02:00", "pv_estimate": 0.54885}, .... ]
south: [{"period_end": "2022-02-09T13:00:00+02:00", "pv_estimate": 0.9862},....]
And then tried to render it with apex charts and overlay it with current solar production from my inverter:
- type: custom:apexcharts-card
graph_span: 36h
apex_config:
chart:
height: 200px
span:
start: day
offset: -6h
now:
show: true
label: Now
header:
show: true
title: Actual vs Forecast
show_states: true
series:
- entity: sensor.solar_active_power
name: Actual
transform: return x / 1000;
stroke_width: 2
unit: kW
fill_raw: last
color: '#0da035'
group_by:
func: avg
duration: 30min
show:
legend_value: false
extend_to_end: false
- entity: sensor.solcast_total_forecast_longterm
type: line
extend_to_end: false
unit: kW
stroke_width: 1
name: Forecast
type: area
show:
legend_value: false
in_header: 'raw'
data_generator: |
const south = JSON.parse(entity.attributes.south);
return JSON.parse(entity.attributes.west).map((record, index) => {
return [
new Date(record.period_end).getTime(),
Number(record.pv_estimate) + Number(south[index].pv_estimate)
];
});
Yet the kwh from energy seem to match:
but the kw forcast not so:
anything simpler? I know that there are people using both the integration and manual fetching but … maybe this could all be done via integration itself?