Advertisement
zubir2k

TNB HomeAssistant Tariff Block

Jul 8th, 2021
1,261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.54 KB | None | 0 0
  1. # Bacaan Blok TNB
  2.   - platform: template
  3.     sensors:
  4.       1stbill_tnb_rm:
  5.         friendly_name: "1st Jumlah Bill TNB"
  6.         unit_of_measurement: 'MYR'
  7.         icon_template: mdi:currency-usd
  8.         value_template: >-
  9.           {% if states('sensor.monthly_power_kw') | float < 201 %}
  10.             {% set G = states('sensor.monthly_power_kw') | float %}
  11.             {{ (G * 0.218) | round(2) }}
  12.           {% elif states('sensor.monthly_power_kw') | float >= 201 %}
  13.             43.60
  14.           {%- else %}
  15.             Unknown
  16.           {%- endif %}
  17.       2ndbill_tnb_rm:
  18.         friendly_name: "2nd Jumlah Bill TNB"
  19.         unit_of_measurement: 'MYR'
  20.         icon_template: mdi:currency-usd
  21.         value_template: >-
  22.           {% if states('sensor.monthly_power_kw') | float <= 200 %}
  23.             0
  24.           {% elif states('sensor.monthly_power_kw') | float >= 301 %}
  25.             33.40
  26.           {% elif states('sensor.monthly_power_kw') | float >= 201 < 300 %}
  27.             {% set H = states('sensor.monthly_power_kw') | float - 200 %}
  28.             {{ (H * 0.334) | round(2) }}
  29.           {%- else %}
  30.             Unknown
  31.           {%- endif %}
  32.   - platform: template
  33.     sensors:
  34.       3rdbill_tnb_rm:
  35.         friendly_name: "3rd Jumlah Bill TNB"
  36.         unit_of_measurement: 'MYR'
  37.         icon_template: mdi:currency-usd
  38.         value_template: >-
  39.           {% if states('sensor.monthly_power_kw') | float <= 300 %}
  40.             0
  41.           {% elif states('sensor.monthly_power_kw') | float >= 601 %}
  42.             154.80
  43.           {% elif states('sensor.monthly_power_kw') | float >= 301 < 600 %}
  44.             {% set I = states('sensor.monthly_power_kw') | float - 300 %}
  45.             {{ (I * 0.516) | round(2) }}
  46.           {%- else %}
  47.             Unknown
  48.           {%- endif %}
  49.   - platform: template
  50.     sensors:
  51.       4thbill_tnb_rm:
  52.         friendly_name: "4th Jumlah Bill TNB"
  53.         unit_of_measurement: 'MYR'
  54.         icon_template: mdi:currency-usd
  55.         value_template: >-
  56.           {% if states('sensor.monthly_power_kw') | float <= 600 %}
  57.             0
  58.           {% elif states('sensor.monthly_power_kw') | float >= 901 %}
  59.             163.80
  60.           {% elif states('sensor.monthly_power_kw') | float >= 601 < 900 %}
  61.             {% set J = states('sensor.monthly_power_kw') | float - 600 %}
  62.             {{ (J * 0.546) | round(2) }}
  63.           {%- else %}
  64.             Unknown
  65.           {%- endif %}
  66.   - platform: template
  67.     sensors:
  68.       5thbill_tnb_rm:
  69.         friendly_name: "5th Jumlah Bill TNB"
  70.         unit_of_measurement: 'MYR'
  71.         icon_template: mdi:currency-usd
  72.         value_template: >-
  73.           {% if states('sensor.monthly_power_kw') | float <= 900 %}
  74.             0
  75.           {% elif states('sensor.monthly_power_kw') | float >= 901 %}
  76.             {% set K = states('sensor.monthly_power_kw') | float - 900 %}
  77.             {{ (K * 0.571) | round(2) }}
  78.           {%- else %}
  79.             Unknown
  80.           {%- endif %}
  81. # Jumlah Bill TNB
  82.   - platform: template
  83.     sensors:
  84.       to_bill_tnb_rm:
  85.         friendly_name: "Total Bill TNB"
  86.         unit_of_measurement: 'MYR'
  87.         icon_template: mdi:currency-usd
  88.         value_template: >-
  89.           {% set G = states('sensor.1stbill_tnb_rm') | float %}
  90.           {% set H = states('sensor.2ndbill_tnb_rm') | float %}
  91.           {% set I = states('sensor.3rdbill_tnb_rm') | float %}
  92.           {% set J = states('sensor.4thbill_tnb_rm') | float %}
  93.           {% set K = states('sensor.5thbill_tnb_rm') | float %}
  94.           {{ (G + H + I + J + K) | round(2) }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement