Thursday, May 21, 2026

A pint of demand

I recently switched to Octopus Energy and got one of their Home Mini devices, which connects to my electricity meter via ZigBee and to my home Wi-Fi to upload meter data to the Octopus servers every 10 seconds. Using their GraphQL web API, you can check your current electricity demand anytime. I've documented how to use their API to get your current electricity demand here. Much more is possible from their API but I only need the current electricity demand.

Here is a fun project to visualise your electricity demand data with a strip of 50 colour LEDs. The colour varies, purple to red, with your current electricity demand.


I'm using a Pimoroni Plasma 2350W which is a USB-C powered controller for WS2812/Neopixel addressable LED strips with 2.4GHz Wi-Fi. The Raspberry 2350W is running MicroPython v1.27. I also have a 5m Flexible RGB LED Wire (50 lights). You could use a standard Raspberry Pico 2W but the Pimoroni version has the advantage of a set of screw terminals for easily connecting the LED strip.



The MicroPython code requests your current electricity demand data from the Octopus server every 30 seconds, which, with the limit of 125 requests per hour, is about as fast as possible.

You'll need to install the latest Pimoroni MicroPython code (plasma_2350_w-v1.1.0-micropython.uf2) from here. You probably don't want the "with-filesystem" version as that one replaces any files already stored on the 2350W's file system with some demo files.

There are four files in this project. You can download them in a .zip file from here.

main.py which automatically launches OctopusElec.py when turned on
OctopusElec.py which is the main code
graphqlclient.py which makes the GraphQL requests and 
secrets.py shown below where you must enter four bits of your information.

WIFI_SSID = "Your WiFi SSID"
WIFI_PASSWORD = "Your WiFi Password"
OCTOPUS_ACCOUNT = "Your Octopus Account number in A-abcdabcd format"
OCTOPUS_APIKEY = "Your Octopus API Key"

To get the API Key click the "Generate my API key" on this Octopus page (you'll need to be logged into your Octopus account).

The easiest way of getting the code onto the Plasma 2350W is to connect it to your PC with USB and to use Thonny to copy the files onto the device. After you've modified the secrets.py file you can disconnect from the PC and power it up from any USB power socket.

Here are the steps:-
2) With a USB lead plugged into your PC power up the 2350W with the boot button pressed, it will appear as a new drive. Copy the latest firmware, plasma_2350_w-v1.1.0-micropython.uf2, onto the drive
3) Download and unzip the .zip file containing the project .py files from here
4) Edit the secrets.py file with your Wi-Fi SSID, password, Octopus account number and Octopus API key
5) Use Thonny to copy the four files (main.py, OctopusElec.py, secrets.py and graphqlclient.py) onto the 2350W
6) Press the reset button on the 2350W and it should connect to Octopus servers and start displaying your electricity demand as a colour. Logging is displayed whilst the 2350W is connected to your PC.

Near the top of OctopusElec.py there are some settings you can alter.

# ─── Configuration ────────────────────────────────────────────────────────────
LOW_W       = 100   # The lowest wattage expected (violet)
HIGH_W      = 6000  # the highest wattage (red)
REFRESH_MS  = 30000 # How often the consumption is requested. Not too fast or API will rate limit
NUM_LEDS    = 50    # The number of LEDs on the strip
ONBOARD_DIM = 0.15  # onboard LED default brightness (0‑1)

Change LOW_W and HIGH_W to set the typical demand range in your house. This might take a bit of trial and error.

Don't alter the REFRESH_MS below 30000 (30 seconds) as anything more frequent causes the API to fail with request limit exceeded errors.

If you'd like to switch to Octopus you can use my referral code for a £50 discount https://share.octopus.energy/playful-engine-680


Friday, May 15, 2026

Get real-time electricity consumption from Octopus Home Mini

I recently switched to an Octopus energy account as they provide a device to allow you to access your real-time electricity consumption from your smart meter. On request Octopus will provide a free Home Mini device which connects to your smart meter with ZigBee and to your home Wi-Fi to upload your electricity consumption every 10 seconds.

If you'd like to switch to Octopus you can use my referral code for a £50 discount https://share.octopus.energy/playful-engine-680

To access the real-time data you query the Octopus API using GraphQL format HTTPS Posts.

To start you need the following: your Octopus account number (A-AAAA1111 format) and your Octopus API Key which you can create here. The API key is like a password so don't reveal it to anyone. If necessary, you can regenerate the key using the same link.

There are 3 steps:

Step 1

Get a Kraken bearer token using the following query. The token lasts for 1 hour before a new, or refreshed, one is required.

URL

https://api.octopus.energy/v1/graphql/

Query

mutation ObtainKrakenToken {

    obtainKrakenToken(input: { APIKey: "sk_live_Your developer API key" }) {

        token

        payload

        refreshToken

        refreshExpiresIn

    }

}

Authentication

None

The result will be as shown below. You only need the text of the long token string.

