forked from vtraveller/gowatt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrowattControl.py
More file actions
44 lines (40 loc) · 1.23 KB
/
growattControl.py
File metadata and controls
44 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import gowatt
import sys
import json
# Look for Growatt login from secrets.py
try:
import login
except:
print('No login details found!')
print('Create a file called login.py with this content')
print('GROWATT_USER = \'YOUR_SHINE_USER_NAME\'')
print('GROWATT_PASS = \'YOUR_SHINE_PASSWORD\'')
sys.exit(1)
# check for target_SOC percent and whether to run
if len(sys.argv) != 8:
charge_rate = 80
target_SOC = 40
start_time_hours = 1
start_time_minutes = 40
end_time_hours = 4
end_time_minutes = 30
run = 1
else:
(fn, charge_rate, target_SOC,
start_time_hours, start_time_minutes,
end_time_hours, end_time_minutes, run) = sys.argv
api = gowatt.Gowatt()
login_response = api.login(login.GROWATT_USER,
login.GROWATT_PASS)
if not login_response:
print('Failed to log into server')
sys.exit(2)
print('Successful login')
if api.setRuleBatteryFirst(start_time_hours, start_time_minutes,
end_time_hours, end_time_minutes,
amount=target_SOC, rate=charge_rate,
enable=bool(run)):
print('Battery charging set successfully')
else:
print('Battery changing times not set')
exit(3)