本帖最后由 neroxps 于 2020-7-16 10:05 编辑
由于机缘巧合之下,我获得了一块科陆的轨道式 485 电表 DDSD720-L ,参考鬼总的教程,使用 485-RS232-USB 摸块接入到 node-red 主机内。
科陆说明文件
科陆DDSD720-L电表使用教程 by 小鬼
Node-red
导入文件:
电表.zip
(2.82 KB, 下载次数: 72)
注意事项
阶梯电价代码需要修改自己的
我这里中山的阶梯电价第一阶梯阈值是分月份的,5~10月份第一阶梯阈值是不一样,所以需要得到当前月份计算获得阈值。
// 通过当月月份判断阶梯一的阈值
function Get_level_One_threshold(){
var Month = new Date().getMonth() + 1
if (Month >= 5 && Month <= 10) {
return 260
} else {
return 200
}
}
阶梯电价的电费
// 阶梯一电费单价
var Level_One_univalent=0.61886875
// 阶梯二电费单价
var Level_Two_univalent=0.66886875
// 阶梯三电费单价
var Level_Three_univalent=0.91886875
// 获取阶梯一阈值
var Level_One_threshold = Get_level_One_threshold()
// 获取阶梯二阈值
var Level_Two_threshold = 600
HomeAssistant 配置
sensor:
# 实时电压
- platform: mqtt
name: "ddsd720_l_voltage"
unit_of_measurement: 'V'
state_topic: "DDSD720-L/data"
value_template: "{{ value_json.Voltage }}"
# 实时功率
- platform: mqtt
name: "ddsd720_l_power"
unit_of_measurement: 'KW'
state_topic: "DDSD720-L/data"
value_template: "{{ value_json.Power }}"
# 实时电流
- platform: mqtt
name: "ddsd720_l_electric_current"
unit_of_measurement: 'A'
state_topic: "DDSD720-L/data"
value_template: "{{ value_json.Electric_current }}"
# 月用电量
- platform: mqtt
name: "ddsd720_l_energy_used"
unit_of_measurement: 'kW·h'
state_topic: "DDSD720-L/data"
value_template: "{{ value_json.Energy_used }}"
# # 当月实时电费
- platform: mqtt
name: "ddsd720_l_total_cost"
unit_of_measurement: '元'
state_topic: "DDSD720-L/cost"
value_template: "{{ value_json.Total_cost }}"
# 当天实时用电量
- platform: mqtt
name: "ddsd720_l_today_energy_used"
unit_of_measurement: 'kW·h'
state_topic: "DDSD720-L/data"
value_template: "{{ value_json.Today_Energy_Used }}"
switch:
# 刷新
- platform: mqtt
name: "ddsd720_l_refresh"
command_topic: "DDSD720-L/Refresh"
state_topic: "DDSD720-L/state"
homeassistant:
customize:
sensor.ddsd720_l_voltage:
friendly_name: 实时电压
icon: mdi:mdi-flash-red-eye
sensor.ddsd720_l_power:
friendly_name: 实时功率
icon: mdi:mdi-flash-outline
sensor.ddsd720_l_electric_current:
friendly_name: 实时电流
icon: mdi:mdi-flash-auto
sensor.ddsd720_l_energy_used:
friendly_name: 月用电量
icon: mdi:mdi-flash-circle
sensor.ddsd720_l_total_cost:
friendly_name: 当月电费
icon: mdi:mdi-cash-usd
sensor.ddsd720_l_today_energy_used:
friendly_name: 当天电量
icon: mdi:mdi-chart-bar
Lovelace
依赖插件:
- mini-graph-card
- button-card
cards:
- entity: sensor.ddsd720_l_total_cost
max: 500
min: 0
severity:
green: 200
red: 400
yellow: 250
type: gauge
- cards:
- aggregate_func: max
animate: true
entities:
- entity: sensor.ddsd720_l_today_energy_used
group_by: date
hour24: true
hours_to_show: 168
name: 近七天用电量
show:
graph: bar
type: 'custom:mini-graph-card'
- entities:
- sensor.ddsd720_l_power
hours_to_show: 24
line_width: 1
points_per_hour: 24
smoothing: false
type: 'custom:mini-graph-card'
type: horizontal-stack
- entity: switch.ddsd720_l_refresh
hold_action:
action: more-info
icon_height: 25px
name: 刷新信息
show_icon: true
show_name: true
tap_action:
action: toggle
type: button
title: 能源type: vertical-stack
|