How danieyal/ha-mytnb works
This Home Assistant integration discovers linked TNB accounts during setup, then periodically fetches usage, billing, payment, and balance data. The coordinator retries transient failures and supplies per-account sensors, while daily readings are imported as long-term recorder statistics. The README also documents rich sensor attributes and account reconfiguration. Arrows reflect the shown calls and data reads; the TNB service is external, and its API internals are not part of this repository.
Main entry points: coordinator.py Account data polling · __init__.py Integration lifecycle · config_flow.py Login and account selection · statistics.py Daily statistics import
Components 10
Account setup
- Login and account selection
custom_components/mytnb/config_flow.py - Integration lifecycle
custom_components/mytnb/__init__.py
Polling runtime
- Integration settings
custom_components/mytnb/const.py - Account data polling
custom_components/mytnb/coordinator.py - Transient retry policy
custom_components/mytnb/retry.py
Account sensors
- Usage and billing sensors
custom_components/mytnb/sensor.py
Usage history
- Daily statistics import
custom_components/mytnb/statistics.py
Other components
- Home Assistant user
- myTNB service
- Home Assistant recorder
Connections 10
- Home Assistant user → Login and account selection: configures
README.md - Login and account selection → myTNB service: validates and discovers
custom_components/mytnb/config_flow.py - Integration lifecycle → Login and account selection: reuses validation
custom_components/mytnb/__init__.py - Integration lifecycle → Account data polling: creates and refreshes
custom_components/mytnb/__init__.py - Integration lifecycle → Usage and billing sensors: forwards platform setup
custom_components/mytnb/__init__.py - Account data polling → myTNB service: logs in and fetches account data
custom_components/mytnb/coordinator.py - Account data polling → Transient retry policy: applies retry policy
custom_components/mytnb/coordinator.py - Account data polling → Daily statistics import: backfills daily readings
custom_components/mytnb/coordinator.py - Account data polling → Usage and billing sensors: provides account data
custom_components/mytnb/sensor.py - Daily statistics import → Home Assistant recorder: reads and imports statistics
custom_components/mytnb/statistics.py