ARC-MX / sgcc_electricity_new

HomeAssistant 国家电网电费查询
Apache License 2.0
345 stars 59 forks source link

从8月28日开始获取30天用电数据会报错,只能获取最近6天,其他天的数据全是空的,导致最后实体数据注册失败 #45

Open EricCorleone opened 2 months ago

EricCorleone commented 2 months ago
2024-08-29 14:03:50  [INFO    ] ---- 数据库: homeassistant.db 连接成功
2024-08-29 14:03:50  [INFO    ] ---- 2024-08-28的用电量30KWh已经成功存入数据库
2024-08-29 14:03:50  [INFO    ] ---- 2024-08-27的用电量30.02KWh已经成功存入数据库
2024-08-29 14:03:50  [INFO    ] ---- 2024-08-26的用电量27.77KWh已经成功存入数据库
2024-08-29 14:03:50  [INFO    ] ---- 2024-08-25的用电量33.55KWh已经成功存入数据库
2024-08-29 14:03:50  [INFO    ] ---- 2024-08-24的用电量33.65KWh已经成功存入数据库
2024-08-29 14:03:50  [INFO    ] ---- 2024-08-23的用电量24.02KWh已经成功存入数据库
Traceback (most recent call last):
  File "/app/data_fetcher.py", line 251, in fetch
    return self._fetch()
  File "/app/data_fetcher.py", line 286, in _fetch
    last_daily_date_list, last_daily_usage_list, yearly_charge_list, yearly_usage_list, month_list, month_usage_list, month_charge_list, usage, total_bill = self._get_other_data(
  File "/app/data_fetcher.py", line 444, in _get_other_data
    self.save_usage_data(driver, user_id_list[i - 1])
  File "/app/data_fetcher.py", line 601, in save_usage_data
    dic = {'date': day, 'usage': float(usage)}
ValueError: could not convert string to float: ''
2024-08-29 14:03:51  [ERROR   ] ---- Webdriver quit abnormly, reason: could not convert string to float: ''. 5 retry times left.
2024-08-29 14:03:51  [ERROR   ] ---- state-refresh task failed, reason is cannot unpack non-iterable NoneType object
Traceback (most recent call last):
  File "/app/main.py", line 55, 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, usage, total_bill = data_fetcher.fetch()
TypeError: cannot unpack non-iterable NoneType object
EricCorleone commented 2 months ago

目前我只能是给dic = {'date': day, 'usage': float(usage)}加个try,遇到报错就跳过:

sgcc_electricity_month_ladder  | 2024-08-29 15:15:05  [INFO    ] ---- 数据库: homeassistant.db 连接成功
sgcc_electricity_month_ladder  | 2024-08-29 15:15:05  [INFO    ] ---- 2024-08-28的用电量30KWh已经成功存入数据库
sgcc_electricity_month_ladder  | 2024-08-29 15:15:05  [INFO    ] ---- 2024-08-27的用电量30.02KWh已经成功存入数据库
sgcc_electricity_month_ladder  | 2024-08-29 15:15:05  [INFO    ] ---- 2024-08-26的用电量27.77KWh已经成功存入数据库
sgcc_electricity_month_ladder  | 2024-08-29 15:15:05  [INFO    ] ---- 2024-08-25的用电量33.55KWh已经成功存入数据库
sgcc_electricity_month_ladder  | 2024-08-29 15:15:05  [INFO    ] ---- 2024-08-24的用电量33.65KWh已经成功存入数据库
sgcc_electricity_month_ladder  | 2024-08-29 15:15:05  [INFO    ] ---- 2024-08-23的用电量24.02KWh已经成功存入数据库
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder  | 转浮点数报错:could not convert string to float: ''