[APP][DEV][PRO] Octopus Energy Integration

More on Power-Up, Power-Down

Just to be very clear, I have no plans to automate the joining of these sessions - you will still have to opt in manually via email or the website. That’s why there are two events - the first says “hey there’s a session being planned” - that’s when you opt in. The second says “hey the session is starting”. At that point your flow can do whatever you want in terms of powering-up or powering-down.

It may be possible to finesse the session is starting trigger so that it is only signalled if you have opted in - I need to check the availability and quality of the opt-in data. Also include the minutes duration as a tag on this card so your flow can reverse its changes at the end of the session.

Maybe an end of session trigger card. Lots to think about.

Wasn’t expecting that to be honest, it is primarily the start and end of session triggers to automate things. I can’t see Octopus :octopus: wanting people to try automate the sign-up to events frankly. But that’s the purpose of the announcement trigger, so you know to login and sign up if you want to. No point trying to make it too complex or convoluted.

Thank you for your consideration and response.

Version 1.2.16 Published TEST

Evening all. Had a user get in contact today, they had problems with Intelligent Octopus Go after Octopus exercised the 360 minute dispatch limit on their account. The pricing data associated with IOG was completely wrong, causing the Kraken App to stop working.

This fix release hardens the code around slot handling so that the App will continue to function. However, when the price slot data is wrong, calculations around pricing and value will also be wrong (you can’t calculate correct outputs from incorrect inputs).

If you have problems with IOG you should get in contact with Octopus to get them put right. I was able to help the user in question by supplying a snapshot of the erroneous pricing data so they could demonstrate the mess to Octopus.

Here’s the link to the new version:

Research on Power-Up and Power-Down

Been following-up on how to implement Power-Up and Power-Down sessions. The good news is the “strawberry” GQL environment that has to be used to get this data appears more robust than it first seemed.

More good news is that the data looks relatively straight-forward. For an account there is an indicator to show whether or not the Power-Up/Power-Down campaign has been joined (have you opted into these sessions at all).

If you are opted in, then there are two data lists. One shows the set of published sessions with dates, times, session type, octo-points per kWh and other data. The other shows the set of sessions that you have opted to join.

In terms of the functionality previously discussed, the first list can be used to fire the “Newly Published” Trigger flow card when a new event is published. The second list can be used to fire the “Session Starting” Trigger flow card when the session actually starts. This list will also support a “Session Ending” Trigger flow card.

Priorities

  1. Gas Tariff to include Invoice Period data
  2. Correct handling and pricing for IOG dispatch sessions, including the time-limit
  3. Power-Up and Power-Down sessions

Oh that sounds absolutely amazing. When you do get to this part, if there is any way of displaying these lists, especially the published sessions list, so you know when to sign up for them, that would be utterly amazeballs!!!

Thank you for your time researching this, much appreciated. And it sounds good news that it’s more robust than you expected. I look forward to helping you test it :grin: From what I have used so far, and what you have described is coming, this is going to be one of the best apps I’m running on my Homey :+1:t3::+1:t3:

Hi Andy

In my experience there is only one future event at any one time. It would be possible to have a device that displayed the details of this event. However, that seems less useful to me than having a flow trigger.

If you have a trigger flow card it can pass all the details as tags. Then you can write a flow that does whatever you want with that information - including sending those details to your mobile phone as an alert. You could even write and run a script that did the sign-up for you.

Once you have signed up, the Event Start trigger would enable you to set up any behaviour you want - again the Start trigger can provide tags about whether it is a Power-Up, Power-Down (or now the recently introduced Weekend Happy Hour). Your flow can decide whether to eat all the power it can, or to stop consuming anything.

One extra thing the app will have to do in the Tariff And Account Devices is apply a zero charge to the Weekend Happy Hours.

Gotta love how all these special cases are making cost calculations ever more difficult…

Planned tags on “New Session Scheduled” card:

  • Event type
  • Start date-time
  • End date-time
  • Duration in minutes
  • Reward per kWh (octo points) [think this is for Power-Down only]
  • Event Id (just because its there)

Planned tags on “Session Start” and “Session End” cards:

  • Event type
  • Start date-time (though that’s “now”, of course)
  • End date-time
  • Evend Id (it might be useful)

Need to think about “Session End” handling - maybe have a “pre-session end” card (say 2 minutes before the end) so that devices that take time to shut down (like the typical ASHP) can be triggered early. Might just NOT HAVE a session end card - the flow triggered at the start could use the duration to wait then trigger “off” behaviours after the wait. A potential problem with that is Homey rebooting during the flow. But then if Homey is down when the session end flow card should be received, it won’t happen anyway.

Lots to think about.

Hi David @David_Piper

I agree, I was just thinking of a possible idea for a widget that listed any future or current events… you did say you were considering widgets further down the line didn’t you.

The most important things in my personal opinion though would definitely be the event start and end When trigger cards for flows.

I think I may have spotted a possible issue with the Gas Tariff. It seems to be showing up as a device consumption in the Electricity usage list and being included in that, throwing out the Electricity usage by however many KWh gas used. I’m reasonably sure it used to turn up in a separate graph from the Electricity, that was red instead of blue. Is this a bug?

Gas tariff change the exclude from energy setting for a quick fix. Need to investigate the right settings for gas consumption.

Gas tariff improvement next on the list so will try to include a fix for this too.

One complexity after another… Whack-a-mole style…

