本帖最后由 jeep869 于 2020-6-28 16:48 编辑
参考大侠们的做法很容易就搞定了,谢谢各位前辈。
模块:peacefair(培正)PZEM-004T 根据大侠的推荐某多多购买,便宜一个快递费。下载固件刷固件:
下载Sonoff-Tasmota固件 固件选择中文sonoff-CN.bin
参考:https://bbs.hassbian.com/thread-6081-1-1.html
几个小坑:1、我买的esp01S需要烧录器,ESP.Easy.Flasher.exe软件找不到烧录器的串口。最后用的ESPFlashDownloadTool_v3.6.2.2.exe烧录。
2、Tx、Rx一定要反接。正常状态是通电后Rx微亮,等一会Tx开始闪烁。
3、电源很重要,按教程装好后始终没有电量数据,串口指示灯也没有闪烁。折腾了1天才发现是电源问题,用的手机充电器换了一个就好了。按教程接好没有数据的可以换电源试试。
设备配置:
1、设置wifi登录管理页面
2、通讯设置主要是设置串口
参考:https://bbs.hassbian.com/thread-7220-1-1.html
硬件接线:
峰谷电费地区为上海,其它地区修改时间与电价应该就可以了。
configuration.yaml
sensor:
#--------dianbiao start--------------
#总电量
- platform: mqtt
name: "Meter_Total"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{value_json['ENERGY'].Total }}"
unit_of_measurement: "KWH"
#昨日电量
- platform: mqtt
name: "Meter_zuori_dianliang"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{value_json['ENERGY'].Yesterday }}"
unit_of_measurement: "KWH"
#今日电量
- platform: mqtt
name: "Meter_jinri_dianliang"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{value_json['ENERGY'].Today }}"
unit_of_measurement: "KWH"
#当前功率
- platform: mqtt
name: "Meter_gonglv"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{value_json['ENERGY'].Power }}"
unit_of_measurement: "W"
#功率因素
- platform: mqtt
name: "Meter_yinshu"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{value_json['ENERGY'].Factor }}"
unit_of_measurement: " "
#当前电压
- platform: mqtt
name: "Meter_dianya"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{value_json['ENERGY'].Voltage }}"
unit_of_measurement: "V"
#当前电流
- platform: mqtt
name: "Meter_dianliu"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{value_json['ENERGY'].Current }}"
unit_of_measurement: "A"
#总电量
- platform: template
sensors:
zong_dianliang:
value_template: >
{{states("sensor.Meter_Total")|float | round(2)}}
unit_of_measurement: "KWH"
#今日总电量
- platform: template
sensors:
jinri_zong_dianliang:
value_template: >
{{states("sensor.Meter_jinri_dianliang")|float | round(2)}}
unit_of_measurement: "KWH"
#每天峰OR谷电费
- platform: template
sensors:
dianfei_daily_feng: #峰时
value_template: >
{{(states("sensor.daily_energy_peak") | float * 0.977) | round(2)}}
unit_of_measurement: "RMB"
- platform: template
sensors:
dianfei_daily_gu: #谷时
value_template: >
{{(states("sensor.daily_energy_offpeak") | float * 0.487) | round(2)}}
unit_of_measurement: "RMB"
#每月峰OR谷电费
- platform: template
sensors:
dianfei_monthly_feng: #峰时
value_template: >
{{(states("sensor.monthly_energy_peak") | float * 0.977) | round(2)}}
unit_of_measurement: "RMB"
- platform: template
sensors:
dianfei_monthly_gu: #谷时
value_template: >
{{(states("sensor.monthly_energy_offpeak") | float * 0.487) | round(2)}}
unit_of_measurement: "RMB"
#今日总电费
- platform: template
sensors:
daily_zong_dianfei:
value_template: >
{{states("sensor.dianfei_daily_feng")|float + states("sensor.dianfei_daily_gu") | float | round(2)}}
unit_of_measurement: "RMB"
#本月总电费
- platform: template
sensors:
monthly_zong_dianfei:
value_template: >
{{states("sensor.dianfei_monthly_feng")|float + states("sensor.dianfei_monthly_gu") | float | round(2)}}
unit_of_measurement: "RMB"
#峰OR谷电价标记处理
utility_meter:
energy:
# source: sensor.zong_dianliang
source: sensor.meter_total
cycle: monthly
daily_energy:
source: sensor.energy #utility_meter定义
cycle: daily
tariffs:
- peak
- offpeak
monthly_energy:
source: sensor.energy #utility_meter定义
cycle: monthly
tariffs:
- peak
- offpeak
#--------dianbiao end--------------
automations.yaml
- id: '1581863480417'
alias: 峰谷电费
description: 标记峰-谷电量
trigger:
- at: 06:00:00
platform: time
- at: '22:00:00'
platform: time
condition: []
action:
- entity_id: utility_meter.daily_energy
service: utility_meter.next_tariff
- entity_id: utility_meter.monthly_energy
service: utility_meter.next_tariff
做了一个包
pzem004_packages.yaml
(6.71 KB, 下载次数: 186)
参考
[硬件评测] 关于PZEM-004T-100A(V3.0)通过Sonoff-Tasmota获取数据的方法
[智能传感] 家庭用电量统计-电费(上海三相峰谷时)
[开关插座] 家庭总体能耗电压电流功率用电度数检测,进阶Grafana应用
|