REST API command/platform fails on POST to external URL (solcast)

Using the apex chart config you have kindly provided, every morning when the new day’s data comes in my forecast data graph goes a bit wrong. There’s no way I’m going to generate power at midnight, and the data from the day before certainly did not predict that.

Screenshot 2021-09-09 at 13-04-19 Overview - Home Assistant

Do you have any idea why this happens?

I was thinking it might be a timezone thing as the forecast data is in UTC (https://hatebin.com/aogimlkrfj) but that cant be it as the actual and forecast data for the rest of the day lines up.

type: custom:apexcharts-card
graph_span: 36h
span:
  start: day
  offset: '-6h'
header:
  show: true
  title: Solar Forecast
  show_states: true
now:
  show: true
  label: now
apex_config:
  legend:
    show: true
series:
  - entity: sensor.sma_inverter_power
    name: Actual
    unit: W
    fill_raw: last
    color: '#0da035'
    stroke_width: 2
    extend_to_end: false
    group_by:
      func: avg
      duration: 30min
    show:
      legend_value: false
  - entity: sensor.solcast_forecast_average_30min
    transform: return x * 1000;
    name: Past Forecast
    unit: W
    fill_raw: last
    color: '#e0b400'
    stroke_width: 2
    extend_to_end: false
    show:
      legend_value: false
  - entity: sensor.solcast_forecast_data
    type: line
    name: Future Forecast
    extend_to_end: false
    stroke_width: 2
    unit: W
    show:
      in_header: false
      legend_value: false
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
         return [new Date(entry.period_end), entry.pv_estimate*1000];
       });

Edit: I think I’ve worked it out. This sensor (for the past data) does not update while the value is a t 0 all night:

- name: solcast_forecast_average_30min
  unit_of_measurement: "kW"
  device_class: power
  state: >
    {{ state_attr('sensor.solcast_forecast_data', 'forecasts')[0].pv_estimate|default('variable is not defined')|round(2) }}

So the graph draws a curve from the last data point. Setting the graph to step line shows this:

Screenshot 2021-09-09 at 13-00-32 Overview - Home Assistant

So I think I need to force the template sensor for the 30min average to update, maybe by including now() like this:

- name: solcast_forecast_average_30min
  unit_of_measurement: "kW"
  device_class: power
  state: >
    {% set force_update = now() %}
    {{ state_attr('sensor.solcast_forecast_data', 'forecasts')[0].pv_estimate|default('variable is not defined')|round(2) }}

If that does not work I’ll try adding a random number in the 0.1 to 0.2W range every 1 minute.