ARC-MX / sgcc_electricity_new

HomeAssistant 国家电网电费查询
Apache License 2.0
94 stars 11 forks source link

状态刷新失败 #16

Closed smilingpoplar closed 2 hours ago

smilingpoplar commented 5 days ago
024-06-28 10:44:59  [INFO    ] ---- 程序开始,当前仓库版本为1.4.1,仓库地址为https://github.com/ARC-MX/sgcc_electricity_new.git
2024-06-28 10:44:59  [INFO    ] ---- chromium-driver version is 120

...

2024-06-28 10:46:53  [INFO    ] ---- 将获取2户数据,user_id: ['<user_id_1>', '<user_id_2>']
...
2024-06-28 10:48:08  [INFO    ] ---- Get month power charge for <user_id_1> successfully, 2024-03-01-2024-03-31 usage is 58 KWh, charge is 24.89 CNY.
2024-06-28 10:48:08  [INFO    ] ---- Get month power charge for <user_id_1> successfully, 2024-04-01-2024-04-30 usage is 55 KWh, charge is 23.77 CNY.
2024-06-28 10:48:08  [INFO    ] ---- Get month power charge for <user_id_1> successfully, 2024-05-01-2024-05-31 usage is 54 KWh, charge is 23.47 CNY.

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='pane-second']/div[1]/div/label[2]/span[1]"}
  (Session info: chrome=120.0.6099.224)
Stacktrace:
#0 0x55e55c864233 <unknown>
#1 0x55e55c52e0fe <unknown>
#2 0x55e55c577ba6 <unknown>
#3 0x55e55c577cc1 <unknown>
#4 0x55e55c5c5204 <unknown>
#5 0x55e55c5a544d <unknown>
#6 0x55e55c5c2680 <unknown>
#7 0x55e55c5a51a3 <unknown>
#8 0x55e55c56a13e <unknown>
#9 0x55e55c56b712 <unknown>
#10 0x55e55c839534 <unknown>
#11 0x55e55c83c759 <unknown>
#12 0x55e55c83c238 <unknown>
#13 0x55e55c83cc05 <unknown>
#14 0x55e55c82babf <unknown>
#15 0x55e55c83cf8e <unknown>
#16 0x55e55c815c86 <unknown>
#17 0x55e55c8553e5 <unknown>
#18 0x55e55c8555cb <unknown>
#19 0x55e55c8637bf <unknown>
#20 0x7f212ddccea7 start_thread

#3 0x55e55c577cc1 <unknown>
#4 0x55e55c5c5204 <unknown>
#5 0x55e55c5a544d <unknown>
#6 0x55e55c5c2680 <unknown>
#7 0x55e55c5a51a3 <unknown>
#8 0x55e55c56a13e <unknown>
#9 0x55e55c56b712 <unknown>
#10 0x55e55c839534 <unknown>
#11 0x55e55c83c759 <unknown>
#12 0x55e55c83c238 <unknown>
#13 0x55e55c83cc05 <unknown>
#14 0x55e55c82babf <unknown>
#15 0x55e55c83cf8e <unknown>
#16 0x55e55c815c86 <unknown>
#17 0x55e55c8553e5 <unknown>
#18 0x55e55c8555cb <unknown>
#19 0x55e55c8637bf <unknown>
#20 0x7f212ddccea7 start_thread
. 5 retry times left.
2024-06-28 10:49:18  [ERROR   ] ---- state-refresh task failed, reason is cannot unpack non-iterable NoneType object
Traceback (most recent call last):
  File "/app/main.py", line 57, in run_task
    user_id_list, balance_list, last_daily_date_list, last_daily_usage_list, yearly_charge_list, yearly_usage_list, month_list, month_usage_list, month_charge_list = data_fetcher.fetch()
TypeError: cannot unpack non-iterable NoneType object
^CTraceback (most recent call last):
  File "/app/main.py", line 90, in <module>
    main()
  File "/app/main.py", line 52, in main
    time.sleep(1)
ARC-MX commented 4 days ago

多用户吗?我这没有多用户的环境,没法调试多用户的情况。从代码看多用户显然是有Bug的,这是老仓库遗留下来的问题。要不你先删掉一个用户试试,等我闲了我再更新吧,最近比较忙。

smilingpoplar commented 4 days ago

我看了下国网页面,跟多用户无关。页面没有“近30天”的选项,

截屏2024-06-28 17 39 04

所以报错Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='pane-second']/div[1]/div/label[2]/span[1]"}

跟 issue #11 是一个问题

ARC-MX commented 4 days ago

这不是提示,请前往国网APP开通智能交费签约即可查看近30天日电量

smilingpoplar commented 4 days ago

提了个pull request #18 :不支持30天用电量时,回退到7天。