Skip to content

Repository files navigation

Home Assistant myTNB Integration

A Home Assistant custom integration for myTNB. Monitor your Tenaga Nasional Berhad electricity accounts.

Features

  • 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

Installation

HACS (recommended)

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Alternatively:

  1. In HACS, go to Integrations
  2. Open the menu (top right) → Custom repositories
  3. Add https://github.com/danieyal/ha-mytnb with category Integration
  4. Search for myTNB in HACS and install

Manual

Copy custom_components/mytnb/ into your Home Assistant custom_components/ directory.

Configuration

  1. Go to SettingsDevices & ServicesAdd Integration
  2. Search for myTNB
  3. Enter your myTNB email and password
  4. All linked accounts are discovered automatically

Sensors

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.

Requirements

  • Home Assistant 2024.1 or later
  • Malaysian IP address (TNB API blocks non-Malaysian connections)

License

MIT

About

Home Assistant custom integration for myTNB

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages