zubir2k

TNB Home Assistant Reset Counter

Jun 18th, 2021 (edited)
1,231
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ############################################################################################
  2. ## Tenega Nasional Berhad (TNB) Malaysia Energy/Electric Bill Calculator for Home Assistant
  3. ## Suitable for eWelink RCCB Switch with Power Monitoring
  4. ############################################################################################
  5. ## Filename: automation.yaml
  6. ############################################################################################
  7. ## Disclaimer: Readings is STRICTLY for reference only. It may not be the same with
  8. ## your actual electric bill.
  9. ############################################################################################
  10. ## This automation performs the following;
  11. ## 1) [Optional] Record readings into file
  12. ## 2) [Optional] Notify readings to Telegram bot
  13. ## 3) Reset utility meter based on your TNB billing cycle
  14.  
  15. alias: Monthly TNB Billing
  16. description: ''
  17. trigger:
  18.   - platform: time
  19.     at: '00:00'
  20. condition:
  21.   - condition: template
  22.     value_template: '{{ (now().strftime("%d") | int) == 9 }}' # 9 ikut pada tarikh mula bill TNB setiap bulan
  23. action:
  24.   - service: notify.monthly_tnb_csv
  25.     data:
  26.       message: >-
  27.         ## TNB Bill ## This month bill for {{ states('sensor.monthly_power_kw')
  28.         | float(2) }}kWh usage is {{states('sensor.to_bill_tnb_rm') | float(2)
  29.         }} MYR
  30.   - service: notify.notify_telegrammaster
  31.     data:
  32.       title: '*⚡ TNB Bill*'
  33.       message: >-
  34.         This month bill for {{ states('sensor.monthly_power_kw') | float(2)
  35.         }}kWh usage is *{{states('sensor.to_bill_tnb_rm') | float(2) }} MYR*
  36.   - service: utility_meter.reset
  37.     data:
  38.       entity_id: utility_meter.monthly_energy
  39. mode: single
  40.  
RAW Paste Data