Giter VIP home page Giter VIP logo

impc_energy's Introduction

内蒙古电费查询

简体中文 | English

hacs_badge version

查询内蒙古住户的电费及历史电量、电费情况

数据说明

数据来自内蒙古电力公司公众号

根据公众号中的说法

查询余额为结算系统余额=上月度结转电费+本月缴纳电费,实际电费余额以表计显示为准。

所以,余额不是实时余额,仅供参考。

安装

可以通过HACS或手动安装 从HACS中搜索插件名 或者从这里下载最新版本

安装后需要重启hass

配置

只需知道自己的户号,即可开始配置

  • configuration.yaml中,增加配置:
sensor:
  #...

  - platform: impc_energy
    account_number: "01xxxxxxxx70"      #户号 (使用引号括住)
    name: 家庭1                       #家庭名称(可选)

  - platform: impc_energy
    account_number: "01xxxxxxxx71"

  #...

其中name字段可选,如果不填写就会使用获取到的户名(多数情况下为住址)作为家庭名称

  • 重启hass

传感器

插件会为每个家庭添加两个传感器 剩余电费 与 历史 image

电费余额是结算余额,所以理论上数值一个月才会改变一次(交了电费也可能改变,没有测试) image

过去12个月的历史数据(用电量与电费)放到了一个传感器里 image

卡片配置

利用图表卡片 apexcharts-card 可以实现如下的效果: image

(x轴步长没有生效可能是这个图表库的问题)

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: markdown
        content: |-
          {% set home=states.sensor.impc_energy_01xxxxxxx70_balance %}
          ### {{home.state}}
          当前余额(元)
      - type: markdown
        content: |-
          {% set home=states.sensor.impc_energy_0110xxxxxx970_history %}
          ### {{home.attributes['current']['bill']}}
          本期总电费(元)
      - type: markdown
        content: |-
          {% set home=states.sensor.impc_energy_011xxxxxxx970_history %}
          ### {{home.attributes['current']['consumption']}}
          本期总电量(kW⋅h)
  - type: custom:apexcharts-card
    header:
      show: true
      title: 用电历史
      show_states: false
      colorize_states: true
    graph_span: 1y
    span:
      offset: '-1month'
    apex_config:
      legend:
        position: top
      xaxis:
        stepSize: 1
        tooltip:
          enabled: false
        labels:
          datetimeFormatter:
            year: ''
            month: M月
      tooltip:
        x:
          format: yyyy年M月
    series:
      - name: 历史电量
        entity: sensor.impc_energy_01xxxxxxxxx70_history
        type: column
        color: 3498DB
        unit: kW⋅h
        show:
          datalabels: false
          legend_value: false
        data_generator: |
          const data=[];
          const attributes=entity.attributes;
          for(let item in attributes){
            if(item.length==6&&item.startsWith("20")){
              //202403
              const timeStr=`${item.slice(0, 4)}-${item.slice(-2)}-01T00:00:00`;
              const dataObj=new Date(timeStr);
              data.push([dataObj.getTime(),attributes[item]["consumption"]]);
            }
          }
          //console.log("data1", data);
          return data;
      - name: 历史电费
        entity: sensor.impc_energy_011xxxxxx970_history
        color: FF9F0b
        unit: 
        extend_to: false
        show:
          datalabels: false
          legend_value: false
        data_generator: |
          const data=[];
          const attributes=entity.attributes;
          for(let item in attributes){
            if(item.length==6&&item.startsWith("20")){
              //202403
              const timeStr=`${item.slice(0, 4)}-${item.slice(-2)}-01T00:00:00`;
              const dataObj=new Date(timeStr);
              data.push([dataObj.getTime(),attributes[item]["bill"]]);
            }
          }
          //console.log("data2", data);
          return data;

其他

没有找到现成能用的,就自己写一个吧。

我是搞Java的,Python勉强能看懂,但是还是有些蛋疼的 (╯‵□′)╯︵┻━┻

这里鸣谢 @involute 大神,参考了他帖子中的代码

同样感谢大神@Aaron Godfrey 提供的插件开发教程

impc_energy's People

Contributors

niaoblush avatar

Stargazers

 avatar  avatar

Watchers

 avatar

impc_energy's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.