『瀚思彼岸』» 智能家居技术论坛

标题: 南方电网电费数据集成,支持短信验证码和扫码登陆 [打印本页]

作者: cubicpill    时间: 2022-11-19 13:28
标题: 南方电网电费数据集成,支持短信验证码和扫码登陆
本帖最后由 cubicpill 于 2024-9-19 03:22 编辑

2024.09.19 已经适配最新登录API,可选择短信验证码或扫码登录。

南方电网电费数据HA集成


本集成已经加入HACS默认存储库,可以在HACS直接搜索安装


注意:本集成需求Home Assistant最低版本为2022.11


本集成仅适用于南方电网覆盖范围(广东、广西、云南、贵州、海南),国网接口与南网不通用,因此无法适配。


--------------------------------2024.09.19更新---------------------------------------------------


v1.2.0 更新登录方式


功能性更新:



非功能性更新:



如有新增bug,欢迎反馈。

--------------------------------以下正文---------------------------------------------------


在论坛里看到 @louis_lee 大佬写的国网电费数据接入,奈何lz人在南网区域内,没办法直接用现成的插件。

看了一下论坛里大部分都是用Node-RED配合抓包得到的数据接入,比较麻烦,正好最近有点空研究了一下国网网上营业厅的登陆页面,发现比想象中容易,一步一步把登陆时的加密解密实现了。

后来发现网页端的登录态几个小时就会过期,于是又抓包研究了一下App(南网在线),发现App和网页端接口基本相同,但是登录态有效时间长很多,于是切换到了App端的API。

第一次写HA的集成,磕磕绊绊从有想法开始到最终实现写了接近两个周,期间参考了无数论坛和Github前辈们的代码,难免会有一些bug,请见谅。


由于该集成直接使用 Web API 登陆,因此资源消耗相对较小,性能较弱的机器也可以放心使用。


目前实现的功能如下,详细内容请看Github:https://github.com/CubicPill/china_southern_power_grid_stat


支持功能



可接入如下数据:



不支持阶梯电费设置(仅能获取当前所在阶梯)、峰谷电价设置和电费计算(本插件只进行数据抓取和转换,不进行任何计算),

暂时也没有支持计划(南网暂时没有统一的API),如有需求,建议单独创建对应的电价实体。


❌因为南网登录API调整,不再支持登录态失效之后自动重新登录,需要手动重新登录。


使用方法


使用HACS手动下载安装


注意:本集成需求Home Assistant最低版本为2022.11


传感器列表



Thank you



感谢瀚思彼岸论坛以下帖子作者的辛苦付出,排名不分先后



自定义集成教程参考:Building a Home Assistant Custom Component Part 1: Project Structure and Basics



















作者: itispip    时间: 2022-11-19 14:24
把国网也做了。坛子里国网那个用docker太耗费资源了。
作者: bokeylee    时间: 2022-11-19 14:56
厉害了,插件都出来了,我本来还想再让流程进化一下的,现在看来不用了哈哈哈哈哈
作者: ucomeito    时间: 2022-11-19 15:08
点添加已绑定的缴费号时候出现 Unknown error occurred
作者: water3033    时间: 2022-11-19 15:10
大佬,能否帮忙看下这个微信小程序的登陆怎么弄? token过一段时间就不行了。https://bbs.hassbian.com/thread-14730-1-1.html
作者: dscao    时间: 2022-11-19 15:27
好东西,来学习学习。
作者: ryanh7    时间: 2022-11-19 15:40
不考虑向后兼容的话,密码存储可以用公钥加密后的值以避免明文存储密码,token可以在内存中刷新,没必要通过reload集成的方式。对于密码错误之类的exception还可以在follow和sensor中优化,遇到错误就停下,以免反复尝试被锁号。
作者: shi2513    时间: 2022-11-19 17:51
真厉害啊,今晚试试
作者: jnukylin    时间: 2022-11-19 18:24
ucomeito 发表于 2022-11-19 15:08
点添加已绑定的缴费号时候出现 Unknown error occurred

我也是这样
作者: 隔壁的王叔叔    时间: 2022-11-19 18:28
这是大佬,大佬。
作者: kffnqtd    时间: 2022-11-19 20:44
支持大佬!
作者: slwl    时间: 2022-11-19 20:52
湖南人民是不是用的国家电网?
作者: 小伙子    时间: 2022-11-19 21:05
无法加载配置向导: {"message":"Invalid handler specified"}

