Oddly the data from the energy dashboard isn’t easily reusable in other templates and the like.
I use Solcast Global Solar Power Forecast Integration for my forecasting in the energy dashboard, but have ended up getting the data I need with a REST sensor.
- platform: rest
name: "Solcast Forecast Data"
json_attributes:
- forecasts
resource: https://api.solcast.com.au/rooftop_sites/yyyy/forecasts?format=json&api_key=xxx&hours=24
method: GET
value_template: "{{ (value_json.forecasts[0].pv_estimate)|round(2) }}"
unit_of_measurement: "kW"
device_class: power
scan_interval: 8000
force_update: true
- name: solcast 24hrs forecast
state: >-
{%- set awattar_all_list = state_attr('sensor.solcast_forecast_data', 'forecasts') | map(attribute='pv_estimate') | list %}
{%- set values_all = namespace(all=[]) %}
{% for i in range(awattar_all_list | length) %}
{%- set v = (awattar_all_list[i] | float |multiply(1000) ) | int(0) %}
{%- set values_all.all = values_all.all + [ v ] %}
{%- endfor %} {{ ([states('sensor.APF_Generation_Entity')|int(0)] + values_all.all)[:48] }}
sensor.solcast_24hrs_forecast
solcast 24hrs forecast
[955, 0, 27, 122, 255, 567, 1038, 1437, 2069, 2441, 2461, 2259, 1817, 1371, 1053, 996, 997, 923, 727, 589, 393, 260, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
I use this in EMHASS: An Energy Management for Home Assistant as follows:
post_mpc_optim_solcast: "curl -i -H \"Content-Type: application/json\" -X POST -d '{\"load_cost_forecast\":{{(
([states('sensor.amber_general_price')|float(0)] +
state_attr('sensor.amber_general_forecast', 'forecasts') |map(attribute='per_kwh')|list)[:48])
}}, \"prod_price_forecast\":{{(
([states('sensor.amber_feed_in_price')|float(0)] +
state_attr('sensor.amber_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list)[:48])
}}, \"pv_power_forecast\":{{states('sensor.solcast_24hrs_forecast')
}}, \"prediction_horizon\":{{min(48,
(state_attr('sensor.amber_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list|length)+1)
}},\"soc_init\":{{(states('sensor.powerwall_charge')|float(0))/100
}},\"soc_final\":0.05,\"def_total_hours\":[2,0,0,0]}' http://localhost:5000/action/naive-mpc-optim"