template:
- trigger:
- platform: mqtt
topic: tele/tasmota_D368DE/RESULT
sensor:
#电池电压(数据正确)
- name: Voltage
unique_id: v001
unit_of_measurement: "V"
state: "{{ (trigger.payload.split(',')[3] | float/100) }}"
#电池电流(数据正确)
- name: Current
unique_id: c001
unit_of_measurement: "A"
state: "{{ (trigger.payload.split(',')[4] | float/100) }}"
#电池温度(数据正确)
- name: Temperature
unique_id: tmp001
unit_of_measurement: "°C"
state: "{{ (trigger.payload.split(',')[9] | float-100) }}"
#电池功率(数据OK)
- name: Battery Power
unique_id: bp01
unit_of_measurement: "W"
state: "{{ ((trigger.payload.split(',')[3] | float/100) * (trigger.payload.split(',')[4] | float/100)) | round(2) }}"
state_class: measurement
#电池设计容量(数据OK)
- name: Amp Hours Remaining
unique_id: ahc01
unit_of_measurement: "AH"
state: "{{ (trigger.payload.split(',')[5] | float/1000) }}"
#电池百分比容量(数据ok,下面的60000是电池原始容量)
- name: Batterycapacity
unique_id: 000060000-1
unit_of_measurement: "%"
state: "{{ (trigger.payload.split(',')[5] | float/250000*100) }}"
#电池充入电量(数据OK)
- name: Chargingenergy
unique_id: ce011
unit_of_measurement: "kWh"
state: "{{ (trigger.payload.split(',')[7] | float/100000) }}"
state_class: total
device_class: energy
#电池放电电量(数据OK)
- name: Dischargingenergy
unique_id: de001
unit_of_measurement: "kWh"
state: "{{ (trigger.payload.split(',')[6] | float/100000) }}"
state_class: total
device_class: energy
#电池充放电时间(数据OK,下面的60是电池的容量可变数据)
- name: Battery Life Hours
unique_id: blh001
unit_of_measurement: "Hours"
state: "{{ (trigger.payload.split(',')[13] | float/60) }}"
#电池充放电状态 (1表示充电,0表示放电)
- name: charge_state
unique_id: cs001
state: "{{ (trigger.payload.split(',')[12]) }}"
|