添加集成配置信息的时候就弹出这个消息了
作者: jyz_0501    时间: 2022-11-19 21:11
期待国网山东~~~
作者: lrving163    时间: 2022-11-19 21:46
ucomeito 发表于 2022-11-19 15:08
点添加已绑定的缴费号时候出现 Unknown error occurred

我也一样。不知道什么原因。
作者: mayouz    时间: 2022-11-19 21:50
不知道什么原因。
作者: cubicpill    时间: 2022-11-19 21:56
ucomeito 发表于 2022-11-19 15:08
点添加已绑定的缴费号时候出现 Unknown error occurred

可以麻烦发一下日志吗?我感觉可能对于不同省份有些返回结构不一定一样,我只测试过广东的
作者: cubicpill    时间: 2022-11-19 21:59
小伙子 发表于 2022-11-19 21:05
无法加载配置向导: {"message":"Invalid handler specified"}

添加集成配置信息的时候就弹出这个消息了 ...

这个比较奇怪,可以发一下日志看看吗?或者 github 提 issue 也行
作者: cubicpill    时间: 2022-11-19 22:04
ryanh7 发表于 2022-11-19 15:40
不考虑向后兼容的话,密码存储可以用公钥加密后的值以避免明文存储密码,token可以在内存中刷新,没必要通 ...

感谢建议!
密码存储的话个人感觉用公钥加密之后存储意义不大,因为直接拿到加密后的那串字符串也可以用来登录,如果用户的明文密码本身不和其他平台共用的话,没有额外的安全问题;
token刷新这一块还没定型,目前方法比较简单粗暴,后续准备直接刷新之后存在hass.data里然后等unload的时候再持久化;
密码错误会直接报错让用户进入reauth,不会自主重试(虽然现在reauth flow 还没实现完)
作者: 小伙子    时间: 2022-11-19 22:15
本帖最后由 小伙子 于 2022-11-19 22:20 编辑
cubicpill 发表于 2022-11-19 21:59
这个比较奇怪,可以发一下日志看看吗?或者 github 提 issue 也行

下载zip压缩包后这个错误没了,直接在hacs下载的包还是以前的,那个好像不太行,现在添加已绑定的缴费号的时候弹出错误 Unknown error occurred


[color=var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87))]



作者: Ari    时间: 2022-11-19 22:38
大佬,这是大佬
作者: ryanh7    时间: 2022-11-19 22:53
cubicpill 发表于 2022-11-19 22:04
感谢建议!
密码存储的话个人感觉用公钥加密之后存储意义不大,因为直接拿到加密后的那串字符串也可以用 ...

考虑很多用户会使用通用密码,加密存储的本意是防止密码泄漏到其他平台,明文存储不是个好主意。同时也要考虑配置完成后密码被修改的情况。密码登录的接口不稳定,在不使用滑动验证码的情况下有时候会有一些错误返回,做好日志打印。
作者: cubicpill    时间: 2022-11-19 23:15
ryanh7 发表于 2022-11-19 22:53
考虑很多用户会使用通用密码,加密存储的本意是防止密码泄漏到其他平台,明文存储不是个好主意。同时也要 ...

目前准备暂时维持现有实现不变,后续可以考虑直接用加密后的密文登陆(相当于一个多次使用的token),不过我还是觉得,防止密码泄露是用户自己的责任。
配置完成后密码被修改会触发登陆失败,然后启动HA自带的reauth flow,应该不是问题。

作者: 刻刻崖    时间: 2022-11-20 00:23
slwl 发表于 2022-11-19 20:52
湖南人民是不是用的国家电网?

湖南用的是国网,可以登录微信看即可确认。
作者: ucomeito    时间: 2022-11-20 09:20
cubicpill 发表于 2022-11-19 21:56
可以麻烦发一下日志吗?我感觉可能对于不同省份有些返回结构不一定一样,我只测试过广东的 ...

我也是广东的



Logger: aiohttp.server
Source: custom_components/china_southern_power_grid_stat/csg_client/__init__.py:523
Integration: China Southern Power Grid Statistics (documentation, issues)
First occurred: 09:15:33 (3 occurrences)
Last logged: 09:16:54
Error handling request

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 241, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 280, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/china_southern_power_grid_stat/config_flow.py", line 175, in async_step_init
    return await self.async_step_add_account()
  File "/config/custom_components/china_southern_power_grid_stat/config_flow.py", line 232, in async_step_add_account
    accounts = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/china_southern_power_grid_stat/csg_client/__init__.py", line 523, in get_all_electricity_accounts
    AreaCode(item["areaCode"]),
  File "/usr/local/lib/python3.10/enum.py", line 385, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.10/enum.py", line 710, in __new__
    raise ve_exc
