当前位置:首页 > HomeAssistant > 正文内容

HomeAssistant接入国家电网(电费余额用电量查询)

西风9个月前 (08-07)HomeAssistant2413

HomeAssistant接入国家电网数据(电费余额用电量查询)(理论已经是支持全国)

欢迎加入本站交流群(245996886)


sgcc_electricity

容器地址:https://registry.hub.docker.com/r/dscao/sgcc_electricity

镜像加速拉取命令:docker pull dockerproxy.com/dscao/sgcc_electricity:latest

部署 docker

以群晖部署 docker 为例,其他 docker 举一反三哈

1. 高级设置里面的,变量需要按下面填入:

PHONE_NUMBER  # 填入国家电网手机号

PASSWORD               # 填入国家电网密码

HASS_URL                 #HA 局域网地址

HASS_TOKEN            #令牌,点 ha 头像 拉到最下面创建填入即可

2.docker 文件夹文件不需要关联,直接下一步

3. 启动容器

4.ha 里面会生成一个实体,实体注册表里面搜索 95598 就出来

实体属性

本应用在启动后和每隔 8 小时抓取一次数据,并在 HA 里更新以下一个实体及其六个属性:

sensor.electricity_95598:电费余额 / 上期账单金额

is_pay: 是否当期已结清

need_pay: 账单欠费金额(后付费用户)

last_electricity_usage:最近一天用电量

thismonth_electricity_usage: 本月用电量

yearly_electricity_usage:今年以来用电量

yearly_electricity_charge: 今年以来电费

last_date: 数据更新的最后日期


手动添加实体

进入configuration.yaml,添加以下代码

template:
  - trigger:
      - platform: event
        event_type: "state_changed"
        event_data: 
          entity_id: sensor.electricity_95598
    sensor:
      - name: electricity_charge_balance_entity
        unique_id: electricity_charge_balance_entity
        state: "{{ states('sensor.electricity_95598') }}"
        state_class: measurement
        unit_of_measurement: "CNY"

      - name: electricity_balance_is_pay_entity
        unique_id: electricity_balance_is_pay_entity
        state: "{{ state_attr('sensor.electricity_95598', 'is_pay') }}"
 
      - name: last_electricity_usage_entity
        unique_id: last_electricity_usage_entity
        state: "{{ state_attr('sensor.electricity_95598', 'last_electricity_usage') }}"
        state_class: measurement
        unit_of_measurement: "KWH"

      - name: yearly_electricity_usage_entity
        unique_id: yearly_electricity_usage_entity
        state: "{{ state_attr('sensor.electricity_95598', 'yearly_electricity_usage') }}"
        state_class: measurement
        unit_of_measurement: "KWH"

      - name: yearly_electricity_charge_entity
        unique_id: yearly_electricity_charge_entity
        state: "{{ state_attr('sensor.electricity_95598', 'yearly_electricity_charge') }}"
        state_class: measurement
        unit_of_measurement: "CNY"

      - name: electricity_need_pay
        unique_id: electricity_need_pay
        state: "{{ state_attr('sensor.electricity_95598', 'need_pay') }}"
        state_class: measurement
        unit_of_measurement: "CNY"
        
      - name: thismonth_electricity_usage_entity
        unique_id: thismonth_electricity_usage_entity
        state: "{{ state_attr('sensor.electricity_95598', 'thismonth_electricity_usage') }}"
        state_class: measurement
        unit_of_measurement: "KWH"

      - name: electricity_last_date_entity
        unique_id: electricity_last_date_entity
        state: "{{ state_attr('sensor.electricity_95598', 'last_date') }}"

总结

就此就结束了~,可以通过调用实体的属性来查询各类的账单 / 金额等等,如果容器异常,看一下日志~


接入南方电网请查看: https://blog.cnod.net/post/55.html

扫描二维码推送至手机访问。

版权声明:本文转载自网络,如有侵权请与本站联系。

本文链接:https://blog.cnod.net/post/53.html

分享给朋友:

相关文章

openwrt下安装homeassitant

openwrt下安装homeassitant

最近在研究homeassistant,目前选择的设备是家里硕果仅存的N1,在一番接入后,家里的设备除了摄像头基本上都接入了homekit,其实主要原因还是因为本身家里的aqara设备就较多,摄像头暂时不想接入,因为最近在考虑更换家里的摄像头...

手动配置Home Assitant能源模块代码

新版的HA推出了全新的能源模块,可以按天,按周,按月,按年显示能源消耗情况,比之前使用配置文件手动处理的方式好了很多。但是它需要一个设置一个总消耗电量的实体,默认情况下tasmota生成的实体是不被支持的,我们需要在配置文件中这样设置:se...

HomeAssistant 接入南方电网 计算电费

HomeAssistant 接入南方电网 计算电费

1.China Southern Power Grid Statistics集成链接2.获取当月用电情况因为我的电费是固定的,没有阶梯电价用电量 * 0.63906875 = 电费3.计算电费然后在UI上显示进入configuration....

homeassistant安装zigbee2mqtt并接入海尔smartcare门磁传感器

homeassistant安装zigbee2mqtt并接入海尔smartcare门磁传感器

*本教程默认已经装好Mosquitto broker,配置好mqtt服务器*在 配置-加载项-加载项商店,右上角三个点,仓库,添加仓库地址,https://github.com/zigbee2mqtt/hassio-zigbee2...

HomeAssistant 安装 HACS教程

HomeAssistant 安装 HACS教程

1.在ha的配置目录建立custom_components、themes、tts、www文件夹2.解压hacs 到custom_components文件夹,或者下载最新版本的HACShttps://github.com/hacs/integ...

Home Assistant手动添加MQTT传感器实体

Home Assistant手动添加MQTT传感器实体

手动添加Home Assistant MQTT传感器实体打开Home Assistant配置文件configuration.yaml在末尾添加如下代码:mqtt:   sensor:   ...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。