Assuming you have the hourly energy data, and you know which hours are the most energy intensive for your dishwasher, you should be able to loop through that data and find the lowest section of the day where those two hours are the lowest (given the other hours have almost no energy use).
You could do this using jinja, but its highly dependent on how you’re getting your energy data.
I use the automation below to get the min and max temperatures for the day, and also work out if its going to rain or not. This involves parsing through the hourly forecast data. I would think you could do something similar to add up the energy costs for a particular block of time and then return the lowest one.
alias: Todays Temperature
description: ""
trigger:
- platform: time
at: "07:30:00"
condition: []
action:
- device_id: xyz
domain: mobile_app
type: notify
title: Daily Forecast
message: >
Good Morning! The temperature outside is currently
{{state_attr('weather.forecast_home_hourly','temperature')}} degrees,
{%set highof = state_attr('weather.forecast_home_hourly','forecast')
| selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | map(attribute='temperature') | max %} {%
if highof is defined and highof %} with a high of {{highof}} degrees
{%endif%} {%set lowof =
state_attr('weather.forecast_home_hourly','forecast') |
selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | map(attribute='temperature') | min %} {%
if lowof is defined and lowof %} and a low of {{lowof}}{%endif%}. The
weather is forecast to be {{states('weather.forecast_home_hourly')}}{% set
currently_raining = states('weather.forecast_home_hourly') == 'rainy'
%}{%set check_for_rain =
state_attr('weather.forecast_home_hourly','forecast') |
selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | selectattr('condition','equalto','rainy')
| list%}{%if not currently_raining%}{% if check_for_rain is defined and
check_for_rain %} and rainy. {% else %}, with no rain. {%endif%} {%else%}.
{%endif%} The house is currently
{{state_attr('climate.main_house','current_temperature')}} degrees.
mode: single