ValueError: '032000' is not a valid AreaCode


作者: ly437267    时间: 2022-11-20 10:38
同广东的,汕头   Unknown error occurred在绑定缴费号的时候也是显示未知错误
作者: ilongjiang    时间: 2022-11-20 13:26
广西用户点添加已绑定的缴费号时候出现 Unknown error occurred
作者: cubicpill    时间: 2022-11-20 15:57
ucomeito 发表于 2022-11-20 09:20
我也是广东的

已经修复,麻烦更新一下看看是否解决?
作者: BSXIAOLinzi    时间: 2022-11-20 18:48
在你的github被南网本部信息中心通知移除前赶紧folk一个私藏,哈哈
作者: ucomeito    时间: 2022-11-20 19:34
cubicpill 发表于 2022-11-20 15:57
已经修复,麻烦更新一下看看是否解决?

已经可以了·····
作者: levkan    时间: 2022-11-20 20:08
我的南方电网基本隔一天更新前天电量,导致昨天电量一直为0,能加一个前天电量的实体么?
作者: cubicpill    时间: 2022-11-20 23:18
levkan 发表于 2022-11-20 20:08
我的南方电网基本隔一天更新前天电量,导致昨天电量一直为0,能加一个前天电量的实体么? ...

我这里也是,有的时候前天的都不一定能及时更新,考虑加一个最新日耗电的实体
作者: arthurfsy    时间: 2022-11-21 15:52
感觉这个是最终完全版本了,无需抓包,无需额外安装docker挺好的!我用账号试了一下,OK的。比我最开始发的NR版本好多了
作者: matisse    时间: 2022-11-21 21:27

搜索存储库
Custom repositories
排序方式
名称
未找到符合条件的存储库
在HACS搜不到存
作者: arthurfsy    时间: 2022-11-22 15:07
matisse 发表于 2022-11-21 21:27
搜索存储库
Custom repositories
排序方式

是直接添加,不是搜索吧?
作者: yypc1300a    时间: 2022-11-22 16:08
大佬牛逼,马上试试,HACS上没搜到啊
作者: cw4774    时间: 2022-11-22 18:41
南方电网是网上国网吗  我安徽的可以用吗
作者: 佳艺造型    时间: 2022-11-22 19:26
插件手动安装好 好像找不到集成
作者: jnukylin    时间: 2022-11-23 14:06
Unknown error occurred的问题解决了吗
作者: jnukylin    时间: 2022-11-23 14:57
测试过了,更新后已经可以使用了,不能获取当月电费

作者: jnukylin    时间: 2022-11-23 14:58
台阶电价如何设置
作者: cubicpill    时间: 2022-11-23 15:56
matisse 发表于 2022-11-21 21:27
搜索存储库
Custom repositories
排序方式

现在还没添加到默认库,需要手动把GitHub项目链接添加到自定义存储库
作者: cubicpill    时间: 2022-11-23 15:58
jnukylin 发表于 2022-11-23 14:58
台阶电价如何设置

插件本身不支持电价计算,需要自己另外设置电费实体
作者: szjim312    时间: 2022-11-23 19:17
下载了最新的zip,还是会报错 Unknown error occurred,地区深圳
作者: chenquanhao    时间: 2022-11-23 21:37
 已经接入了,看下能用多久
作者: cubicpill    时间: 2022-11-23 21:39
szjim312 发表于 2022-11-23 19:17
下载了最新的zip,还是会报错 Unknown error occurred,地区深圳

是master分支的最新commit还是release里面的?release里面的那个还是之前的版本,有bug
作者: szjim312    时间: 2022-11-24 09:07
master分支在哪里下载?
作者: szjim312    时间: 2022-11-24 09:16
cubicpill 发表于 2022-11-23 21:39
是master分支的最新commit还是release里面的?release里面的那个还是之前的版本,有bug ...

已解决,食用中,谢谢!

作者: pcworker    时间: 2022-11-24 09:46
itispip 发表于 2022-11-19 14:24
把国网也做了。坛子里国网那个用docker太耗费资源了。

那个docker只是占用空间大一点吧,消耗CPU资源吗,每天只查询一次
作者: c1pher_小愚    时间: 2022-11-24 19:53
https://github.com/hacs/default/pull/1582
看到你的单子了,问下你知道一般他们这个review要多久不?他们是按月审批么
作者: cubicpill    时间: 2022-11-24 23:58
25989406 发表于 2022-11-24 19:53
https://github.com/hacs/default/pull/1582
看到你的单子了,问下你知道一般他们这个review要多久不?他们 ...

