不用监测电费啊,再说那个也不准。
自己写template计算.
sensor:
#今日电费
- platform: template
sensors:
jinri_dianfei:
unit_of_measurement: "RMB"
value_template: >
{% if now().month in [1,3,5,7,8,10,12] %}
{% set date = (31 - now().day) %}
{% elif now().month in [4,6,9,11] %}
{% set date = (30 - now().day) %}
{% elif now().month == 2 and ((now().year-2000) % 4 > 0) %}
{% set date = (28 - now().day) %}
{% elif now().month == 2 and ((now().year-2000) % 4 == 0) %}
{% set date = (29 - now().day) %}
{% endif %}
{% if (date != 0 and (states("sensor.ben_nian_du_yong_dian") | float - states("sensor.jin_ri_yong_dian") | float + (states("sensor.zuo_ri_dianliang") | float * (date + 1))) | int > 3120) or (date == 0 and states("sensor.ben_nian_du_yong_dian") | int > 3120) %}
{{(states("sensor.jin_ri_yong_dian") | float * 0.86) | round(2)}}
{% elif (date != 0 and (states("sensor.ben_nian_du_yong_dian") | float - states("sensor.jin_ri_yong_dian") | float + (states("sensor.zuo_ri_dianliang") | float * (date + 1))) | int > 2160) or (date == 0 and states("sensor.ben_nian_du_yong_dian") | int > 2160) %}
{{(states("sensor.jin_ri_yong_dian") | float * 0.61) | round(2)}}
{% else %}
{{(states("sensor.jin_ri_yong_dian") | float * 0.56) | round(2)}}
{% endif %}
#总电费
- platform: template
sensors:
zongdianfei:
unit_of_measurement: "RMB"
value_template: >
{% if now().month in [1,3,5,7,8,10,12] %}
{% set date = (31 - now().day) %}
{% elif now().month in [4,6,9,11] %}
{% set date = (30 - now().day) %}
{% elif now().month == 2 and ((now().year-2000) % 4 > 0) %}
{% set date = (28 - now().day) %}
{% elif now().month == 2 and ((now().year-2000) % 4 == 0) %}
{% set date = (29 - now().day) %}
{% endif %}
{% if (date != 0 and (states("sensor.ben_nian_du_yong_dian") | float - states("sensor.jin_ri_yong_dian") | float + (states("sensor.zuo_ri_dianliang") | float * (date + 1))) | int > 3120) or (date == 0 and states("sensor.ben_nian_du_yong_dian") | int > 3120) %}
{{(states("sensor.ben_nian_du_yong_dian") | float * 0.86) | round(2)}}
{% elif (date != 0 and (states("sensor.ben_nian_du_yong_dian") | float - states("sensor.jin_ri_yong_dian") | float + (states("sensor.zuo_ri_dianliang") | float * (date + 1))) | int > 2160) or (date == 0 and states("sensor.ben_nian_du_yong_dian") | int > 2160) %}
{{(states("sensor.ben_nian_du_yong_dian") | float * 0.61) | round(2)}}
{% else %}
{{(states("sensor.ben_nian_du_yong_dian") | float * 0.56) | round(2)}}
{% endif %}
#当前阶梯
- platform: template
sensors:
dang_qian_jie_ti:
unit_of_measurement: "L"
value_template: >
{% if states("sensor.ben_nian_du_yong_dian") | float <= 2160 %}
1
{% elif states("sensor.ben_nian_du_yong_dian") | float >2160 and states("sensor.ben_nian_du_yong_dian") | float <= 3120 %}
2
{% elif states("sensor.ben_nian_du_yong_dian") | float > 3120 %}
3
{% else %}
4
{% endif %}
friendly_name: '当前阶梯'
|