Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############################################################################################
- ## Tenega Nasional Berhad (TNB) Malaysia Energy/Electric Bill Calculator for Home Assistant
- ## Suitable for eWelink RCCB Switch with Power Monitoring
- ############################################################################################
- ## Filename: configuration.yaml
- ############################################################################################
- ## Disclaimer: Readings is STRICTLY for reference only. It may not be the same with
- ## your actual electric bill.
- ############################################################################################
- ## This configuration has 6 parts;
- ## 1) sonoff integration
- ## 2) sensor
- ## 3) utility meter
- ## 4) monthly reset - https://pastebin.com/nwiPwLBD
- ## 5) [Optional] notification - telegram & file
- ## 6) [Optional] telegram integration
- # Sonoff Integration - AlexxIT/SonoffLAN
- sonoff:
- username: (enter your eWelink email here)
- password: (enter your eWelink Password here)
- force_update: [temperature, power]
- scan_interval: '00:01:00'
- sensors: [temperature, humidity, power, current, voltage, rssi]
- mode: local
- reload: always
- # TNB energy reading
- sensor:
- - platform: integration
- name: Energy Consumed
- source: sensor.sonoff_xxxxxxxxxx_power #sensor device dalam watt. Replace sonoff_xxxxxxxxxx with your own.
- - platform: template
- sensors:
- daily_power_kw:
- friendly_name: "Daily kWh"
- unit_of_measurement: "kWh"
- value_template: >-
- {% set C = states('sensor.daily_energy_normal') | float %}
- {{ (C / 1000) |round(2) }}
- icon_template: mdi:counter
- monthly_power_kw:
- friendly_name: "Monthly kWh"
- unit_of_measurement: "kWh"
- value_template: >-
- {% set C = states('sensor.monthly_energy_normal') | float %}
- {{ (C / 1000) |round(2) }}
- icon_template: mdi:counter
- # Bacaan Blok TNB
- - platform: template
- sensors:
- 2ndbill_tnb_rm:
- friendly_name: "2nd Jumlah Bill TNB"
- unit_of_measurement: 'MYR'
- icon_template: mdi:currency-usd
- value_template: >-
- {% if states('sensor.monthly_power_kw') | float < 201 %}
- {% set Y = states('sensor.monthly_power_kw') | float %}
- {{ (Y * 0.218) |round(2) }}
- {% elif states('sensor.monthly_power_kw') | float >= 201 %}
- 43.60
- {%- else %}
- Unknown
- {%- endif %}
- - platform: template
- sensors:
- 3rdbill_tnb_rm:
- friendly_name: "3rd Jumlah Bill TNB"
- unit_of_measurement: 'MYR'
- icon_template: mdi:currency-usd
- value_template: >-
- {% if states('sensor.monthly_power_kw') | float <= 200 %}
- 0
- {% elif states('sensor.monthly_power_kw') | float >= 301 %}
- 33.40
- {% elif states('sensor.monthly_power_kw') | float >= 201 < 300 %}
- {% set E = states('sensor.monthly_power_kw') | float - 200 %}
- {{ (E * 0.334) |round(2) }}
- {% elif states('sensor.monthly_power_kw') | float >= 301 %}
- 33.40
- {%- else %}
- Unknown
- {%- endif %}
- - platform: template
- sensors:
- 4thbill_tnb_rm:
- friendly_name: "4th Jumlah Bill TNB"
- unit_of_measurement: 'MYR'
- icon_template: mdi:currency-usd
- value_template: >-
- {% if states('sensor.monthly_power_kw') | float <= 300 %}
- 0
- {% elif states('sensor.monthly_power_kw') | float >= 601 %}
- 154.80
- {% elif states('sensor.monthly_power_kw') | float >= 301 < 600 %}
- {% set F = states('sensor.monthly_power_kw') | float - 300 %}
- {{ (F * 0.516) |round(2) }}
- {% elif states('sensor.monthly_power_kw') | float >= 601 %}
- 154.80
- {%- else %}
- Unknown
- {%- endif %}
- - platform: template
- sensors:
- 5thbill_tnb_rm:
- friendly_name: "5th Jumlah Bill TNB"
- unit_of_measurement: 'MYR'
- icon_template: mdi:currency-usd
- value_template: >-
- {% if states('sensor.monthly_power_kw') | float <= 600 %}
- 0
- {% elif states('sensor.monthly_power_kw') | float >= 901 %}
- 163.80
- {% elif states('sensor.monthly_power_kw') | float >= 601 < 900 %}
- {% set G = states('sensor.monthly_power_kw') | float - 600 %}
- {{ (G * 0.546) |round(2) }}
- {% elif states('sensor.monthly_power_kw') | float >= 901 %}
- 163.80
- {%- else %}
- Unknown
- {%- endif %}
- # Jumlah Bill TNB
- - platform: template
- sensors:
- to_bill_tnb_rm:
- friendly_name: "Total Bill TNB"
- unit_of_measurement: 'MYR'
- icon_template: mdi:currency-usd
- value_template: >-
- {% set H = states('sensor.2ndbill_tnb_rm') | float %}
- {% set I = states('sensor.3rdbill_tnb_rm') | float %}
- {% set J = states('sensor.4thbill_tnb_rm') | float %}
- {% set K = states('sensor.5thbill_tnb_rm') | float %}
- {{ (H + I + J + K) |round(2) }}
- # Average Daily Bill TNB
- - platform: template
- sensors:
- daily_tnb_rm:
- friendly_name: "Daily Bill TNB"
- unit_of_measurement: 'MYR'
- icon_template: mdi:currency-usd
- value_template: >-
- {% set Y = states('sensor.daily_power_kw') | float %}
- {{ (Y * 0.218) |round(2) }}
- # TNB METER
- utility_meter:
- daily_energy:
- source: sensor.energy_consumed
- cycle: daily
- tariffs:
- - normal
- monthly_energy:
- source: sensor.energy_consumed
- cycle: yearly
- tariffs:
- - normal
- # Notification
- notify:
- - platform: telegram
- name: notify.telegrammaster
- chat_id: !secret telegram_master
- - platform: file
- filename: /config/www/reports/monthly_tnb.csv # path where the file will be generated.
- name: Monthly TNB CSV
- timestamp: true
- telegram_bot:
- - platform: polling
- api_key: !secret telegram_key
- allowed_chat_ids:
- - !secret telegram_master
- - platform: webhooks
- api_key: !secret telegram_key
- url: https://yourHAname.duckdns.org # or your own domain name
- allowed_chat_ids:
- - !secret telegram_master
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement