Skip to content

Commit

Permalink
Merge pull request dracoventions#4 from the-dbp/growatt
Browse files Browse the repository at this point in the history
use json for battery config
  • Loading branch information
the-dbp authored Apr 19, 2021
2 parents 65bdf97 + 1850f4c commit 2e1da15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion etc/twcmanager/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,15 @@
"token": "xx"
},
#Growatt: I'm using a growatt pypi package to very easily pull the data
#useBatteyAt describes at whihc SOC the system will add the battery's maxOutput to the pool of available power
#batteryMaxOutput is the maximum watt that the battery will output calculated by dividing battery Wh in two,
#in my case that's 9600wh and half of that is 4800
"Growatt": {
"enabled": false,
"username":"username",
"password":"password"
"password":"password",
"useBatteryAt":"80",
"batteryMaxOutput":"4800"
}

},
Expand Down
10 changes: 6 additions & 4 deletions lib/TWCManager/EMS/Growatt.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Growatt:
status = False
timeout = 2
username = None
useBatteryAt = 80 #set to 100 if you don't want to use from battery
batteryGenerates = 4800 #my battery is 9.6kwh it generates half of that number as kw
useBatteryAt = None
batteryMaxOutput = None

def __init__(self, master):
self.master = master
Expand All @@ -39,6 +39,8 @@ def __init__(self, master):
self.password = self.configGrowatt.get("password", "")
self.status = self.configGrowatt.get("enabled", False)
self.username = self.configGrowatt.get("username", "")
self.useBatteryAt = float(self.configGrowatt.get("useBatteryAt", ""))
self.batteryMaxOutput = float(self.configGrowatt.get("batteryMaxOutput", ""))

# Unload if this module is disabled or misconfigured
if (not self.status) or (
Expand Down Expand Up @@ -107,11 +109,11 @@ def getGenerationValues(self):
mix_status = api.mix_system_status(device_sn, plant_ID)
self.batterySOC = float(mix_status['SOC'])
gen_calc = float(status['pPv1']) + float(status['pPv2'])
gen_calc = gen_calc*1000
gen_calc *= 1000
gen_api = float(status['ppv'])*1000

if self.useBatteryAt<self.batterySOC:
self.generatedW = gen_api+self.batteryGenerates
self.generatedW = gen_api+self.batteryMaxOutput
else:
self.generatedW = gen_api
self.consumedW =float(status['pLocalLoad'])*1000
Expand Down

0 comments on commit 2e1da15

Please sign in to comment.