Data & Automation
Automated Home Energy Analytics: Zero-Maintenance Smart Meter Texas CSV Pipeline with Apps Script, Sheets, and Looker Studio
Build a zero-maintenance, serverless home energy pipeline that ingests Smart Meter Texas 15-minute interval CSV exports via Google Apps Script into Google Sheets and Looker Studio.
Overview
Texas retail electric plans reward homeowners who actually understand their hourly load curve—especially when comparing time-of-use windows, HVAC peak cycling, or overnight 3D printing and shop loads. Smart Meter Texas already captures 15-minute interval kWh data for every ERCOT meter, but manually logging into the portal and pasting spreadsheets together quickly turns into a chore you abandon after two weeks.
By combining Smart Meter Texas scheduled email CSV reports with a small Google Apps Script trigger, an append-only Google Sheet ledger, and Looker Studio, you can run a completely serverless, zero-maintenance energy analytics pipeline at zero hosting cost.
Key Takeaways
- Schedule automated daily interval CSV deliveries from Smart Meter Texas to a dedicated Gmail label so no web scraping or fragile API tokens are required.
- Enforce idempotent deduplication using a composite key (ESI ID + Date + Start Time) so re-running or overlapping reports never double-count kWh.
- Normalize timestamp strings, day-of-week flags, and billing-period buckets at ingestion time so Looker Studio charts stay fast and simple.
- Keep raw ingestion separate from dashboard summary tabs so you can rebuild charts without ever touching historical readings.
Zero-Maintenance Serverless Pipeline Overview
The cleanest home automation pipelines eliminate moving parts. Instead of provisioning a cloud VM or maintaining brittle browser automation against the utility portal, configure Smart Meter Texas’s built-in report scheduler to email daily 15-minute interval usage CSV attachments to your Gmail account, and create a Gmail filter that applies a label such as Energy/SMT-Inbox and skips the main inbox.
A time-driven Google Apps Script trigger wakes up once every morning, scans threads carrying that inbox label, parses each CSV attachment with Utilities.parseCsv(), deduplicates rows against existing keys in Google Sheets, appends only genuinely new 15-minute intervals, and swaps the thread label to Energy/SMT-Processed. If an email arrives late or duplicates yesterday’s overlap window, the pipeline handles it silently without manual cleanup.
| Column | Data Type | Source / Derivation | Analytical Purpose |
|---|---|---|---|
| interval_key | Text (Unique) | ESIID + "|" + UsageDate + "|" + StartTime | Idempotent deduplication primary key |
| esi_id | Text | Raw CSV ESIID column (stripped quotes) | Supports multi-meter or property history |
| interval_start | DateTime | Parsed local start timestamp | Hourly heatmaps & continuous time series |
| usage_date | Date | Normalized YYYY-MM-DD | Daily totals and billing-cycle rollups |
| hour_of_day | Integer (0–23) | Extracted from start time | Load shape analysis & peak-window comparisons |
| usage_kwh | Numeric (Decimal) | Parsed USAGE_KWH interval value | Core consumption & estimated cost calculations |
| day_type | Text | Weekday vs Weekend | Separating work-from-home & weekend shop usage |
Idempotent CSV Parsing and Deduplication in Google Apps Script
Smart Meter Texas CSV headers occasionally wrap ESI IDs in single quotes to prevent Excel from corrupting 17-digit identifiers into scientific notation, and interval exports can overlap across midnight boundaries or daylight saving transitions. Writing defensive parsing logic up front prevents subtle chart spikes later.
Load the existing interval_key column into a JavaScript Set once per trigger execution, parse every CSV attachment in memory, filter out header rows and already-seen keys, and perform a single batched setValues() write at the end. Batching writes keeps Apps Script execution well under Google’s runtime quotas even if you backfill several months of historical CSVs in one pass.
const INBOX_LABEL = 'Energy/SMT-Inbox';
const PROCESSED_LABEL = 'Energy/SMT-Processed';
const LEDGER_SHEET = 'IntervalLedger';
function ingestSmartMeterCsvs() {
const inboxLabel = GmailApp.getUserLabelByName(INBOX_LABEL);
const doneLabel = GmailApp.getUserLabelByName(PROCESSED_LABEL);
if (!inboxLabel || !doneLabel) return;
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(LEDGER_SHEET);
const lastRow = sheet.getLastRow();
const existingKeys = new Set(
lastRow > 1 ? sheet.getRange(2, 1, lastRow - 1, 1).getValues().flat() : [],
);
const rowsToAppend = [];
for (const thread of inboxLabel.getThreads(0, 25)) {
for (const msg of thread.getMessages()) {
for (const att of msg.getAttachments()) {
if (!att.getName().toLowerCase().endsWith('.csv')) continue;
const parsed = Utilities.parseCsv(att.getDataAsString());
for (let i = 1; i < parsed.length; i++) {
const [rawEsi, rawDate, rawStart, , rawKwh] = parsed[i];
const esi = String(rawEsi || '').replace(/^'+/, '').trim();
const kwh = Number.parseFloat(rawKwh);
if (!esi || !rawDate || !rawStart || Number.isNaN(kwh)) continue;
const key = `${esi}|${rawDate.trim()}|${rawStart.trim()}`;
if (existingKeys.has(key)) continue;
existingKeys.add(key);
const startDt = new Date(`${rawDate.trim()} ${rawStart.trim()}`);
const day = startDt.getDay();
rowsToAppend.push([
key,
esi,
startDt,
Utilities.formatDate(startDt, Session.getScriptTimeZone(), 'yyyy-MM-dd'),
startDt.getHours(),
kwh,
day === 0 || day === 6 ? 'Weekend' : 'Weekday',
]);
}
}
}
thread.removeLabel(inboxLabel);
thread.addLabel(doneLabel);
}
if (rowsToAppend.length > 0) {
sheet.getRange(sheet.getLastRow() + 1, 1, rowsToAppend.length, 7).setValues(rowsToAppend);
}
}Visualizing Load Profiles and Rate Scenarios in Looker Studio
Connect Looker Studio directly to the IntervalLedger tab with date-range controls bound to usage_date. Because every 15-minute reading carries both hour_of_day and day_type, you can build three immediately actionable views without complex blending: a daily kWh bar trend against rolling 7-day averages, an hour-of-day load-shape curve comparing weekdays vs. weekends, and a simulated rate comparison scorecard.
Before shopping for a new Texas retail electricity contract, add calculated fields in Looker Studio that apply candidate fixed-rate tiers or free-nights time-of-use windows directly across your real historical 15-minute intervals. Evaluating plans against your own actual hourly usage eliminates marketing guesswork and reveals immediately whether shifting laundry, EV charging, or long 3D prints after 9:00 PM genuinely lowers monthly bills.
- Archive older calendar years into yearly backup tabs if your ledger grows past several hundred thousand rows so Google Sheets recalculations remain snappy.
- Add an automated email alert inside Apps Script if zero new rows arrive for three consecutive days so you notice immediately if a utility scheduled report expires.
- Keep utility delivery charges (TDU per-kWh + fixed monthly base fee) in a small Config tab so estimated bill calculations match real statements closely.