renhai-lab / sgcc_electricity

本应用可以帮助你将国网的电费、用电量数据接入homeassistant,并且储存到数据库。
159 stars 45 forks source link

TypeError: 'NoneType' object is not subscriptable #6

Closed MrDotW closed 1 year ago

MrDotW commented 1 year ago

docker部署, 登录成功后获取了electricity charge balance, year power usage和year power charge

然后就报错 TypeError: 'NoneType' object is not subscriptable

2023-08-08 07:22:57 [INFO ] ---- Webdriver initialized. 2023-08-08 07:24:44 [INFO ] ---- Login successfully on https://www.95598.cn/osgweb/login 2023-08-08 07:25:09 [INFO ] ---- get all user id: [' '] 2023-08-08 07:25:42 [INFO ] ---- Get electricity charge balance for successfully, balance is 126.61 CNY. 2023-08-08 07:26:19 [INFO ] ---- Get year power usage for successfully, usage is 2569 kwh 2023-08-08 07:26:19 [INFO ] ---- Get year power charge for successfully, yealrly charge is 1487.96 CNY 2023-08-08 07:26:36 [ERROR ] ---- state-refresh task failed, reason is 'NoneType' object is not subscriptable Traceback (most recent call last): File "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 = data_fetcher.fetch() File "/app/data_fetcher.py", line 86, in fetch raise e File "/app/data_fetcher.py", line 83, in fetch return self._fetch() File "/app/data_fetcher.py", line 111, in _fetch last_daily_date_list, last_daily_usage_list, yearly_charge_list, yearly_usage_list = self._get_other_data(driver, user_id_list) File "/app/data_fetcher.py", line 230, in _get_other_data self._save_daily_usage(driver, user_id_list[i - 1]) File "/app/data_fetcher.py", line 332, in _save_daily_usage collection = self.db[collection_name] TypeError: 'NoneType' object is not subscriptable

renhai-lab commented 1 year ago

很奇怪,为什么你的用户没有用户id,能提供关于用户id的更多信息吗? 登录国家电网网页版,找找页面中的切换用户下拉按钮,点击后截图发过来看看。如图: image

MrDotW commented 1 year ago

id有 我删了 这个没影响吧 主要是在获取最后一个数据的时候报错 昨天第一次运行成功了 后来一直这样

image

renhai-lab commented 1 year ago

属于不储存到数据库的代码bug,马上修复。1.3.2已修复