Advertisement
ninhvanthang

Tính tiền điện

Jul 14th, 2019
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.92 KB | None | 0 0
  1. sensor:
  2.   - platform: template
  3.     sensors:
  4.       tiendien:
  5.         friendly_name: "Tiền điện"
  6.         unit_of_measurement: 'đ'
  7.         value_template: >-
  8.           {% set watt = states('sensor.monthly_energy')|float %}
  9.           {%- if(watt >= 400) -%}
  10.           {% set money = 83900 + 173400 + 201400 + 253600 + 283400 + (watt-400)*2927 %}
  11.           {%- elif(watt >= 300) -%}
  12.           {% set money = 83900 + 173400 + 201400 + 253600 + (watt-300)*2834 %}
  13.           {%- elif(watt >= 200) -%}
  14.           {% set money = 83900 + 173400 + 201400 + (watt-200)*2536 %}
  15.           {%- elif(watt >= 100) -%}
  16.           {% set money = 83900 + 173400 + (watt-100)*2014 %}
  17.           {%- elif(watt >= 50) -%}
  18.           {% set money = 83900 + (watt-50)*1734 %}
  19.           {%- else -%}
  20.           {% set money = watt*1678 %}
  21.           {%- endif-%}
  22.           {% set money = money*1.1 %}
  23.           {{ "{0:,.0f}".format(money| int) }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement