natbesh
(Nate Besh)
September 18, 2023, 4:51am
1
The problem
I’m not getting any graph lines for the forecasted data when using apex charts to show the solcast integration data.
There’s data for the integration - but i cant get it to display, most likely me nuffing up syntax somewhere.
Troubleshooting so far:
There’s data from the solcast integration
I’m seeing updates for the sensors that i’m using “sensor.solcast_pv_forecast_forecast_today”
The sensors are showing the totals in the graph on the dashboard, just not the lines
i’ve reloaded the solcast integration
i’ve reloaded HA
still no joy…
Here’s what it looks like:
Looking at the sensor “sensor.solcast_pv_forecast_forecast_today” in HA integrations:
Attributes:
DetailedForecast
period_start: ‘2023-09-18T00:00:00+10:00’
pv_estimate: 0
pv_estimate10: 0
pv_estimate90: 0
period_start: ‘2023-09-18T00:30:00+10:00’
pv_estimate: 0
pv_estimate10: 0
pv_estimate90: 0
Here’s the code to generate the graph:
data_generator: |
return entity.attributes.detailedforecast.map((entry) => {
return [new Date(entry.period_start), entry.pv_estimate];
});
Full Code:
type: custom:apexcharts-card
apex_config:
chart:
height: 350px
all_series_config:
unit: ' kWh'
header:
title: Solar forecast
show: true
standard_format: true
show_states: true
colorize_states: true
graph_span: 2d
span:
start: day
offset: '-0h'
now:
show: true
label: Now
yaxis:
* id: kwh
min: 0
apex_config:
tickAmount: 5
* id: header_only
show: false
series:
* entity: sensor.solcast_pv_forecast_forecast_today
yaxis_id: kwh
type: area
name: Today
color: orange
data_generator: |
return entity.attributes.detailedforecast.map((entry) => {
return [new Date(entry.period_start), entry.pv_estimate];
});
show:
legend_value: false
in_header: false
stroke_width: 3
float_precision: 2
extend_to: false
* entity: sensor.solcast_pv_forecast_forecast_tomorrow
yaxis_id: kwh
type: area
name: Tomorrow
color: orange
data_generator: |
return entity.attributes.detailedforecast.map((entry) => {
return [new Date(entry.period_start), entry.pv_estimate];
});
show:
legend_value: false
in_header: false
stroke_width: 3
float_precision: 2
extend_to: false
* entity: sensor.solcast_pv_forecast_forecast_today
yaxis_id: header_only
name: Today
color: orange
show:
legend_value: true
in_header: true
in_chart: false
* entity: sensor.solcast_pv_forecast_forecast_remaining_today
yaxis_id: header_only
name: Remaining
color: orange
show:
legend_value: true
in_header: true
in_chart: false
* entity: sensor.solcast_pv_forecast_forecast_tomorrow
yaxis_id: header_only
name: Tomorrow
color: grey
show:
legend_value: true
in_header: true
in_chart: false
njhcarroll
(njhcarroll)
November 27, 2023, 10:01am
4
I have exactly the same issue as @natbesh . Solcast is working both at site and in HA instance. I have solcast data from entities graphed via predbat but when trying to create this apex card (same code by looks) just hangs with loading message.
njhcarroll
(njhcarroll)
November 27, 2023, 9:54pm
5
Solved it. The APEX chart was calling “Forecast” rather than “detailedForecast” in the data fetch.
Revised Code:
type: custom:apexcharts-card
apex_config:
chart:
height: 350px
all_series_config:
unit: ' kWh'
header:
title: Solar forecast
show: true
standard_format: true
show_states: true
colorize_states: true
graph_span: 2d
span:
start: day
offset: '-0h'
now:
show: true
label: Now
yaxis:
- id: kwh
min: 0
apex_config:
tickAmount: 5
- id: header_only
show: false
series:
- entity: sensor.solcast_pv_forecast_forecast_today
yaxis_id: kwh
type: area
name: Today
color: orange
data_generator: |
var today = entity.attributes.detailedForecast.map((start, index) => {
return [new Date(start["period_start"]).getTime(), entity.attributes.detailedForecast[index]["pv_estimate"]];
});
var data = today
return data;
show:
legend_value: false
in_header: false
stroke_width: 3
float_precision: 2
extend_to: false
- entity: sensor.solcast_pv_forecast_forecast_tomorrow
yaxis_id: kwh
type: area
name: Tomorrow
color: grey
data_generator: |
var today = entity.attributes.detailedForecast.map((start, index) => {
return [new Date(start["period_start"]).getTime(), entity.attributes.detailedForecast[index]["pv_estimate"]];
});
var data = today
return data;
show:
legend_value: false
in_header: false
stroke_width: 3
float_precision: 2
extend_to: false
- entity: sensor.solcast_pv_forecast_forecast_today
yaxis_id: header_only
name: Today
color: orange
show:
legend_value: true
in_header: true
in_chart: false
- entity: sensor.solcast_pv_forecast_forecast_remaining_today
yaxis_id: header_only
name: Remaining
color: orange
show:
legend_value: true
in_header: true
in_chart: false
- entity: sensor.solcast_pv_forecast_forecast_tomorrow
yaxis_id: header_only
name: Tomorrow
color: grey
show:
legend_value: true
in_header: true
in_chart: false
- entity: sensor.solcast_pv_forecast_api_last_polled
yaxis_id: header_only
name: Last update
unit: ' min.'
transform: return ((Date.now()) - (new Date(x).getTime())) / 60 / 60 / 24
show:
legend_value: true
in_header: true
in_chart: false
4 Likes
This has been baffling me for days. thanks for the fix!!!
jfd141
(John F Dawson)
March 12, 2024, 9:22pm
7
It looks to me as if the graphs should be in kW not kWh, or I am misunderstanding. Otherwise many thanks for this excellent example. Just what I needed to get going with Solcast.