Earth Notes: Hey Siri, Flatten the Duck! (2017)

Updated 2024-02-11 17:42 GMT.
By Damon Hart-Davis.
Green the grid, and help off-grid users too, with a simple laptop, tablet and phone tweak or two. #FlattenTheDuck #cutCarbon
duck curve from CAISO
Given Apple's tight control over, and integration of, its hardware and software, there are some simple tweaks that Apple could make to its battery charging controls to effectively add significant chunks of storage to various electricity grids around the world and make them greener and more efficient. Related adjustments would help off-grid users of Apple's rechargeable battery-powered devices, such as phones, tablets and laptops.

Summary Questions and Answers

What MacBook change would help the grid?

Avoid charging to 100% or at full rate, when the local grid is under strain or at high carbon intensity. This is known as Demand Side Response (DSR) or virtual power plant (VPP). Allow an easy override for when the user really needs the laptop full, fast.

What MacBook change would help off-grid?

Limit charging power, since off-grid sources may be more sensitive to the initial aggressive charging power when a MacBook battery is low. Allow an easy override for when the user really needs the laptop full, fast.

Can other devices with storage help the grid and off-grid?

Yes, the same techniques to limit maximum charge percentage and maximum charging power at the right moments will make a difference. Phone batteries are smaller but there are lots more of them for example.

Flattening The Duck?

California invents lots of things, including cute names for shared problems! To quote "We have come to flatten the duck":

In California, fossil fuel power plants have been complaining that solar panels steal their business during the day, and stop producing when the sun goes down. This happens exactly when everyone gets home and switches on air con, cookers, TVs etc.

So a massive ramp up in production is the result. [and results in a load curve that looks like a duck[PDF]]

...

The shape of the curve is very California-specific, but the problem is similar across the globe.

...

Solar may be part of the answer, storage and demand response the other part.

(This is a shape that traders in Europe call the "devil horns.")

More directly Flatten the Duck says:

Energy Storage has emerged as a leading solution for smoothing out the duck curve. By absorbing some of the excess energy generated by solar during the daytime and supplying it to building loads or feeding back into the grid in the afternoon and evening, it creates a flatter demand curve that will make it possible to accelerate the acceptance of renewable energy resources.
Duck curve graphs in search results

So how can Apple help, at home in sunny CA, and elsewhere in the world?

There seems not to be "an app for that" yet, possibly because the right controls are not made available by the operating system.

Some slight cleverness injected into its operating systems (and Apple lives by that, yes?) would turn its legions of battery-powered devices into virtual storage helping the grid avoid dirty and expensive fuels and use more renewables, at zero cost.

Technical Stuff

As Upside (KrakenFlex as at 2023) said The electricity grid is under stress. At peak times, it is forced to use its oldest, dirtiest, most expensive power stations to meet demand.

Furthermore, the grid has to be sized to cope with peak demand, in terms of pylons, generators, etc, building in higher costs that appear on bills and waste embodied energy too.

So What Tweaks Are Needed?

