Earth Notes: On The Green Light Signal and Beyond (2021)

Updated 2022-12-27.
Learn how I am trying a smart lighting nudge @home to use 'leccy at grid-friendly times. #IoT #CO2Intensity
Using some low-key IoT and WiFi magic to try to reduce electricity consumption at bad times, inspired by the UK's National Grid!

2021-04: Green Light Signal

green light signal

In April 2021 the UK's National Grid created its Green Light Signal:

In a bid to help Britain understand where it gets electricity from, National Grid has launched the Green Light Signal - a low-energy light bulb designed to glow green when the electricity supply at home is cleanest so people can make smarter energy choices. The clever gadget is powered by National Grid's carbon intensity API (carbonintensity.org.uk), a carbon intensity forecasting tool with a regional breakdown, built by National Grid ESO, WWF and The University of Oxford and The European Defence Fund.

You put the lamp provided into a 'spare' light fitting which you leave on, set up some IoT magic, and the lamp stays off most of the time, but goes green when your bit of the GB grid is 'green'. (Well, this was my experience for the limited time that I ran it as supplied!)

I am very much in favour of simple traffic-light-style signals as a nudge for behaviour...

Many many thanks to Duncan Burt of National Grid for sending me one to try out and get my thoughts racing! This overcame my inertia trying to get something similar actually up and running!

Below I make some observations on the kit as delivered, and then subvert the whole thing for a somewhat different use case!

Green Light Signal in box
The Green Light Signal and its presentation box. The lamp is in the tube on the right.

Critique of Pure Greenness

20210516 screenshot IFTTT Green Light Signal activity

Hats off to National Grid for putting something together that works! That's always the hardest bit.

Here are some observations that may sound like carping, but are meant as honest analysis especially for my situation:

Quite a lot of this is unmitigated inherent IoT setup complexity, some is use case selection.

A More Gentle Way?

Before I come to all the technical detail, here's what my re-spin of the signal looks like.

