Immersed in Octopus's free periods
The UK’s Octopus Energy offers occasional “free periods” for electricity. Called “Power-ups”, the following is from their website:
we’re calling on homes in areas with lots of green generation to use up that spare solar and wind when it's most plentiful...
Yes, free electricity sometimes! As long as you have a smart meter and you live in the right area (and luckily I do), you get an email the day before asking you to opt in to the next Power-up which, to date, has always been between 2pm and 4pm the next day. And who wouldn’t opt in as there’s no down side.
Maximising the benefit
Of course if you get a freebie, you want to maximise it if possible (and, to be fair, Octopus encourage you to do so). That means running as many high power devices as possible. In my case, some need manual intervention, such as the dishwasher and washing machine as they need loading (although I will investigate extending the automation in this article to some of these), while at least one, the immersion heater, needs no manual intervention.
Before these Octopus free periods, I’d never used our immersion heater, I didn’t even know if it worked (it does)! I now have an automation to switch it on and off whenever there’s such a free period and I explain below how it works.
The approach
The approach I wanted was as follows:
on receipt of their email, enable my automation for the next day
on the day of the free period, switch on the immersion heater at 2pm and off at 4pm. For this I use a ZigBee smart switch rated at 13A.
ensure the automation doesn’t run again until the next free period
The immersion automation
First I’ll explain how the automation that switches the immersion heater on and off is implemented. As ever, it’s a Node-RED automation and explaining it first makes explaining the email handling simpler.
Below is the full Node-RED for this automation. Very simple as you can see (I send an email to alert me a switch on has occurred so I’m aware and, in the unlikely event it was invalid, I can correct things manually).
The processing is as follows:
Every day, inject two messages, one at 2pm with msg.topic = START and the other at 4pm with msg.topic = END
Only let the messages pass to On or off? if a helper I created for this purpose input_boolean.free_period is on
Depending on whether the msg.topic is START or END, turn my ZigBee switch on or off accordingly
If the free period has expired (msg.topic = END), also reset input_boolean.free_period to off so the automation doesn’t run every day
Handling the email
The more complicated part was automatically processing Octopus’s email declaring there’ll be a free period the following day. Processing this email simply needs to set the helper input_boolean.free_period on.
I use gmail so, to process the email, I had to install the IMAP integration in Home Assistant (HA). The documentation is clear and its installation was straightforward. In order to trigger an event in HA whenever I get an email announcing a new free period, I placed the following in my configuration.yaml:
template
: - trigger:
- platform: event
event_type: "imap_content" id: "custom_event"
event_data:
sender: "hello@octopus.energy"
sensor:
- name: Octopus_free_power_email
state: >-
{% if 'Power up for free' in trigger.event.data["subject"] %}
Free
{% else %}
Cost
{% endif %}
This looks for any email from hello@octopus.energy, if the subject contains the text Power up for free (all their free period emails seem to contain this text), then sensor.octopus_free_power_email is set to Free, otherwise it’s set to Cost. Whenever this sensor goes to Free, I have the Node-RED flow below that triggers and sets input_boolean.free_period to on so that the following day my immersion heater will be switched on. Note I send myself an email whenever this runs just so I’m aware of what’s happening in case I’ve missed it.
Now the more astute among you might wonder why am I using a sensor and a helper, surely I can get away with just the sensor? In theory yes but that assumes that the email from Octopus always arrives after the current free period. In theory, it’s possible that, if there are consecutive days with free periods, the email for the second free period arrives before the first free period has ended (or even started). My approach protects against this - I’ll keep a watch on the emails from Octopus and, if this does happen, I’ll amend the flow above to only run after 4pm.
Fail safe
Other than in these free periods, I never want to have my immersion heater on, the cost would be prohibitive. Now that I have a remote switch on the immersion heater, it’s conceivable it could be switched on by mistake. So I have a simple Node-RED flow that sends me an email whenever the immersion heater comes on:
Final thoughts
This approach has worked well so far. I’ve had no inadvertent switch ons and only the correct emails have triggered the process. As a visual cue for when a free period is going to be active in the next 2pm to 4pm window, I’ve added a conditional chip to my dashboard which shows an orange boiler when the input_boolean.free_period helper is set on, as shown below. We can then be ready to get every other manual devices set up to run in the free period.