PV Forecast get highest value of today

Hello,

i use solcast as pv forecast. To trigger automations i need the highest value of today and the timestamp.

My sensor has an array for the forecast.

detailedForecast: 
- period_start: '2025-04-15T00:00:00+02:00'
  pv_estimate: 0
  pv_estimate10: 0
  pv_estimate90: 0
- period_start: '2025-04-15T00:30:00+02:00'
  pv_estimate: 0
  pv_estimate10: 0
  pv_estimate90: 0
- period_start: '2025-04-15T01:00:00+02:00'
  pv_estimate: 0
  pv_estimate10: 0
  pv_estimate90: 0
- period_start: '2025-04-15T01:30:00+02:00'
  pv_estimate: 0
  pv_estimate10: 0
  pv_estimate90: 0
....

I created a template to get the max value of today:

{{ state_attr('sensor.solcast_pv_forecast_prognose_heute' , 'detailedForecast')[:48]| map(attribute='pv_estimate')| list | max }}

But how do i get the related timestamp to the value? So that i can see, when the max value is, today?

Second question:
How can i trigger my automation, that it starts when the forecast says, now its the max value?

Try this. I tested it on my solcast data but it is a slightly different format from yours so I then adapted it:

{% set data = state_attr('sensor.solcast_pv_forecast_prognose_heute' , 'detailedForecast') %}
{{ data | selectattr('pv_estimate', 'eq', data | map(attribute='pv_estimate') | list | max) | map(attribute='period_start') | join }}

thanks. I got the timestamp.

Can you help me, for my second question?

triggers:
  - trigger: time
    at: sensor.your_pv_max_time_sensor_here
1 Like

thanks, that was to simple :wink: