A Home Assistant custom integration for myTNB. Monitor your Tenaga Nasional Berhad electricity accounts.
- Account auto-discovery: one login discovers all linked TNB accounts
- Usage tracking: current, average, and last completed month's kWh consumption
- Cost monitoring: current, projected, and last completed month's billing in RM
- Bill history: last payment date/amount, outstanding balance
- Smart meter support: SMR status per account
- Rich attributes: daily breakdown, tariff blocks, full bill history
- Retry with backoff: transient API failures are retried with exponential backoff + jitter at both the per-request level (in python-mytnb) and the per-cycle level (in this integration), so a WAF blip doesn't surface as an unavailable entity
Alternatively:
- In HACS, go to Integrations
- Open the ⋮ menu (top right) → Custom repositories
- Add
https://github.com/danieyal/ha-mytnbwith category Integration - Search for myTNB in HACS and install
Copy custom_components/mytnb/ into your Home Assistant custom_components/ directory.
- Go to Settings → Devices & Services → Add Integration
- Search for myTNB
- Enter your myTNB email and password
- All linked accounts are discovered automatically
For each discovered account (e.g. 220123456789):
| Sensor | Unit | Description |
|---|---|---|
sensor.mytnb_<acc>_current_usage |
kWh | Current billing period usage |
sensor.mytnb_<acc>_average_usage |
kWh | Average daily usage |
sensor.mytnb_<acc>_current_cost |
RM | Current billing period cost |
sensor.mytnb_<acc>_projected_cost |
RM | Projected billing period cost |
sensor.mytnb_<acc>_last_month_usage |
kWh | Last completed billing month usage |
sensor.mytnb_<acc>_last_month_cost |
RM | Last completed billing month cost |
sensor.mytnb_<acc>_due_amount |
RM | Outstanding balance |
sensor.mytnb_<acc>_last_payment_amount |
RM | Last payment amount |
sensor.mytnb_<acc>_last_payment_date |
date | Last payment date |
Each sensor includes attributes for account details, daily usage, tariff blocks, and bill history.
- Home Assistant 2024.1 or later
- Malaysian IP address (TNB API blocks non-Malaysian connections)
MIT