Skip to content

Commit

Permalink
update example.env
Browse files Browse the repository at this point in the history
  • Loading branch information
ARC-MX committed Jun 4, 2024
1 parent 9b984cc commit e8a9c07
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 24 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@

## 三、安装

### 1)方法一(推荐):docker镜像部署,速度快
### 1)注册国家电网账户
首先要注册国家电网账户,绑定电表,并且可以手动查询电量

注册网址:[https://www.95598.cn/osgweb/login](https://www.95598.cn/osgweb/login)

### 2)docker镜像部署,速度快

1. 安装docker和homeassistant,[Homeassistant极简安装法](https://github.com/renhaiidea/easy-homeassistant)
2. 克隆仓库
Expand Down Expand Up @@ -102,7 +107,6 @@
# 日志级别
LOG_LEVEL="INFO" # 例如“DEBUG”可以查看出错情况
```

4. 运行

```bash
Expand Down Expand Up @@ -329,7 +333,6 @@ sensor:
# 支付宝&微信 打赏码
<center class="half">
<img src="assets/Alipay.png" width=200 style="margin-right: 70px";/>
<img src="assets/WeiChatpay.png" width=200/>
Expand Down
50 changes: 31 additions & 19 deletions example.env
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
# 以下项都需要修改
# 国网登录信息
PHONE_NUMBER="xxx" # 修改为自己的登录账号
PASSWORD="xxxx" # 修改为自己的登录密码
### 以下项都需要修改
## 国网登录信息
# 修改为自己的登录账号
PHONE_NUMBER="xxx"
# 修改为自己的登录密码
PASSWORD="xxxx"

# 数据库配置
ENABLE_DATABASE_STORAGE=True # or False 不启用数据库储存每日用电量数据。
# or False 不启用数据库储存每日用电量数据。
ENABLE_DATABASE_STORAGE=True
# 数据库可以填已有的mongodb数据库
MONGO_URL="mongodb://USERNAME:PASSWORD@mongo-for-sgcc:27017/" # 数据库地址 修改USERNAME PASSWORD和mongo-for-sgcc和mongo容器名称一致
DB_NAME="homeassistant" # 数据库名,默认为homeassistant
# 数据库地址 修改USERNAME PASSWORD和mongo-for-sgcc和mongo容器名称一致
MONGO_URL="mongodb://USERNAME:PASSWORD@mongo-for-sgcc:27017/"
# 数据库名,默认为homeassistant
DB_NAME="homeassistant"
# COLLECTION_NAME默认为electricity_daily_usage_{国网用户id},不支持修改。

# homeassistant配置
HASS_URL="http://localhost:8123/" # 改为你的localhost为你的homeassistant地址
## homeassistant配置
# 改为你的localhost为你的homeassistant地址
HASS_URL="http://localhost:8123/"
# homeassistant的长期令牌
HASS_TOKEN="eyxxxxx"

HASS_TOKEN="eyxxxxx" # homeassistant的长期令牌

# selenium运行参数
JOB_START_TIME="07:00" # 任务开始时间,24小时制,例如"07:00”则为每天早上7点执行,第一次启动程序如果时间晚于早上7点则会立即执行一次。
## selenium运行参数
# 任务开始时间,24小时制,例如"07:00”则为每天早上7点执行,第一次启动程序如果时间晚于早上7点则会立即执行一次。
JOB_START_TIME="07:00"

## 其他默认参数
DRIVER_IMPLICITY_WAIT_TIME=60 # 浏览器默认等待时间,秒。
RETRY_TIMES_LIMIT=5 # 登录重试次数
LOGIN_EXPECTED_TIME=60 # 登录超时时间,秒
# 浏览器默认等待时间,秒。
DRIVER_IMPLICITY_WAIT_TIME=60
# 登录重试次数
RETRY_TIMES_LIMIT=5
# 登录超时时间,秒
LOGIN_EXPECTED_TIME=60
RETRY_WAIT_TIME_OFFSET_UNIT=10
FIRST_SLEEP_TIME=10 # 第一次运行等待时间,秒
# 第一次运行等待时间,秒
FIRST_SLEEP_TIME=10

# 日志级别
LOG_LEVEL="INFO" # 例如“DUBUG”可以查看出错情况
## 日志级别
# 例如“DUBUG”可以查看出错情况
LOG_LEVEL="INFO"
10 changes: 8 additions & 2 deletions scripts/data_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from onnx import ONNX
import platform

DEBUG = False

def __ease_out_expo(sep):
if sep == 1:
return 1
Expand Down Expand Up @@ -259,8 +261,12 @@ def _fetch(self):
logging.info("Webdriver initialized.")

try:
if self._login(driver):
raise Exception("_login unsuccessed !")
if DEBUG:
driver.get(LOGIN_URL)
pass
else:
if self._login(driver):
raise Exception("_login unsuccessed !")
logging.info(f"Login successfully on {LOGIN_URL}")
time.sleep(self.RETRY_WAIT_TIME_OFFSET_UNIT)
user_id_list = self._get_user_ids(driver)
Expand Down

0 comments on commit e8a9c07

Please sign in to comment.