我看他们一般是两周过一批,估计轮到我还要十天吧。。。
作者: xfyisheng    时间: 2022-11-25 10:55
国家电网能这样就好了
作者: c1pher_小愚    时间: 2022-11-25 11:01
cubicpill 发表于 2022-11-24 23:58
我看他们一般是两周过一批,估计轮到我还要十天吧。。。

等的我花都谢了
作者: ASillyMan    时间: 2022-11-26 23:29
谢谢楼主分享
作者: zyling    时间: 2022-11-27 07:13
福建用户可以使用吗?
作者: fangguisheng    时间: 2022-11-30 10:08
获取到了户号,但是刷新不出任何数据是咋回事?
作者: xybu    时间: 2022-11-30 11:56
请问各位每日和每月的用电量怎么转换成柱状图? 原有的图卡用不了!
[attach]43769[/attach]
[attach]43770[/attach]
作者: fangguisheng    时间: 2022-11-30 12:50
Logger: homeassistant.components.sensor
Source: custom_components/china_southern_power_grid_stat/sensor.py:200
Integration: 传感器 (documentation, issues)
First occurred: 12:45:52 (1 occurrences)
Last logged: 12:45:52

Error while setting up china_southern_power_grid_stat platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/china_southern_power_grid_stat/sensor.py", line 145, in async_setup_entry
    await coordinator.async_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in async_refresh
    await self._async_refresh(log_failures=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners
    update_callback()
  File "/config/custom_components/china_southern_power_grid_stat/sensor.py", line 200, in _handle_coordinator_update
    account_data = self._coordinator.data.get(self._account_number)
AttributeError: 'NoneType' object has no attribute 'get'

作者: arthurfsy    时间: 2022-12-5 16:36
xybu 发表于 2022-11-30 11:56
请问各位每日和每月的用电量怎么转换成柱状图? 原有的图卡用不了!


看到有群友问怎么使用阶梯计算当月电费、展示每月明细,特此贴出NR流。
注1:里面的户号需要改为你自己的(我的是0945开头的)
注2:这个NR流里的每月电费,都是通过阶梯电费方式直接计算得出,当月电费和实际扣费可能有0.0X元的差距(方便用余额抵扣的用户看真实的电费)
注3:卡片代码仅供参考,可改为自己喜欢的样式
[attach]43882[/attach]





作者: mzkxd    时间: 2022-12-5 17:51
先回复后学习!!
作者: MX10085    时间: 2022-12-5 17:57
本帖最后由 MX10085 于 2022-12-5 20:19 编辑

正常使用,插件很强大!
作者: xybu    时间: 2022-12-5 23:05
arthurfsy 发表于 2022-12-5 16:36
看到有群友问怎么使用阶梯计算当月电费、展示每月明细,特此贴出NR流。
注1:里面的户号需要改为你自己 ...

非常感谢,这样才让数据产生的意义!
作者: levkan    时间: 2022-12-17 14:32
建议更新失败后保留上一次的数据继续显示
作者: cnbb    时间: 2023-1-6 16:35
2023-01-06 15:40:23.150 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Unexpected exception:
2023-01-06 15:40:23.221 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Error fetching CSG Account 188xxxxxxx56 data: Unexpected exception:
2023-01-06 15:40:23.221 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:23.222 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:23.223 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:23.223 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:23.224 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:23.224 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:23.225 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:23.226 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:23.226 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:23.227 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] Coordinator has no data
2023-01-06 15:40:29.142 ERROR (SyncWorker_4) [custom_components.china_southern_power_grid_stat.sensor] Error fetching data in coordinator: function get_yesterday_kwh, <CSGAPIError sta=01 message=用户日电量外部接口查询异常>
作者: vinci_chen    时间: 2023-1-7 21:02
arthurfsy 发表于 2022-12-5 16:36
看到有群友问怎么使用阶梯计算当月电费、展示每月明细,特此贴出NR流。
注1:里面的户号需要改为你自己 ...

这个不能直接用啊,小白不会改,  只弄出来上边的,下面的曲线图弄不出来
作者: cubicpill    时间: 2023-1-8 20:58
cnbb 发表于 2023-1-6 16:35
2023-01-06 15:40:23.150 ERROR (MainThread) [custom_components.china_southern_power_grid_stat.sensor] ...

