# eak012/mea-electric-bill-card architecture

> Architecture diagram of the GitHub repository eak012/mea-electric-bill-card, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eak012/mea-electric-bill-card
- Repository: https://github.com/eak012/mea-electric-bill-card

## Overview

This is a Home Assistant Lovelace card for estimating MEA Type 1.2 electricity bills. Users configure cumulative grid and optional solar sensors, choose a billing period or cutoff, and view net usage, an itemized estimate, and bill-cycle history. The sampled source supports the current-period calculation and rendering path; README capabilities fill in documented features whose implementation was not sampled, so uncertain internal wiring is omitted.

Main entry points: [`mea-electric-bill-card.js`](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js) (MEA Bill Card)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_config["Configuration"]
  node_editor["Visual Config Editor"]
  node_settings["Card Settings"]
end

subgraph group_billing["Billing Engine"]
  node_boundary["Period Boundaries"]
  node_segments["Usage Segments"]
  node_usage["Usage Aggregation"]
  node_net["Solar Net Usage"]
  node_rates["Progressive Rates"]
  node_bill["Bill Breakdown"]
  node_history["Bill-Cycle History"]
end

subgraph group_display["Card Display"]
  node_card["MEA Bill Card"]
  node_period["Period Selection"]
  node_view["Summary and Tables"]
end

node_user(("Dashboard User"))
node_ha["Home Assistant"]
node_sensors["Cumulative Energy Sensors"]
node_ha_stats[("Long-Term Statistics")]
node_ha_history["History API"]

node_user -->|"sets options"| node_editor
node_editor -->|"emits config"| node_settings
node_ha -->|"hosts card"| node_card
node_card -->|"reads config"| node_settings
node_user -->|"selects period"| node_period
node_period -->|"changes period"| node_card
node_card -->|"gets date range"| node_boundary
node_card -->|"requests usage"| node_segments
node_segments -->|"fetches statistics"| node_ha_stats
node_segments -->|"fetches recent data"| node_ha_history
node_sensors -->|"record energy"| node_ha_stats
node_sensors -->|"provide readings"| node_ha_history
node_segments -->|"provides points"| node_usage
node_usage -->|"returns totals"| node_net
node_net -->|"supplies net units"| node_bill
node_card -->|"calculates estimate"| node_bill
node_card -->|"loads bill cycles"| node_history
node_bill -->|"supplies breakdown"| node_view
node_history -->|"supplies rows"| node_view
node_card -->|"renders card"| node_view
node_view -->|"shows results"| node_user

click node_editor "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_settings "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_card "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_period "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_boundary "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_segments "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_usage "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_net "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_rates "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_bill "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_history "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"
click node_view "https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_editor,node_settings,node_user toneBlue
class node_boundary,node_segments,node_usage,node_net,node_rates,node_bill,node_history,node_ha_stats toneAmber
class node_card,node_period,node_view,node_ha_history toneMint
class node_ha,node_sensors toneIndigo
```

## Components

### Configuration

- [Visual Config Editor](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`
- [Card Settings](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`

### Billing Engine

- [Period Boundaries](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`
- [Usage Segments](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`
- [Usage Aggregation](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`
- [Solar Net Usage](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`
- [Progressive Rates](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`
- [Bill Breakdown](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`
- [Bill-Cycle History](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`

### Card Display

- [MEA Bill Card](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`
- [Period Selection](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`
- [Summary and Tables](https://github.com/eak012/mea-electric-bill-card/blob/main/mea-electric-bill-card.js): `mea-electric-bill-card.js`

### Other components

- **Dashboard User**
- **Home Assistant**
- **Cumulative Energy Sensors**
- **Long-Term Statistics**
- **History API**

## Connections

- Dashboard User → Visual Config Editor: sets options
- Visual Config Editor → Card Settings: emits config
- Home Assistant → MEA Bill Card: hosts card
- MEA Bill Card → Card Settings: reads config
- Dashboard User → Period Selection: selects period
- Period Selection → MEA Bill Card: changes period
- MEA Bill Card → Period Boundaries: gets date range
- MEA Bill Card → Usage Segments: requests usage
- Usage Segments → Long-Term Statistics: fetches statistics
- Usage Segments → History API: fetches recent data
- Cumulative Energy Sensors → Long-Term Statistics: record energy
- Cumulative Energy Sensors → History API: provide readings
- Usage Segments → Usage Aggregation: provides points
- Usage Aggregation → Solar Net Usage: returns totals
- Solar Net Usage → Bill Breakdown: supplies net units
- MEA Bill Card → Bill Breakdown: calculates estimate
- MEA Bill Card → Bill-Cycle History: loads bill cycles
- Bill Breakdown → Summary and Tables: supplies breakdown
- Bill-Cycle History → Summary and Tables: supplies rows
- MEA Bill Card → Summary and Tables: renders card
- Summary and Tables → Dashboard User: shows results