{

    "data": {

        "obtainKrakenToken": {

            "token": "eyJhbGciOiJSUzI1NiIsImlzcyI6Imh0dHBzOi8vYXBpLm9jdG9wdXMuZW5lcmd5L3YxL2dyYXBocWwvIiwiamt1IjoiaHR0cHM6Ly9hdXRoLm9jdG9wdXMuZW5lcmd5Ly53ZWxsLWtub3duL2p3a3MuanNvbiIsImtpZCI6InFRb3hIbzhiTF91Wi1NdE9kQ2labDZacjFaMWsyM1l2Y0taZnU5QldHNkEiLCJ0eXAiOiJKV1QifQ.eyJzdWIiOiJrcmFrZW58YWNjb3VudC11c2VyOjEzMjMyODc3IiwiZ3R5IjoiQVBJLUtFWSIsImVtYWlsIjoiYW5kcmV3LmpvbmVzQGFscXVpc3QuY28udWsiLCJ0b2tlblVzZSI6ImFjY09090909sd09sd09s0d9pLm9jdG9wdXMuZW5lcmd5L3YxL2dyYXBocWwvIiwiaWF0IjoxNzc4ODczMjA1LCJleHAiOjE3Nzg4NzY4MDUsIm9yaWdJYXQiOjE3Nzg4NzMyMDV9.ABJbgP0gvh68SqNx-GGXGVq4_WSbZ6vqfWb9veWYV0mHojyMkW-EqMUMhVrtvIFYhyom4qbWodfnAGrNIh0akpauzCJG-6qFa8Noynuibqlu4RmoVThYbIOUGbqO6p-VQmKPACKuhimfCzntU2m_Gh2uNr8Tbsx5pqXPnGp6S10LQm1eJvrKmJ4ca1PDh53lx75zgDo-JjARKXm4M4JHbjN5D4TlfJ7fPGlrZktafYad9XwvN1DraAutB4Ur-8ogCpVo7IoBWnnN7gaJCFSEALfi03_wb6ydx-Kb0qnbpKyi-DkJYCn-8EFowQEfA2SKgHMz8nPAN0e58Cb385bS1Q",

            "payload": {

                "sub": "kraken|account-user:000000",

                "gty": "API-KEY",

                "email": "andrew@000000",

                "tokenUse": "access",

                "iss": "https://api.octopus.energy/v1/graphql/",

                "iat": 1778873205,

                "exp": 1778876805,

                "origIat": 1778873205

            },

            "refreshToken": "faff3b0d2700cc9cd6c2fc8d000000e31466dd0daea2149d4c2c68f1",

            "refreshExpiresIn": 1779478005

        }

    }

}

Step 2

You need to establish the deviceId for your electricity meter. Using your Account Number and the bearer token from step 1. I think you only need to do this once as I don't think the deviceId changes.

URL

https://api.octopus.energy/v1/graphql/

Query

query MyQuery {

    account(accountNumber"A-YourAccountNumber") {

        electricityAgreements(activetrue) {

            meterPoint {

                meters(includeInactivefalse) {

                    smartDevices {

                        deviceId

                    }

                }

            }

        }

    }

}

Authentication

The bearer token from the step 1 above


The result will be as below, you'll need your deviceId for step 3.
{
    "data": {
        "account": {
            "electricityAgreements": [
                {
                    "meterPoint": {
                        "meters": [
                            {
                                "smartDevices": [
                                    {
                                        "deviceId""00-00-00-00-00-00-00-00"
                                    }
                                ]
                            }
                        ]
                    }
                }
            ]
        }
    }
}

Step 3

To read the real-time electricity consumption you need the bearer token from step 1 and the 8 byte deviceID from step 2

URL

https://api.octopus.energy/v1/graphql/

Query

query SmartMeterTelemetry {

    smartMeterTelemetry(deviceId: "Your deviceId from step 2") {

        readAt

        consumption

        demand

    }

}

Authentication

The bearer token from step 1

Your current consumption, in Watts, is in the demand field shown below. I've been making this request every 30 seconds and the API seems happy with that.

{
    "data": {
        "smartMeterTelemetry": [
            {
                "readAt""2026-05-15T17:14:50+00:00",
                "consumption""55667150",
                "demand""700"
            }
        ]
    }
}

Sunday, February 22, 2026

PowerPoint - text wrapping in the middle of words not at the space between words

Today I had a strange PowerPoint document where the text was wrapping in the middle of words rather than at the spaces between the words. Example below


There seems to be no way to fix this within Microsoft® PowerPoint® for Microsoft 365 MSO (Version 2602 Build 16.0.19725.20058) 64-bit [the latest version].

It appears this problem is caused by the document being saved when running on a machine with Asian language support (which I don't have installed).

The solution is as follows :-

1) Save the .pptx file to a folder on your PC (C:\Temp\PPT1.pptx in my example)

2) Rename the .pptx file to .zip (PPT1.zip in my example)

3) Use "Extract All" to extract all the files from the .zip file into a set of folders (creating C:\Temp\PPT1 folder and sub-folders in my example)

4) Use Notepad++ to "Replace in Files" with "In all sub-folders" enabled and replace all latinLnBrk="1" with latinLnBrk="0"


5) Use "Compress to" to zip up the contents of the folder to a new .zip file (PPT2.zip in my example)

6) Rename the .zip file to .pptx (PPT2.zip to PPT2.pptx in my example)

7) When you open the PowerPoint file (PPT2.pptx in my example) the text will now be correctly wrapped at the spaces between the words.
That was a whole lot more complex than it should be for a Sunday afternoon!

If anyone runs into this problem frequently let me know and I'll write a small app to fix the files.


Alternative method :
  1. From PowerPoint use File>Save As and change the Save as type to "PowerPoint XML Presentation (*.xml)".
  2. Open the XML file in NotePad
  3. Choose Edit>Replace
  4. In the Find what field, type latinLnBrk="1"
  5. In the Replace with field, type latinLnBrk="0"
  6. Choose Replace All
  7. Save the file and close NotePad
  8. Open PowerPoint and use File>Open to find and reopen the XML version. Resave in the normal PowerPoint pptx format. All English text will now break normally.