看起来像是和 https://github.com/CubicPill/chi ... ecomment-1373008076 一样的问题,先看看app里是否能正常显示
作者: cnbb    时间: 2023-1-9 15:55
cubicpill 发表于 2023-1-8 20:58
看起来像是和 https://github.com/CubicPill/china_southern_power_grid_stat/issues/6#issuecomment-137 ...

南网在线app正常~~昨日用电量本身显示为0,只在用电日历可以看到
作者: liyuanhai    时间: 2023-1-14 12:25
大佬,显示不可用是什么原因啊?
作者: dhcxiaoer    时间: 2023-2-5 23:52
学习学习,大佬nb
作者: yanliwei23    时间: 2023-2-6 08:59
跪求大佬来个国网的
作者: dhcxiaoer    时间: 2023-2-6 13:27
学习学习
作者: hunl1986    时间: 2023-2-9 23:57

                               
登录/注册后可看大图


请问图片里的里的数据用什么参数获取?

作者: hunl1986    时间: 2023-2-22 11:17
xybu 发表于 2022-11-30 11:56
请问各位每日和每月的用电量怎么转换成柱状图? 原有的图卡用不了!

请问解决了吗,我也是同样的问题
作者: dxsc    时间: 2023-2-24 10:39
厉害啊,学习学习
作者: shishishi    时间: 2023-2-24 15:21
浙江的能用就好了
作者: hunl1986    时间: 2023-2-26 23:46
cubicpill 发表于 2022-11-20 23:18
我这里也是,有的时候前天的都不一定能及时更新,考虑加一个最新日耗电的实体 ...

使用apexcharts-card图表如何显示,麻烦大神帮忙改一下代码
  1. type: custom:apexcharts-card
  2. header:
  3.   show: true
  4.   title: 当月用电趋势图
  5.   show_states: true
  6.   colorize_states: true
  7. graph_span: 31d
  8. span:
  9.   start: month
  10. series:
  11.   - entity: sensor.0308300234854862_this_month_total_usage
  12.     data_generator: |
  13.       return entity.attributes.this_month_by_day.map((peak, index) => {
  14.         return [new Date(peak).getTime(), entity.attributes.this_month_by_day[index]];
  15.       });
复制代码

作者: 2CMOL    时间: 2023-2-27 02:14
添加集成的时候出现

无法加载配置向导: <html> <head><title>504 Gateway Time-out</title></head> <body> <center><h1>504 Gateway Time-out</h1></center> <hr><center>nginx</center> </body> </html> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page -->

hacs版本1.30.1
Home Assistant 2023.2.5

作者: dxsc    时间: 2023-2-28 08:32
这是大佬,大佬。
作者: TOSHINOU    时间: 2023-3-5 13:59
谢谢分享
作者: 252376009    时间: 2023-3-11 14:21
我得去学学国网的去
作者: ray_deng    时间: 2023-3-18 19:25
本帖最后由 ray_deng 于 2023-3-18 19:29 编辑

HACS安装china_southern_power_grid_stat正常,但实体中看不到,请问安装后怎么配置呢?
--------------------------------------------------------------------------------------------
找到了,在添加设备那里,添加集成,就找到了

作者: kerwinxu94    时间: 2023-3-20 17:30
本帖最后由 kerwinxu94 于 2023-3-20 17:35 编辑

感谢大佬分享
作者: elvinli    时间: 2023-3-21 10:11
大佬,这个能适配国家电网版本吗
作者: lipwah    时间: 2023-3-23 21:55
大佬,怎样显示上月电费
作者: scofield123    时间: 2023-4-14 13:33

如果是用用户编号+营业执照号码后六位,接口如何更改呢
作者: heqicheng    时间: 2023-5-20 11:39
Logger: custom_components.china_southern_power_grid_stat.sensor
Source: custom_components/china_southern_power_grid_stat/sensor.py:402
Integration: China Southern Power Grid Statistics (documentation, issues)
First occurred: 11:35:28 (8 occurrences)
Last logged: 11:38:32

Error fetching data in coordinator: API error, function get_month_daily_cost_detail, <CSGAPIError sta=02 message=深圳电费日历查询返回:营销接口异常:营销系统:10001-服务调用异常,执行数据库查询出错!查询语句:


你好,我是广州地区的,看日志是调用了深圳的接口,请问是哪里配置的问题吗?
作者: bynow    时间: 2023-5-20 12:35

