Green Energy Scheduling -- Save my complicated workaround

My local energy provider has a schedule for when energy is Peak, Off-Peak and Super-Off Peak for users of their variable billing plans. It’s the same all year on weekends, but changes to one set of times on weekdays between October and April, and another set of times between May and September.

After a lot of fits and starts, I managed to create a complicated system of helpers and automations to make this work. And while I got there, I feel like there HAD to be a simpler way to do this. Would love some input.

Here’s what I ended up doing:

—Create a drop down helper called “Energy Cost Sensor” that can be changed to Peak, Moderate (Off-Peak), or Green (Super Off-Peak).

—Create a sensor that just outputs the name of the month (this was the hardest but is apparently very easy if you know YAML and Python…which I do not. Yet.)

—Create a schedule helper entity for each of the states:
——Peak Use (Weekdays, May thru September)
——Peak Use (Weekdays, October thru April)
——Moderate Use (Weekdays, May thru September)
——Moderate Use (Weekdays, October thru April)
——Green (Everyday, since it doesn’t change based on the months or weekdays vs weekends)
——Moderate Use (Weekends)

—Create automations for each schedule helper entity that changes the Energy Cost Sensor to the appropriate option.

—Create an automation that disables the May-September automations and enables the October-April automations when the Month sensor changes to October

—Create an automation that disables the October-April automations and enables the May-September Automations when the Month sensor changes to May

So: 1 template (month), 1 dropdown helper, 6 scheduler helpers, and 8 automations.

I got there, but feels excessive. Thoughts on simplifying?

Set up a local calendar with recurring events instead of multiple schedules and the month sensor.

Put the cost in the description in the recurring calendar events. Name the events using the Summary option.

Then use one triggered template sensor that gets the current cost from the calendar events.

More info on calendar automation:

If the costs change you should only have to edit the costs for each recurring event (Peak, Off-Peak and Super-Off Peak).

The other way is one template sensor that makes multiple use of {{now().month}}, {{now().weekday}} and {{now().hour}} to select your cost based on a bunch of if statements.

You could use input_numbers in the template sensor so you could edit the costs for each tariff directly from a dashboard when your energy supplier changes them.

Don’t forget to take into account daylight savings if you have it.

e.g. my peak / off peak binary sensor (way less complicated but just to give you ideas):

- name: "Peak Rate"
  unique_id: de98f85a-61be-46e7-92fd-d34320b80e4e
  icon: "mdi:power-plug"
  state: >
    {% if states('binary_sensor.is_dst')|bool(0) %}
      {{ (now().weekday() < 5) and ( (7 < now().hour < 11) or (16 < now().hour < 22) ) }}
    {% else %}
      {{ (now().weekday() < 5) and ( (6 < now().hour < 10) or (15 < now().hour < 21) ) }}
    {% endif %}

peak = weekdays from 6am to 10am and 3pm to 9pm. One our ahead if DST.

1 Like

Nice, I’ll give this a shot. Thanks!