(I'm still tuning it. As of I am quietly running a couple of lamps on my new scheme, waiting for spontaneous comment from the family...)

My approach is to avoid dedicating a whole light fitting and lamp. Instead, I tweak the colour of a lamp when it is in use. The light is switched on and off at the wall switch as usual. So I'm not adding any new load to the grid. Nor am I requiring a 'spare' that may not exist.

I have the lamp on a normal warm-ish white most of the time. When the grid is relatively green, tinge the lamp colour green. When the grid is high carbon intensity (or other factors), tinge the lamp red and dim it a little. Possibly have it 'breathe' a little to gently get attention that saving energy would be a good thing now.

Basically just a light that is switched on and off as usual, providing light when light is needed, and carrying a subtle hint when needed. No computer interface need be touched in normal use.

A lamp does double duty.

This does not deliver a grid green/red signal if you don't have a light on. Is that a problem? My working hypothesis is: probably not.

(I also have this working on a GU10 style bulb, which will suit quite a few more locations in typical GB households. In fact the way that I have set it up currently, I can control any number of lamps simultaneously, sprinkled throughout the house, though I have just two for now!)

GU10s might be especially good for kitchens where a lot of household peak-time demand happens.

Diary of an Install

Here is a summary of my journey to get the Green Light Signal set up, and then me going "off piste"!

I was busy with other things, so this took quite a while! At least I did not give up and leave it to gather dust somewhere...

2021-04-23: arrival and first impressions

Green Light Signal in box

The Green Light Signal package arrived late afternoon on the from National Grid ESO. Thank you!

The box contains a leaflet, and what turns out to be a smart lamp in the manufacturer's cardboard tube inside a National Grid card sleeve. (I took a while to work out how to get into the lamp.) All sitting in a bed of something like hay, nicely presented.

The package could have been smaller and lighter and cheaper. (I'm thinking embedded / upfront carbon and other eco costs here!)

An initial inspection showed that the lamp requires an ES27 (spotlight, screw) style socket (or a B22 bayonet socket with the supplied adaptor). We don't have either of those in all rooms these days.

LIFX Mini Colour ES27 lamp packshot

The system also seems to require downloading native apps for LIFX (the lamp is an LIFX Mini Colour, 9W 800lm) and IFTTT, and setting up (new) accounts for both. The IFTTT account may (eventually) cost money, it's not clear.

For security reasons I don't have the Play Store running, nor therefore in general run native apps on my own phone! So I have dug out some older (Android) devices to see if I can use one of them.

The LIFX app will load on my old Huawei tablet (Android 4.4.4) but seems to fail silently when trying to register an account. It seems to believe that it is not connected to the Internet, though it is. The LIFX 'virtual bulb' feature does seem to interact with my MacBook just fine.

There does not seem to be an IFTTT app that will even load on the tablet.

I note that Amazon has an LIFX GU10 multicolour lamp available.

It may not be necessary to to run the native IFTTT app on the phone. I may be able to set IFTTT up via my laptop browser.

I have dug out an old LG phone with Android 5.x. Downloading LIFX (V3.1) app onto that seems to work. I am reluctantly creating an account registering against one of my web mail accounts with relatively good SPAM defences.

The LIFX app detects the lamp when I turn it on at the wall, but seems unable to actually connect to it. An eventual failure pop-up starts Oops, that didn't work.

Before that is sometimes a smaller warning/notification of the form:

Cannot search all WiFi networks. Check SIM card ...

or

Internet not available for {lamp name}

So I'm currently stuck.

The set-up seems to require something that I don't have, or that I am not prepared to use for privacy and security reasons.

2021-05-01: still not there

I emailed LIFX support about my inability to get their app loaded or working on my Android devices. I also mentioned how I did not want to run the Play Store or native apps on my primary phone.

In part of the email chain I got this response:

From what I understand you'd like to have an alternative option of managing your lights.

Since you don't want to enable the Google Play Store, here ae a couple of alternatives for you.

if you want to build your own control method you can use the API's
https://api.developer.lifx.com/
https://lan.developer.lifx.com/docs/introduction

Also, there is a possibility of downloading the windows LIFX app, however please bear in mind that this is a version we don't support anymore as our main app is switched to android and IOS devices.
https://www.microsoft.com/en-au/p/lifx/9nblggh367vj?activetab=pivot:overviewtab

Lastly, since we don't support the LIFX Windows app, you can give it a go with an open source app created by one of our customers here.
https://github.com/samclane/LIFX-Control-Panel

It turns out that Andy Stanford-Clark (CTO of the local chunk of IBM) has replicated the Green Light Signal with Node Red and the API from carbonintensity.org.uk!

2021-05-13: dead end

So it turns out that I can indeed control the lamp from a Windows 10 laptop running LIFX-Control-Panel, so long as I pointed the laptop's WiFi at the WiFi access point that the newly-unboxed LIFX lamp creates.

(It turns out to be possible to get an LIFX lamp back to a box-fresh state by slowly power-cycling it five times, as it happens...)

But what none of that helps with is moving the lamp from being its own WiFi, onto the house WiFi as is evidently how it is meant to be used.

I did contemplate leaving the LIFX lamp as-is and having (say) my RPi fire up a WiFi dongle to talk to each lamp. One downside is that in this mode there is no security on the lamp's operation at all, so someone could sit outside my house and prank me by flashing the lights on and off or worse!

I note that the serial number from the piece of paper in the LIFX lamp box is the lamp's MAC address. I believe that all LIFX lamp MAC addresses start "D0:73:D5" and thus serial numbers "D0 73 D5".

I'd like to reduce the risk of my LIFX lamp leaking sensitive information such as my WiFi password, eg back to the LIFX cloud.

So I created a new 2.4GHz WiFi SSID on my router just for devices such as the LIFX lamp that may wish to talk to the outside world. I may turn off such routing, or traffic between that SSID and other bits of the LAN. The new SSID is short and has no spaces in it to make it easier to pass to simple-minded devices if necessary.

I started a thread on the LIFX Developer Zone (the third new account created) Getting started: low level help please! I asked if I was right to assume that if I want connectivity to IFTTT then I somehow need to get my WiFi SSID and key into the lamp for it then to become a WiFi client. I am happy to write extremely low-level network code if need be. Or am I barking up the wrong tree?

The official response was that there was no alternative to using a phone and that doing that is not part of the public API.

I expressed my disappointment...

Having an already-fragile IoT setup process be tied to having new versions of one of two phone operating systems (and with reports that the Android apps are unreliable) does not seem to be helpful...

LIFX lamp retains state when turned off

An important discovery in the middle of all of this: when turned off at the wall an LIFX lamp retains the colour and brightness that it was last set to. Turning on again at the wall has the lamp continue just as it was before being turned off.

Thus always setting the lamp over WiFi to a full (or near full) brightness value will mean that the user can just switch the light on and off at the wall in the obvious way without going near a computer.

Sending the target colour at least every few minutes to the lamp will allow it to respond reasonably fast to changes in grid conditions. That update by default (if updating to the colour/brightness already shown) is invisible, ie no flicker or other annoyance.

2021-05-16: lifx-hacks and contact!

Yesterday someone pointed me at LIFX Hacks.

With lifx-hacks I was able to bind the bulb to my now IoT-only WiFi SSID! Hurrah!

Yes it was as I had guessed: lifx-hacks passes your WiFi SSID and password to the lamp, which uses them to connect as a client.

It's really not clear to me (nor many others) what LIFX gains by being obstructive on this point. LIFX could even issue a tiny Windows 10 (or Android, iOS, Linux, etc) program to do just this.

Now LIFX's (unsupported) Windows 10 app let me 'claim' the lamp for my cloud account as the Android app should have done.

Three weeks' delay and a lot of effort...

After this things began to race ahead.

I was quickly able to, in IFTTT, connect with the Green Light Signal applet.

green light signal

A few minutes later, the bulb had turned (lurid) green, which accords with carbonintensity.org.uk for this area.

(To keep things as simple as possible, in the DHCP server on my router, I fixed the IP address for the lamp, in case I want to talk to it directly.)

The updates seem to be coming in, a little irregularly, every couple of minutes.

About an hour after first getting the GLS/IFTTT combo driving my lamp, and because carbonintensity.org.uk was showing London as green for a day or so, I changed the 'postcode' to 'Nation' in the IFTTT config ('England' was amber), and a couple of minutes later the light went off!

Turning the lamp off at the wall and back on had it come on dimly. I don't think that this UX is going to work for me!

Better for me might be:

  • when grid green make the light go green-ish if on
  • when grid red make the light go red-ish if on, maybe with some 'breathing'
  • otherwise leave light on at warm white and full brightness.

About half an hour later I disconnected the Green Light Signal app in IFTTT!

I then set about controlling the lamp directly from my MacBook, and my Raspberry Pi server using my own live GB Grid Carbon Intensity traffic-light signals. I describe this in more detail below.

By bedtime I was all set up.

2021-05-18: LIFX GU10

LIFX GU10 lamp packshot

I took a punt and hoped that the same lifx-hacks magic would work more generally.

I had ordered a LIFX GU10 multicolour lamp (6W 400lm) from Amazon (£47.50 including P&P + VAT), and it arrived today.

I bound it to my IoT WiFi SSID with lifx-hacks which was quick. Then the new lamp was working alongside the other one!

I initially set up all the colour changes to be done by broadcast, which meant that no extra code was needed for the second lamp. With the two lamps in the same room the both seem to change at once in response to each command.

The original lamp is staying in my study.

The GU10 lamp has been put on one of the two GU10 strings in the kitchen, illuminating the corner with the kettle. I'm hoping that that light string will be on when there is lots of (say) cooking to be done, and can therefore provide a non-annoying grid status. The 'red' and 'green' signals are relatively subtle tints.

Note that I have not claimed this new lamp in my LIFX cloud account. I don't know if it's calling home or not, though it has no need to, since all control is local within my building LAN.

2021-05-19: fancy white

Since I have fancy colour-changing lamps I have decided to fold in an extra feature (technical details below). Within fours hours either side of solar noon, I'll have the lamp at a relatively cool white, otherwise warm white, when not red nor green.

Technical Details

Here is more technical detail from some of the diary steps and beyond.

lifxlan

As soon as I had my first LIFX lamp bound to my local WiFi, and disconnected the IFTTT applet, I started to play with lifxlan.

I installed it with pip (or pip3) on both my MacBook and my RPi server.

I then had one of the example scripts supplied with the lamp powered up:

% python3 hello_world.py

Discovery will go much faster if you provide the number of lights on your LAN:
  python hello_world.py <number of lights on LAN>

Discovering lights...

Found 1 light(s):

LIFX Mini 633F93
  MAC Address: d0:73:d5:63:3F:93
  IP Address: 192.168.0.XXX
  Port: 56700
  Service: UDP
  Power: On
  Location: 16WW
  Group: 5s
  Color (HSBK): (21845, 65535, 65535, 3200)
  Host Firmware Build Timestamp: 1574901399000000000 (2019-11-28 00:36:39 UTC)
  Host Firmware Build Version: 3.6
  Wifi Firmware Build Timestamp: 0 (1970-01-01 00:00:00 UTC)
  Wifi Firmware Build Version: 0.0
  Vendor: 1
  Product: 49 (LIFX Mini Color)
  Version: 16843010
  Features: {'color': True, 'temperature': True, 'infrared': False, 'multizone': False, 'chain': False, 'matrix': False, 'min_kelvin': 1500, 'max_kelvin': 9000, 'hev': False, 'relays': False, 'buttons': False}
  Current Time: 1937257498000 (1970-01-01 00:32:17.257498 UTC)
  Uptime (ns): 1937257498000 (0.54 hours)
  Last Downtime Duration +/-5s (ns): 0 (0.0 hours)
  Wifi Signal Strength (mW): 5.011870030102727e-07
  Wifi TX (bytes): 3877702633
  Wifi RX (bytes): 3877702633

I'm impressed with lifxlan. I'm using a couple of its example scripts directly. I have modified another for some specialised polling.

Note that to receive responses to broadcasts, eg polling what state all lamps are in, I had to open up a little the firewall running on my RPi itself.

Integration with traffic light page

Once every 5 or 10 minutes on my RPi server, a script is run to update the live GB Grid Carbon Intensity page.

I added a hook into the end of that, and a couple of other times in a ten-minute cycle, to run a script that looks like this:

#!/bin/sh
# Broadcast grid intensity to all LIFX lamps.

# $1 is the intensity to signal:
#   * "auto" to use the flags set by the trafficLights application.
#   * "red" for high grid intensity.
#   * "green" for low grid intensity.
#   * "warm" for warm-white general room lighting.
#   * "noon" for near-noon cooler white general room lighting.
#   * "yellow" or anything else gives a 'normal' status, warm/noon.

# Normal can be signalled by a white normal lamp colour.
# The other colours are shown as somewhat unsaturated versions
# so as to not be too annoying.
#
# In future they may breathe, and/or more states may be shown.

# Requires the lifxlan package to installed and locatable at run-time.
# https://github.com/mclarkk/lifxlan

# Colours to set the LIFX lamps to.
# 'Warm' and 'daylight' whites.
WARM_WHITE="58275 0 65535 3200"
WHITE="58275 0 65535 5500"
# Red and green are desaturated to be a subtle hint!
RED="65535 7000 55000 3200" # Dim a little to save some more energy!
PRERED="65535 20000 50000 3200" # Pre-red flicker to emphasise red.
GREEN="16173 10000 65535 3200"

# Default to DEFAULT_COLOUR, ie warm white (~3200K).
# But in middle of day use a cooler white (~5500K).
DEFAULT_COLOUR="$WARM_WHITE"
SOLARHOUR="`date -u +%H`"
if [ "$SOLARHOUR" -ge 8 -a "$SOLARHOUR" -lt 16 ]; then
    DEFAULT_COLOUR="$WHITE"
fi
COLOUR="$DEFAULT_COLOUR"

# Process command argument.
case "$1" in
auto)
    if [ -f _gridCarbonIntensityGB.red.flag ]; then COLOUR="$RED";
    elif [ ! -f _gridCarbonIntensityGB.flag ]; then COLOUR="$GREEN";
    fi;;
red) COLOUR="$RED";;
green) COLOUR="$GREEN";;
warm) COLOUR="$WARM_WHITE";;
noon) COLOUR="$WHITE";;
esac

