Essential Energy, 2019
Smart Plug: a $30 smart plug that doubles as a grid sensor.
We engineered and developed Smart Plug, a Flutter app for Essential Energy customers. It sets up an off-the-shelf TP-Link smart plug by speaking the plug's local protocol, shows live power, cost and schedules, and feeds every plug's voltage readings into a cloud pipeline that places each one on the low-voltage network.
- Client
- Essential Energy, the NSW Government-owned electricity distributor
- Industry
- Energy & utilities
- Services
- Consumer mobile app, IoT device integration, real-time data pipeline
- Platforms
- Flutter for iOS and Android, Firebase Auth and Cloud Messaging, App Engine, Cloud Functions, Pub/Sub, BigQuery, Firestore, Cloud SQL
- Our role
- We engineered and developed the app, its device protocol layer, the API, the cron services and the ingestion pipeline, and designed the onboarding screens.
The challenge
The low-voltage network, from the street transformer to the house, has historically been dark. Utilities know what leaves the substation and far less about what reaches each home, while rooftop solar and batteries now push power both ways along those wires. Installing new sensors at scale is slow and expensive.
Customers, meanwhile, already own devices that measure voltage and power. A smart plug of the kind sold in hardware stores for about thirty dollars measures the voltage at the wall it is plugged into, which is exactly what a distributor can't normally see.
The engineering question was whether those devices could be used responsibly: get them online without a support call, read them reliably, and put every reading in the right place on the network, while giving the customer something worth keeping the plug for.
Our approach
We built two products on one device. For customers, an app to set up the plug, switch it, schedule it and see what their appliances cost to run. For the network, a pipeline that turns every plug's readings into a low-voltage data point tagged with its substation and feeder. The customer value is what keeps the sensor plugged in.
We proved the device protocol in small scripts before writing a screen, then moved the working version into the app with tests around it. The ingestion followed the same one-schema, many-adapters pattern as the Network Visibility platform, so plug readings landed beside smart-meter and battery data.
What we built
Speaking the plug's local protocol
The plug takes small JSON commands, such as "tell me about yourself" or "turn the relay on", wrapped in a lightweight XOR autokey obfuscation. We implemented it in Dart in a single service class: a length-prefixed message over TCP for commands, and an encrypted broadcast over UDP to discover plugs on the home network, so the phone finds and configures a plug with no cloud round trip.
Obfuscation is not authentication. Anyone on the same network who knows the scheme can read and send commands, so the app treats the local network as hostile: nothing sensitive goes over it, and ownership of a plug is decided by the signed-in user in our backend, not by whoever answers on the network.
A seven-step setup flow
Onboarding is where consumer IoT loses people, so it got as much design attention as the pipeline. Seven illustrated steps: connect, find the plug, name it, link it to your meter and tariff (single-rate or time-of-use), done. Each step does one thing and explains why. When discovery fails on guest networks, mesh routers or phones on mobile data, the app gives a calm explanation and a retry, not a spinner.
Live power, cost and schedules
Customers see live power, daily kWh and what yesterday cost, plus energy-saving tips. On and off schedules, such as "heater on at 6 am on weekdays", run on the server: a cron service checks every minute in Sydney time and fires any rules due. The app shows exactly what will happen, and a schedule change is one write, not a conversation with a device that might be offline.
Carrying the meter ID
During setup the app names the plug with a convention that includes the customer's meter identifier, so every reading from the vendor's cloud arrives already carrying it. That saved a mapping table and a class of orphan-device bugs. Because a customer can rename a plug, the pipeline refuses and logs any reading whose meter ID it can't find, rather than guessing.
A pipeline that places every reading
Every five minutes a cron service queries each plug's latest reading, with at most ten queries in flight so a growing fleet never bursts past the vendor's rate limits, and publishes one Pub/Sub message per plug. A Cloud Function converts millivolts to volts and milliwatts to kilowatts, attaches premise, substation, feeder, town, depot and region, and writes history to BigQuery and the latest reading to Firestore with a geohash for maps. A React admin dashboard with Mapbox shows the plugs on the network.
Architecture
- Smart plugVoltage and power at the wall
- Flutter appLocal discovery and setup, then control
- Cron and Pub/SubEvery 5 minutes, one message per plug
- Cloud FunctionUnits converted, network context attached
- BigQuery and FirestoreHistory, and the latest reading per plug
Setup happens on the home network; ongoing readings come through the cloud.
Results
- 7illustrated steps to set up a plug
- 5 minbetween readings for every plug
- 10queries in flight at most, to respect vendor limits
- 1 minschedule checks, in Sydney time
Under the hood
A phone, a plug and a small set of single-purpose services.
- Flutter
- Dart
- TCP & UDP sockets
- XOR autokey protocol
- Firebase Auth
- Google Sign-In
- Firebase Cloud Messaging
- App Engine
- Cloud Functions
- Pub/Sub
- BigQuery
- Firestore
- Cloud SQL
- Geohash
- React
- Mapbox
What it taught us
The premise lookup built its SQL by string interpolation, and the meter ID came from a device name a customer could edit. Today we parameterise that query on day one and validate the ID before it reaches a database. Any value that has passed through a consumer device is user input, however it got to you. That rule now sits in every IoT and data build we do.
Lessons for today
- Give people a reason to keep the sensor. Customer value, such as cost and schedules, is what keeps a cheap device plugged in and reporting.
- Prototype the protocol before the product. Meet a device's surprises in a script, not in an onboarding screen.
- Convert units at the edge. Nothing downstream should need to remember which vendor reports millivolts.
- Prefer local control where you can. Today we would favour devices with documented, authenticated local APIs and standards such as Matter, so the product doesn't depend on a vendor's cloud.
- Collect the data a model will need. Clean, located, time-stamped readings are the raw material for forecasting and anomaly detection later.
Questions
How can a smart plug act as a grid sensor?
Each plug measures the voltage at the wall it is plugged into. Placed on the network by its meter, substation and feeder, every plug becomes a cheap low-voltage data point.
Is the plug's local protocol secure?
No. It is a lightweight obfuscation, not encryption or authentication, so the app keeps sensitive data off the local network and decides who owns a plug from the signed-in user in its own backend.
How does each reading know where it is on the network?
The app includes the customer's meter identifier in the plug's name during setup. The pipeline looks that meter up and attaches premise, substation, feeder and region to every reading.
Does setting up a plug need the cloud?
No. The app finds and configures the plug directly over the home network. Readings and schedules use the cloud afterwards.
Related
The services behind this work, and more stories like it.
Services
Case studies
Essential EnergySeeing the low-voltage grid. An event-driven pipeline that placed smart-meter, battery, smart-plug and telco readings on the network, with no new sensors.
Essential Energy30 days of demand, for every customer segment. CNN-LSTM forecasts for 20 tariff segments, served as an API and shown in Power BI.
Essential EnergyAn electricity network on an iPad, offline. Field Portal: custom compression for the asset map, and a form designer that removed 3,000+ paper forms and workflows.
Bring us the hard problem.
A 45-minute discovery call with the engineer who'll build it.