跪求大佬来个国网的
作者: cubicpill    时间: 2023-5-20 12:46
heqicheng 发表于 2023-5-20 11:39
Logger: custom_components.china_southern_power_grid_stat.sensor
Source: custom_components/china_sout ...

接口应该是通用的,没有地区之分,先试试app里的用电日历(日电费部分)是否正常?
作者: heqicheng    时间: 2023-5-20 15:59
cubicpill 发表于 2023-5-20 12:46
接口应该是通用的,没有地区之分,先试试app里的用电日历(日电费部分)是否正常? ...

感谢楼主回复,试了一下,微信小程序正常,南方电网的网站没有数据,所以应该是电网接口问题?
作者: cubicpill    时间: 2023-5-20 22:23
heqicheng 发表于 2023-5-20 15:59
感谢楼主回复,试了一下,微信小程序正常,南方电网的网站没有数据,所以应该是电网接口问题? ...

那应该是南网接口的问题了,我在微信小程序里没找到每日电费,只有每日用电量,方便说一下微信小程序每日电费入口在哪吗?我看看能不能也集成进去
作者: a_dongde    时间: 2023-5-24 09:05
升级到最新版HA  5.3后将插件也升级到了最新版,,目前是所有的实体都显示不可用了···········
作者: a_dongde    时间: 2023-5-24 13:50
最新版升级后  提示实体不可用,HA版本5.3
作者: a_dongde    时间: 2023-5-24 14:32
heqicheng 发表于 2023-5-20 11:39
Logger: custom_components.china_southern_power_grid_stat.sensor
Source: custom_components/china_sout ...

遇到了同样问题,目前实体不可用
作者: kite3721    时间: 2023-5-24 14:45
2023-05-24 13:46:40.971 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 332, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered'"

作者: hunl1986    时间: 2023-5-26 21:13
把-latest_day_kwh接入能源里会变成负数,显示发电,请问如何解决
作者: tty228    时间: 2023-5-26 21:43
大佬大才,给跪了
作者: yaojogd    时间: 2023-6-6 00:39
全新安装的os10.2,还是提示无法加载配置向导: 500 Internal Server Error Server got itself in trouble
日志:
Logger: aiohttp.server
Source: requirements.py:290
First occurred: 00:19:00 (1 occurrences)
Last logged: 00:19:00

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 148, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 71, in post
    result = await self._flow_mgr.async_init(
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 845, in async_init
    flow, result = await task
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 863, in _async_init
    flow = await self.async_create_flow(handler, context=context, data=data)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 962, in async_create_flow
    await _load_integration(self.hass, handler_key, self._hass_config)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2026, in _load_integration
    await async_process_deps_reqs(hass, hass_config, integration)
  File "/usr/src/homeassistant/homeassistant/setup.py", line 389, in async_process_deps_reqs
    await requirements.async_get_integration_with_requirements(
  File "/usr/src/homeassistant/homeassistant/requirements.py", line 52, in async_get_integration_with_requirements
    return await manager.async_get_integration_with_requirements(domain)
  File "/usr/src/homeassistant/homeassistant/requirements.py", line 171, in async_get_integration_with_requirements
    await self._async_process_integration(integration, done)
  File "/usr/src/homeassistant/homeassistant/requirements.py", line 186, in _async_process_integration
    await self.async_process_requirements(
  File "/usr/src/homeassistant/homeassistant/requirements.py", line 252, in async_process_requirements
    await self._async_process_requirements(name, missing)
  File "/usr/src/homeassistant/homeassistant/requirements.py", line 290, in _async_process_requirements
    raise RequirementsNotFound(name, list(failures))
homeassistant.requirements.RequirementsNotFound: Requirements for china_southern_power_grid_stat not found: ['pycryptodome==3.15.0'].
是什么问题呢?
作者: cubicpill    时间: 2023-6-7 21:40
yaojogd 发表于 2023-6-6 00:39
全新安装的os10.2,还是提示无法加载配置向导: 500 Internal Server Error Server got itself in trouble
...

网络问题,下载python依赖包的时候出错了
作者: yaojogd    时间: 2023-6-9 00:43
cubicpill 发表于 2023-6-7 21:40
网络问题,下载python依赖包的时候出错了

全局代理都不成功。。有没有命令行安装依赖的?
作者: danmin    时间: 2023-6-13 14:44
用上了,大佬牛逼




欢迎光临 『瀚思彼岸』» 智能家居技术论坛 (https://bbs.hassbian.com/) Powered by Discuz! X3.5