找回密码
 立即注册

微信扫码登录

搜索
查看: 90127|回复: 239

[新奇玩法] 我也来个电费插件(RN流)-浙江

 火... [复制链接]

9

主题

148

回帖

2204

积分

金牌会员

积分
2204
金钱
2047
HASS币
10
发表于 2021-6-28 14:20:21 | 显示全部楼层 |阅读模式
本帖最后由 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]; });


微信图片_20210628141304.jpg
微信图片_20210628141358.jpg
微信截图_20220921081953.png

电费修复.rar

5.04 KB, 下载次数: 492

电费20220920.rar

5.1 KB, 下载次数: 386

评分

参与人数 7金钱 +46 收起 理由
llgxdnn + 5 感谢楼主分享!
sczdlj` + 5 高手,这是高手!
ysst4 + 5 高手,这是高手!
nbasia + 5
h5529 + 1
wbdlwz + 5 感谢楼主分享!
+ 20 感谢楼主分享!

查看全部评分

回复

使用道具 举报

0

主题

66

回帖

448

积分

论坛积极会员

积分
448
金钱
382
HASS币
0
发表于 2025-6-19 15:34:03 | 显示全部楼层
这个现在是不是不能用了?
回复

使用道具 举报

19

主题

111

回帖

760

积分

高级会员

积分
760
金钱
630
HASS币
0
发表于 2024-9-11 16:58:00 | 显示全部楼层
大佬 这个是怎么实现的  代码是啥
93835e3ce8ff6b61298ee08cfc97cb0.png
回复

使用道具 举报

0

主题

66

回帖

448

积分

论坛积极会员

积分
448
金钱
382
HASS币
0
发表于 2024-6-14 14:00:10 | 显示全部楼层
微信公众号检修,不知道啥时候恢复
回复

使用道具 举报

0

主题

51

回帖

1021

积分

金牌会员

积分
1021
金钱
970
HASS币
0
发表于 2024-6-13 12:39:17 | 显示全部楼层
好像获取的参数变了吗?又用不了了。
回复

使用道具 举报

40

主题

1139

回帖

4535

积分

论坛元老

积分
4535
金钱
3356
HASS币
0
QQ
发表于 2024-3-12 15:18:32 | 显示全部楼层
湖北武汉的电网数据能接入吗?
回复

使用道具 举报

1

主题

191

回帖

1817

积分

金牌会员

积分
1817
金钱
1625
HASS币
0
发表于 2024-2-2 13:43:20 | 显示全部楼层
楼主你好,有个问题请教一下,这个新的一年开始,年度用电和阶梯一直没有清零,我看公众号上是还没有出现新的数据,有没有办法在流程中做到新的一年开始,强制清零呢,不然这个实时电价的统计就一直会按上一期的三阶电价统计,谢谢
回复

使用道具 举报

0

主题

66

回帖

448

积分

论坛积极会员

积分
448
金钱
382
HASS币
0
发表于 2024-1-4 17:02:42 | 显示全部楼层
本帖最后由 lihuihz 于 2024-1-4 17:11 编辑

跑了一天报错了,抓包ipad上微信公众号里查询用电详情返回“系统检修中,可以先返回旧版本使用哦”,另一个手机上微信号查询是正常的, 难道被ban了?
回复

使用道具 举报

0

主题

66

回帖

448

积分

论坛积极会员

积分
448
金钱
382
HASS币
0
发表于 2024-1-4 13:44:35 | 显示全部楼层
lihuihz 发表于 2024-1-4 13:11
楼主你好,sensor.electricity_first,sensor.electricity_second和sensor.electricity_thired这3个sensor ...

爬楼在139#楼找到方法了
回复

使用道具 举报

0

主题

66

回帖

448

积分

论坛积极会员

积分
448
金钱
382
HASS币
0
发表于 2024-1-4 13:11:16 | 显示全部楼层
楼主你好,sensor.electricity_first,sensor.electricity_second和sensor.electricity_thired这3个sensor在附件的Node-Red flow里并没有啊?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-7-16 18:00 , Processed in 0.136951 second(s), 13 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表