本帖最后由 tangxingjie1991 于 2022-9-21 08:22 编辑
1、通过stream抓取国网浙江电力的公众号,有个checkLogin的链接,复制后面的参数填入nr里面设置参数节点,然后再填写你的户号,同步间隔最好一天一次,免的被拉黑。
2、实体在集成里添加Node-RED Companion,没有的自行在HACS里安装
2022.5.20 修复了公众号字段变更引起的问题
修改了设置参数节点 params需要抓包checkLogin后面参数解码后再填入
2022.9.20 修复了公众号更新后不可用
UI配置
- title: 电费
path: ''
icon: mdi:lightning-bolt
badges: []
cards:
- type: gauge
entity: sensor.gong_lu
name: 全屋功耗
needle: true
severity:
green: 0
yellow: 1000
red: 3000
min: 0
unit: ' '
max: 6000
- type: grid
cards:
- type: entities
state_color: true
show_header_toggle: false
entities:
- entity: sensor.daily_energy
type: custom:multiple-entity-row
secondary_info: last-changed
icon: mdi:ev-station
unit: 度
name: 今日用电
entities:
- entity: sensor.daily_energy_peak
name: 峰
unit: false
- entity: sensor.daily_energy_offpeak
name: 谷
unit: false
- entity: sensor.daily_energy_cost
type: custom:multiple-entity-row
secondary_info: last-changed
unit: 元
name: 今日用电
entities:
- entity: sensor.daily_energy_peak_cost
name: 峰
unit: false
- entity: sensor.daily_energy_offpeak_cost
name: 谷
unit: false
- entity: sensor.dayelectricity
type: custom:multiple-entity-row
secondary_info: last-changed
name: 昨日用电
entities:
- attribute: f
name: 峰
- attribute: g
name: 谷
- entity: sensor.dayelectricityprice
type: custom:multiple-entity-row
entities:
- attribute: daypricef
name: 峰
- attribute: daypriceg
name: 谷
name: 昨日用电
- entity: sensor.monthelectricity
type: custom:multiple-entity-row
name: 月度用电
entities:
- attribute: f
name: 峰
- attribute: g
name: 谷
- entity: sensor.monthelectricityprice
type: custom:multiple-entity-row
name: 月度用电
entities:
- attribute: monthpricef
name: 峰
- attribute: monthpriceg
name: 谷
- entity: sensor.yearelectricity
name: 年度用电
- type: custom:bar-card
width: 45%
height: 2em
decimal: 0
unit_of_measurement: '%'
positions:
icon: outside
indicator: 'off'
name: outside
severity:
- color: Green
from: 0
to: 25
- color: Orange
from: 26
to: 50
- color: Red
from: 51
to: 100
entity_row: true
entities:
- entity: sensor.electricity_first
- entity: sensor.electricity_second
- type: custom:bar-card
width: 45%
height: 2em
decimal: 0
unit_of_measurement: 度
positions:
icon: outside
indicator: 'off'
name: outside
severity:
- color: '#303435'
from: 11
to: 100
- color: '#6d2525'
from: 0
to: 10
entity_row: true
entities:
- entity: sensor.electricity_thired
columns: 1
square: false
- type: custom:apexcharts-card
graph_span: 15d
locale: zh-cn
all_series_config:
stroke_width: 2
opacity: 0.8
type: line
header:
show: true
title: 用电情况
show_states: true
colorize_states: true
series:
- entity: sensor.historyelectricity
name: 峰用电
data_generator: |
const data = [];
entity.attributes.history.map((peak, index) => {
data.push([new Date(peak.datetime).getTime(), peak.ZXYGZ2]);
});
for( var i = 0; i < data.length; i++ ){
for( var j = i + 1; j < data.length; j++ ){
if(data[i][0] > data[j][0]){
const data1 = data[i];
data[i] = data[j];
data[j] = data1;
}
}
}
return data;
- entity: sensor.historyelectricity
name: 谷用电
data_generator: |
const data = [];
entity.attributes.history.map((peak, index) => {
data.push([new Date(peak.datetime).getTime(), peak.ZXYGZ4]);
});
for( var i = 0; i < data.length; i++ ){
for( var j = i + 1; j < data.length; j++ ){
if(data[i][0] > data[j][0]){
const data1 = data[i];
data[i] = data[j];
data[j] = data1;
}
}
}
return data;
- entity: sensor.historyelectricity
name: 全天用电
data_generator: |
const data = [];
entity.attributes.history.map((peak, index) => {
data.push([new Date(peak.datetime).getTime(), peak.ZXYGZ]);
});
for( var i = 0; i < data.length; i++ ){
for( var j = i + 1; j < data.length; j++ ){
if(data[i][0] > data[j][0]){
const data1 = data[i];
data[i] = data[j];
data[j] = data1;
}
}
}
return data;
- type: custom:apexcharts-card
graph_span: 12month
locale: zh-cn
all_series_config:
stroke_width: 2
opacity: 0.8
type: column
show:
legend_value: false
datalabels: true
as_duration: month
header:
show: true
title: 月度电费
series:
- entity: sensor.historyelectricitybill
name: 月度电费
data_generator: >-
return entity.attributes.list.map((peak, index) => { return [new
Date(peak.recordDate).getTime(), peak.rcvedAmt]; });
- type: custom:apexcharts-card
graph_span: 12month
locale: zh-cn
all_series_config:
stroke_width: 2
opacity: 0.8
type: column
show:
legend_value: false
datalabels: true
as_duration: month
header:
show: true
title: 月度耗电
series:
- entity: sensor.historyelectricitybill
name: 月度耗电
unit: 度
data_generator: >-
return entity.attributes.list.map((peak, index) => { return [new
Date(peak.recordDate).getTime(), peak.pq]; });
|