# If on red, attract attention gently.
if [ "$RED" = "$COLOUR" ]; then
    python3 .work/script/lifxlan/broadcast_color.py $PRERED
    sleep 0.5 || sleep 1
fi

# Invoke lifxlan example script!
exec python3 .work/script/lifxlan/broadcast_color.py $COLOUR

This does too much and is too clever and also probably needs more tuning!

Note the final line (and a few above it) broadcast_color.py. That is one of the supplied example scripts. Run it with either a single colour argument such as "RED" or a HSBK (Hue Saturation Brightness Kelvin) tuple, and all the lamps are set to that colour.

There's a bit in the middle that uses _gridCarbonIntensityGB*.flags as described in the GB Grid Carbon Intensity page to decide which colour to set the lamp if "auto" is passed in. Else if "red" or "green" are passed in those colours are used. Else a normal white colour is used, as for a normal manually switched lamp! That white will be cooler near to noon, because I can.

Note that the red and green are hints of colour rather than being lurid, so that the lamp still works as a manually-switched lamp.

Additionally, when red, it is dimmed a little (which may save power too), and there is a brief more saturated dip on each update as a stronger hint.

Shaky video of sequence of "noon" "noon" "red" "red" "warm" "warm" "green" "green" with 5-second gaps as seen in corner of kitchen (video heavily compressed by clideo.com):

33s "signal colours noon red warm green [VIDEO]" (poster) (captions) Uploaded . Downloads:

2022-06-25: still going

Both lamps are still working. No one has complained! I'm fairly sure that they are not driving any change either, though!

2022-11-07: disconnected?

The pendant lamp in my study just did a multicolour cycle when I switched it on, and I think it has reset. I encountered this as I was about to test a switch in my broadcast colour changer to use the new (up to) 7-day red/yellow/green grid intensity indication from the previous 1-day view.