(I tried to find ways to engineer solutions myself, for my MacBook Air, but haven't yet found out how to. I think that some may only require a software tweak by Apple to make possible; others may require some hardware tweaks too. Exposing and documenting features to make these things possible would allow Apple or third parties to quietly make things "just work" better by "flattening the duck", and help save the planet!)

The operating systems (MacOS/iOS) already have a notion of where the machine is in the world from location services, eg used to automatically set the timezone for the clock.

From that location (and the season) it is easy to know roughly when peak demand happens, eg winter evenings 4pm to 9pm in the UK, from a built-in database that would be easy to maintain.

In many cases it will be possible to work out which grid the machine is likely connected to. And also to discover dynamically over the Internet (when available) when the grid is under stress, eg from tools such as the live display on this site using CO2 intensity as a proxy, or from live stats from organisations such as ENTSO-E for Europe, or the ISOs in the US. Possibly behind a server run by Apple to avoid flinging millions of extra queries at these third-party systems.

Other openADR service providers and aggregators may be happy to oblige, being paid to manage this free demand response.

Upside itself coordinated UPSes (Uninterruptible Power Supplies) for companies' computers to provide exactly this kind of service.

The algorithm to provide virtual storage to the grid might look like:

(An even more grid-friendly version might not charge beyond ~90% unless the grid had too much generation, in which case it would help absorb that excess by allowing charging to 100%.)

All of this is only needed when the device (laptop, phone, etc) is accepting power from what it thinks is an AC mains adapter.

All of this could be overridden by settings in "Energy Saver" System Preferences "Power Adapter" panel.

Bingo: 1 million laptops deferring 20% of their 50Wh battery charge would defer 10MWh of demand on the grid until it was in better shape. No pain, no cost, can be turned off by the user easily, and unlikely to cause any major pain in any case.

Note that even relatively small amounts of storage are valuable both to contribute to a large pool, and depending on how fast that storage can respond. Typical grid managers use a range of services with response times from the order of seconds to hours. The laptop virtual storage pool can be at the faster end of that.

Further, see off-grid section below, in may be reasonable to expect to curtail each laptop's peak consumption by 50% by carefully controlling charging, which might be 30W per laptop or 30MW, which represents a chunky expensive emergency diesel generator that does not need to be fired up.

Available Virtual Storage Capacity Estimate

This is an initial estimate, for which I would welcome better values for different grid catchment areas.

In the UK (for the GB grid) at least one million laptops plugged in to AC mains at times when they could make a difference, with (say) 10Wh deferrable charging/capacity each out of a 50Wh battery (so 20%, eg not charging beyond 80% full when the grid is stressed) for 10MWh of aggregate virtual storage.

Worldwide Apple sold more than 5 million Macs in Q1 2017, ie ~20m/year. Only 5% of those have to be in the UK and be in use for at least one year (and typical lifetime is probably several years) to support the above.

(Note that smartphones and tablets, while containing much less battery than laptops, are much more numerous, so may make a similar virtual storage contribution if plugged in at peak times and/or when the grid needs emergency support such as when a major generator trips off the grid unexpectedly.)

Gross grid demand in peak hours for (say) the GB grid in winter is of the order of 5h * 45GW = 225GWh, so the 10MWh of virtual storage is clearly in 'balancing' territory, as part of a wider pool of grid services and support.

Off-grid

I have a modest off-grid solar PV system with batteries, that supplies some light loads, separate from the grid-tie system on my roof. What I describe would apply just as much to someone living and working off-grid in a solar-powered cabin in the woods or van on the road, etc!

In the battery use/charging graph below, just before noon, my Internet connection hardware (eg router) automatically switched off-grid taking ~16W. A little later I plugged my MacBook Air into the off-grid system with the MBA's battery at about 20%. Whoomph! Another 60W from my off-grid system! If the sun had not been out some of that would have had to come from storage, wasting energy in the round trip and eating a little of its cycle life. And 60W is quite hard on various off-grid system components, considering that the average MBA load (see about 16h00) is more like 10--20W.

greedy laptop battery charging, but avoiding drawing from off-grid main battery with demand always below available power from PV

I was in no particular hurry to recharge my MBA at that point, and indeed I am usually not hugely time limited in my access to a charging source. (Maybe I am, just occasionally, when in a café on business.)

It would be good if we could tell our Apple devices in software to cap their additional charging demand to something like the typical non-charging demand to reduce the stress on upstream devices, or even not charge at all temporarily or unless below some low-water mark such as 80%. These could be advanced controls on the "Energy Saver" System Preferences panel, and indeed overlap with the grid-friendly features mentioned above. The only penalty is a slower charge, but the battery life could well be extended by the more gentle management.

NUT / APCUPSD

One way to achieve some of this may be to use a tool such as NUT (Network UPS Tools) and install a client side on the Mac (eg MacBook Air) that sensibly polls a server indicating when the grid (or local storage) is under strain and reduces power demand (eg blanking the screen sooner).

With a little bit of nudging (2018-09-01) I got brew install nut to do something, but it did not add any UPS controls to the the system "Energy Saver" GUI.

This superuser.com item How to Automatically Launch NUT Client at Boot on MacOS seems promising to indicate how to complete setup.

Another route may be APCUPSD, though again, simply installing that (without config edits) did not magically make any UPS options appear in the "Energy Saver" control.

The key elements of the /etc/apcupsd/apcupsd.conf config file to be edited may be:

UPSCABLE ether
UPSTYPE net
DEVICE grid-distress-server:port

Though this is not encouraging: "Note: None of these settings are observed on a system with support for an internal battery, such as a laptop. UPS emergency shutdown settings are for desktop and server only."

pmset

pmset when run as root allows manipulation of power management settings. Without root it can display them:

% pmset -g
System-wide power settings:
Currently in use:
 standbydelay         10800
 standby              1
 womp                 0
 halfdim              1
 hibernatefile        /var/vm/sleepimage
 powernap             0
 gpuswitch            2
 networkoversleep     0
 disksleep            10
 sleep                9
 autopoweroffdelay    28800
 hibernatemode        3
 autopoweroff         1
 ttyskeepawake        1
 displaysleep         9
 acwake               0
 lidwake              1

Interestingly, in macOS High Sierra (10.13.6) "Energy Saver", adjusting the "Turn display off after" control adjusts both "sleep" and "displaysleep". Adjusting "sleep" does not show in the control. So it may be possible to keep a monitoring process (for grid carbon, etc) that forces (say) "sleep" to something like battery values to save power, and restore it to the "displaysleep" value when the grid (etc) is happy again. A bit crude, but may be OK for a first pass...

2021-11-07: AlDente

I have just installed the free version of "AlDente". It prevents a MacBook battery from being 'overcooked', ie overcharged.

By default AlDente limits charge to 80%, which should prolong battery life.

It may be possible to fiddle with this to adjust the maximum charge level to respond to grid state, or to off-grid conditions when appropriate. This might even be possible by observing which charger ID is plugged in. I logged two issues/suggestions. See the info available from ioreg -w 0 -f -r -c AppleSmartBattery.

I was asked about scale and responded:

love the idea, I'm just curious. does my laptop charging make that much of a difference? I understand something like a washing machine or an EV.

Millions of laptops each with tens of watt.hours (Wh) of storage (~200M ship per year globally) makes for at least [] 10s of megawatt.hours (MWh) of potential deferred/shifted demand. Large grid-connected battery such as Australia's Hornsdale Power Reserve is ~200MWh, so on a global scale it is visible.

Another way of viewing it from the UK (GB grid) perspective: more than half the population has a laptop (https://www.statista.com/statistics/274137/laptop-penetration-in-the-united-kingdom-uk-since-2009/ thus maybe 30M laptops), and typical charging power may be 20W, so deferrable charging power ~600MW. Compared to peak demand on the GB grid yesterday of 40GW, or total contracted deferrable demand response of ~2GW IIRC, that is again significant. It won't prop the grid up on its own, but it essentially costs nothing (CapEx) and does not hurt (may even prolong battery life), and is potentially a sizeable fraction of existing solutions.

(You should also avoid running your washing machine or charging your EV in peak hours. Deferring charging your laptop should be additive not a replacement.)

2022-05-20: macOS lowpowermode

I have just upgraded my MacBook Air because the old one was falling apart. The new (M1) MBA running macOS Monterey (12.x) supports a lowpowermode separately in battery and charger/mains states.

I have just added a couple of lines to my root crontab to engage low power mode when on charger/mains between about 4pm and 8pm, which should result in a tiny reduction in grid load at GB peak times. Something like:

8-58/10 16-19 * * * pmset -c lowpowermode 1
9-59/10 20 * * * pmset -c lowpowermode 0

I am able to override lowpowermode via the battery system preferences if ever I want to. Maybe I could change the set interval to every 20 minutes rather than 10 if this arrangement becomes annoying.

2022-06-27: lowpowermode Measured

Screenshot 20220627 macOs Monterey 12p4 Power Adaptor preferences low power mode cropped
The macOS Monterey dialogue to manually enable low power mode, in this case for when on a power adaptor rather than battery, since this is how we'd be grid-friendly.

Today I actually measured power consumption with my Satechi USB-C power meter. In a typical moderately quiet moment, eg with an editor open and screen on, but not doing very much, power consumption dropped from ~4.9W to ~4.2W, ie 0.7W or ~15%. This 15% seems to be a representative saving, given some Web searches.

I have asked the folks at AlDente if they would consider having an option to automatically engage this mode alongside other grid-friendly features. They seem amenable to the idea... (Also added comment to existing GitHub issue.)

Some search engine playing suggests that ~15% of UK Internet users have MacBooks (as of today). That might translate to ~2M GB-grid-connected MacBooks. So avoiding charging has a virtual capacity of maybe ~60MW, low power mode maybe another ~1MW+. The grid could do with GW savings at peak, but these levels are not worthless.

2022-11-07: AlDente Calibration

For the first time ever, I think, I did a calibration in AlDente, certainly the first time on the MBA M1.

I note that during the 'discharge' phases, when although connected to mains power (via the adaptor) via USB-C the MBA actually runs from battery power, my Satechi USB meter reports that the MBA was/is still drawing ~70mA at ~20V, ie ~1.4W. I think that more than 1Ah was drawn like that, and then more than 3Ah additional while charging up from 15% again. Typical "MBA running but battery not charging" is ~180mA @ ~20V, ie ~3.6W.

2023-03-11: AlDente 1.21 Schedule

AlDente 1.21 now has scheduled tasks, so I have set one to lower the charge limit to 50% just before 4pm daily, and another to raise the limit to 80% just after 8pm. (I may change the daily to just weekdays, since weekend peaks are milder.)

I have "Start Tasks at next Opportunity" enabled, so if the MBA happens to be sleeping at one of these times then the right thing should happen when it is woken.

I am leaving my lowpowermode tweaks in cron (at similar times) for now, though I hope that they can be folded into these tasks soon.

Thus my MBA will avoid charging during peak times unless the battery is low, but will still run from mains when present. That avoids adding cycling wear to the MBA battery, and avoids round-trip battery losses, maximising efficiency. Alongside the existing lowpowermode stuff, this helps automagically gently reduce/defer grid demand at peak times a little.

2023-04-02: adjusted to be weekdays rather than daily, mainly to allow calibration (alternate weekends) to have a chance uninterrupted. Demand peaks are generally less troublesome at weekends.

2023-04-07: experimentally strengthened the AlDente ~4pm action to "Discharge to 40%" (on weekdays). This will cycle the Mac's battery sacrificially, so I will probably revert to just setting the charge limit to 40% soon.

2023-04-10: using my Mac, streaming some music, etc, the consumption difference (as measured by my Satechi USB power monitor) between AlDente's Discharge mode (~1.4W) and paused above the charge limit (7W) is enough to eat into battery life and indeed incur a significant round-trip energy penalty, so I'm reverting to "set limit at 40%" rather than "discharge to 40%".

2023-04-24: trying a graded approach, all on weekdays only, allowing for stronger response to a "peak peak" ~5pm to ~7pm:

  • At ~4pm, set lowpowermode and set a charge limit of 40%.
  • At ~5pm, set "Discharge to" 40% (ie essentially run off battery).
  • At ~7pm, set a charge limit of 40% (undoing discharge mode).
  • At ~8pm, unset lowpowermode and set a charge limit of 80%.

Note that our cooking at home is often for a 5:30pm meal. The GB peak tends to be a little later. This scheme "peak peak" nominally covers both.

(NB: just completed a calibration cycle, started ~6pm Saturday, by the wee hours of Monday!)

~4409 words.