# Automating for hourly energy prices

Dynamic energy pricing is becoming more popular, and there have been some very cool videos with ideas for them (for example Smart Home Junkie’s video).

This works great if you have a device that will run for an hour, or where (like a washing machine) the vast majority of energy use is in the first hour of running.

But I want to do this for my dishwasher. Now dishwashers vary, but my dishwasher uses a lot of energy in the 1st and 4rd hours. See below:

So my idea is that my automation needs to run when both the 1st and the 3rd hours are cheap. Does anyone have a suggestion on how to do this? Average of 5 hours price? Stick to just the first hour? Average between first and 3rd the lowest?

If you know when your cheap energy tariff kicks in, and you know you need at least (say) three hours to complete a dishwasher cycle, then surely just make the smart plug only turn on if you have three hours left of the time needed using a time condition.

So to keep it simple, lets imagine that your cheap energy starts at 6pm and finishes at midnight. So you have a 6 hour window of cheaper electricity. Assuming in this example, it takes 3 hours to complete a cycle, simply turn off the smart plug after 9pm, or if won’t finish its cycle before the energy price rises. You will also need some logic to check that dishwasher hasn’t already been started, as you don’t want the smart plug cutting the power if its half way through its cycle.

With dynamic pricing I mean that we have hourly rates. It’s getting more popular in the Netherlands for example. These are tomorrow’s rates for example:

So since my dishwasher needs 5 hours, and hour #1 and #3 are the most intensive in energy use, it would have to start at 13:00 tomorrow, as it would practically be running for free (with one hour even being negative).

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
``````

In response your request to enable the Dishwasher to be active at ‘Cheapest Energy Hours’ I’m using a Jinja macro, Power Plug, Nordpool Integration and in addition to this a notification at my mobile phone (iPhone in my case) when it is adviced to switch on the Dishwasher (or Washing Machine, Dryer etc.) based on ‘Cheapest Energy Hours’ and with ‘‘weighted value’s’’ based on energy consumption at given time during the Dishwasher’s program.

So at 6:00 PM I receive a notification at my phone: This evening it is adviced to switch on the dishwasher at hh:mm (cost) or tomorrow from hh:mm onwards (cost). With this information I can program the delayed starttime at Dishwasher. Of course the time that this notification is sent as well as the text of the notification can be modified in the YAML Automation.

Copy the ‘Cheapest Energy Hours’ jinja macro (HACS) into the custom_templates folder. Create Dashboard Card (type: custom:apexcharts-card) and YAML in Development Sjablonen (to play with) as well YAML in Automations that creates the notification to be sent you your phone. YAML can be found at Twoenter.nl (blog). YAML alias: “[notify] Dishwasher” needs to be adjusted with your specific information such as Device to be notified kWh tariff and desired time of the notification. Moreover you only receive a notification if you’re at home.

Oh and smart Power-Plug used for power monitoring (always on) and notification “Dishwasher Finished” Blueprint.

Sources and thanks to:
TheFes (Martijn) 'Cheapest Energy Hours"
Twoenter.nl (Wouter)

1 Like