This document describes the Home Assistant / HACS integration architecture for public Eversource electricity tariffs as of v0.3.0+.
Production code under custom_components/eversource_rates/ is authoritative. This document explains how the integration works and notes design decisions. It is not a promise of natural gas, time-of-day, or third-party supplier support.
| Item | Value |
|---|---|
| Domain / path | eversource_rates / custom_components/eversource_rates |
| Commodity | Electricity only (natural gas is out of scope) |
| Supported territories | New Hampshire, Connecticut, Western Massachusetts, Eastern Massachusetts |
| Supported rate classes | NH: Residential Rate R CT: Rate 1 (Residential) WMA: R1 - Residential Non-Heating (Fixed & Monthly Variable Basic Service) EMA: R1 - Residential Non-Heating (Fixed & Monthly Variable Basic Service; Main & Cape service areas) |
| Supply model | Eversource default / basic service from public tariff pages |
| Timezone | All service territories evaluate tariff calendar dates in Eastern Time (America/New_York) |
| Tariff refresh schedule | Every 24 hours by default; configurable via Options (6 / 12 / 24 / 48 / 72 / 168 hours) |
| Authentication | None — unauthenticated public HTTPS endpoints with state-specific URL suffixes |
To avoid confusion between polling and repo maintenance, three distinct schedules exist:
- Home Assistant Tariff Refresh: Defaults to every 24 hours via
DataUpdateCoordinator. Configurable in integration Options to 6, 12, 24, 48, 72, or 168 hours (7 days). Saving new options immediately reloads the entry and performs a refresh. - GitHub Validation Workflow: Runs daily at
00:00 UTCvia GitHub Actions (validate.yml). Executes HACS validation,hassfest, Ruff linting/formatting, andpytestagainst local test fixtures. It does not scrape live Eversource pages. - Dependabot Checks: Runs weekly on Mondays for GitHub Actions, Python packages, and pre-commit hooks.
custom_components/eversource_rates/
├── __init__.py # Config-entry setup; coordinator lifecycle, sensor platform forward
├── manifest.json # Domain, HACS metadata, requirements (version via Release Please)
├── const.py # DOMAIN, URLs, intervals, EVERSOURCE_TIME_ZONE, TERRITORIES
├── tariffs.py # Tariff definitions, selections, and entry-data resolution
├── sources.py # Public endpoint definitions (TariffSource) per territory/rate
├── config_flow.py # Multi-step config flow + OptionsFlowWithReload
├── coordinator.py # DataUpdateCoordinator wrapper (EversourceRatesCoordinator)
├── api.py # EversourceClient (async concurrent fetch & validation)
├── models.py # Immutable slotted dataclasses (SupplyRate, DeliveryRates, EversourceRates)
├── parsers/ # Territory-specific tariff parsers (fail-closed)
│ ├── __init__.py # Parser dispatch (parse_tariff, get_tariff_parser)
│ ├── common.py # Shared parsing helpers (decimal, component_key, is_summary_row)
│ ├── nh.py # New Hampshire Rate R parser
│ ├── ct.py # Connecticut Rate 1 parser
│ └── ma.py # Massachusetts R1 parser (WMA & EMA)
├── sensor.py # Primary rate sensors + diagnostic delivery-component sensors
├── entity_ids.py # Stable object-ID generation (preserves legacy NH Rate R IDs)
├── strings.json # Integration string definitions for hassfest
└── translations/
└── en.json # Authoritative English UI translations
Developer utility (not part of the HA runtime path):
tools/fetch_eversource_rates.py
Public supply URL ──┐
├── EversourceClient (aiohttp ClientSession)
Public delivery URL ─┘ │
▼
parsers.parse_tariff()
│
▼
EversourceRates
│
▼
EversourceRatesCoordinator
│
▼
Primary + diagnostic sensors
- Fetch — Asynchronous concurrent
GETof the public supply and delivery tariff pages. Each supported territory uses a state-specific URL suffix (/nh,/ct,/wma, or/ema) without a personalization cookie. - Timezone Evaluation — Effective date intervals are evaluated in Eastern Time (
America/New_York), ensuring consistent period selection regardless of the Home Assistant host system timezone (such as UTC). - Parse — Territory parsers extract supply and delivery tables into exact
Decimalvalues. Missing required riders, malformed units, conflicting duplicates, or mismatching delivery totals fail closed. - Coordinate —
DataUpdateCoordinatorhandles scheduling and retains prior rate data when a refresh encounters an error (UpdateFailed). Successful refreshes publish an updatedretrieved_attimestamp. - Expose — Sensors publish current rates for the Energy dashboard and diagnostics.
The configuration flow dynamically asks for required attributes based on territory:
- Service territory: NH, CT, WMA, or EMA.
- Electric rate class: Appropriate rate class for the territory (e.g. Rate R, Rate 1, or R1).
- Supply plan (MA only): Fixed Basic Service or Monthly Variable Basic Service.
- Service area (EMA only): Greater Boston / Cambridge / South Shore or Cape Cod / Martha's Vineyard (reflecting differing Energy Efficiency riders).
Before creating the config entry, the flow tests live connectivity and parsing against Eversource to fail fast if pages are unreachable or changed.
Uses Home Assistant's OptionsFlowWithReload pattern. Users can select an update interval: 6, 12, 24, 48, 72, or 168 hours (7 days). Submitting options automatically reloads the entry, immediately executing a fresh coordinator refresh with the new interval.
Rate sensors use SensorStateClass.MEASUREMENT and omit SensorDeviceClass.MONETARY (which is inappropriate for USD/kWh).
- Total Electricity Rate (
sensor.eversource_total_electricity_ratefor NH; territory-prefixed for others): Supply + variable delivery in USD/kWh. This is the entity to configure in the Energy dashboard. - Supply Rate: Current Eversource default-service supply price.
- Delivery Rate: Sum of all variable Eversource delivery charges.
- Customer Charge: Fixed monthly customer charge (USD/month); intentionally excluded from the per-kWh Energy price.
Disabled-by-default diagnostic sensors expose each parsed USD/kWh delivery rider (e.g. Transmission Charge, Distribution Charge, Stranded Cost Recovery). If a rider disappears from the tariff, the entity toggles to unavailable; if it reappears, it becomes available again.
All financial math uses exact decimal.Decimal:
supply
+ Σ variable delivery components
= total_variable_rate → Total Electricity Rate sensor
The fixed monthly customer charge is excluded from the Energy dashboard price so incremental kWh costs are not distorted.
-
Release Please manages
manifest.jsonversion,CHANGELOG.md, and GitHub releases. Never manually bump release versions. -
Quality gates: CI enforces 100% passes on HACS validation,
hassfest, Ruff linting/formatting, and a strict$\ge 96%$ test coverage threshold.