Get BlueMail for Mobile

Swear I’m not purposely trying to complicate things… just mentioning anything I find while using and testing the app :wink:

I know that. It’s great to get the feedback so that things can be improved. :clap:

As long as it’s of help n value, I will keep testing and commenting any oddities I find :+1:t3:

I have to say, so far, it’s been a damn sight more stable than my old solution that was a bought and paid for commercial product… a Glowmarkt CAD (not a typo, that’s how they spell it). Which is basically an In Home Display device, but that connects to your WiFi as well as the meter’s Zigbee HAN, so it gives you instantaneous live Electric & Gas meter data. Despite paying for it, it was always dropping connection to Homey or the meter, and was a total pain in the posterior. The Octopus Home Mini with your app hasn’t skipped a beat once yet! :+1:t3::ok_hand:t3:

Exceptional work fine sir :raised_fist:t3:

Hi David @David_Piper

I hope you are well, and it being quiet here is only because you are busy.

I got bored one weekend, and came up with my own mad scientist kind of bodge solution for automating Octopus events… and thought I’d share it here, just in case anyone else wanted to automate power down events. This is just an example, and I freely admit AI helped me write the Homey Script (as I am not great with java script). But it works okay-ish for me.

I also couldn’t find a way to automate signing on to the power down events. This only works if you click the link in the email they send you and accept the challenge first. Otherwise you’re just automatically powering down for no reason. But if like me, you’re so scattered that you click the accept button, but then forget all about it, this helps.

The code in the Homey Script Then run code with argument and return text-tag is:

const subject = args[0];
const match = subject.match(/[0-9]+-[0-9]+[a|p]m/);
const eventTimeRange = match ? match[0] : '';
return eventTimeRange;

And the Homey Script Then run script card points to a script containing this code:

// Get all Logic variables
const variables = await Homey.logic.getVariables();

// Find variables by name
const eventTimeRange = Object.values(variables).find(
v => v.name === 'OctopusEventTime'
);

const eventStartHr = Object.values(variables).find(
v => v.name === 'OctopusEventStartHour'
);

const eventEndHr = Object.values(variables).find(
v => v.name === 'OctopusEventEndHour'
);

if (!eventTimeRange) throw new Error('Variable "OctopusEventTime" not found');
if (!eventStartHr) throw new Error('Variable "OctopusEventStartHour" not found');
if (!eventEndHr) throw new Error('Variable "OctopusEventEndHour" not found');

// Example: "6-7pm"
const range = String(eventTimeRange.value).trim().toLowerCase();

// Extract hours and the single am/pm suffix
const match = range.match(/^(\d{1,2})\s*-\s*(\d{1,2})\s*(am|pm)$/);

if (!match) {
throw new Error(
Invalid time range "${range}". Expected format such as "6-7pm" or "6-7am".
);
}

let startHour = Number(match[1]);
let endHour = Number(match[2]);
const period = match[3];

// Convert both hours to 24-hour format
if (period === 'pm') {
if (startHour !== 12) startHour += 12;
if (endHour !== 12) endHour += 12;
} else {
// AM
if (startHour === 12) startHour = 0;
if (endHour === 12) endHour = 0;
}

// Update Homey number variables
await Homey.logic.updateVariable({
id: eventStartHr.id,
variable: {
value: startHour
}
});

await Homey.logic.updateVariable({
id: eventEndHr.id,
variable: {
value: endHour
}
});

return OctopusEventTime "${range}" → Start: ${startHour}, End: ${endHour};

This assumes that you have a Text variable named: OctopusEventTime and two Number variables named: OctopusEventStartHour & OctopusEventEndHour

The Homey Apps used are:
Mail Hook [scans an IMAP mailbox at a set interval for the Octopus event email]
Homey Script
Action Scheduler [with 2 cron devices added and “Run Once” enabled on them]
Advanced Triggers [I used this, but it can easily be done without it if you wish. I just like the ability to trigger actions from multiple different Flows, without having to repeat the logic.]

I hope one day to be able to do without all this, with native app support for power down/up events… as I hope to get solar and batteries going soon, and automating charging or going off-grid for events would be a game changer. Meantime I shall keep on bodging things ha ha

There is an explicit mutation inside Kraken Strawberry that deals with the registration. But first I shall do the read-only stuff so at least users know that there are power events in the ether.

Hi David,

Good to hear from you dude, I was starting to think you might have done a runner after previous post overload from me ha ha :rofl:

Ooo that sounds promising… but yes, having the notifications and triggers first would be awesome. Thanks for the update, much appreciated.

Personal Update

Things have been a bit busy on the domestic front in the last few months, so the Kraken app has been receiving less attention than I would like. Things don’t show any signs of getting quieter in the next few weeks, but after that I hope to be able to focus more time back on this stuff.

Intelligent Octopus Go Users

If there are IOG users out there experiencing difficulties, I have worked with a couple of users and have identified what seems to be a consistent mal-formation of account data if you exceed the 360 minute dispatch limit. The test version 1.2.16 specifically enables the app to work around the mal-formed data. But it is not possible to correct the malformation.

If you update to 1.2.16 and the app starts to work again, take a look at the SLOT END TIME on the IMPORT TARIFF. If this says “Invalid Date” that is an indicator that the tariff data is malformed. You should talk with Octopus to get the situation resolved. If you wish, I can provide a snap-shot of the malformation so you have evidence to present to Octopus.