mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-23 02:52:10 +10:00
simplify impoft_from_grid for hybrid
* export_power_hybrid gets negative once power is imported from the grid. So no calculation is needed. Basically simplifies the code a bit.
This commit is contained in:
+10
-11
@@ -325,10 +325,11 @@ class SungrowInverter():
|
|||||||
|
|
||||||
# Create a registers for Power imported and exported to/from Grid
|
# Create a registers for Power imported and exported to/from Grid
|
||||||
if self.inverter_config['level'] >= 1:
|
if self.inverter_config['level'] >= 1:
|
||||||
|
self.latest_scrape["export_to_grid"] = 0
|
||||||
|
self.latest_scrape["import_from_grid"] = 0
|
||||||
|
|
||||||
if self.validateRegister('meter_power'):
|
if self.validateRegister('meter_power'):
|
||||||
try:
|
try:
|
||||||
self.latest_scrape["export_to_grid"] = 0
|
|
||||||
self.latest_scrape["import_from_grid"] = 0
|
|
||||||
power = self.latest_scrape.get('meter_power', self.latest_scrape.get('export_power', 0))
|
power = self.latest_scrape.get('meter_power', self.latest_scrape.get('export_power', 0))
|
||||||
if power < 0:
|
if power < 0:
|
||||||
self.latest_scrape["export_to_grid"] = abs(power)
|
self.latest_scrape["export_to_grid"] = abs(power)
|
||||||
@@ -336,17 +337,15 @@ class SungrowInverter():
|
|||||||
self.latest_scrape["import_from_grid"] = power
|
self.latest_scrape["import_from_grid"] = power
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
# in this case we connected to a hybrid inverter and need to calculate the import differently
|
# in this case we connected to a hybrid inverter and need to use export_power_hybrid
|
||||||
|
# export_power_hybrid is negative in case of importing from the grid
|
||||||
elif self.validateRegister('export_power_hybrid'):
|
elif self.validateRegister('export_power_hybrid'):
|
||||||
try:
|
try:
|
||||||
self.latest_scrape['export_to_grid'] = self.latest_scrape.get('export_power_hybrid', 0)
|
power = self.latest_scrape.get('export_power_hybrid', 0)
|
||||||
self.latest_scrape['import_from_grid'] = 0
|
if power < 0:
|
||||||
|
self.latest_scrape["import_from_grid"] = abs(power)
|
||||||
# take AC output of the inverter into account as could have a battery attached.
|
elif power >= 0:
|
||||||
# once the load is higher then the AC output, we import energy from the grid
|
self.latest_scrape["export_to_grid"] = power
|
||||||
power = self.latest_scrape.get('load_power_hybrid') - self.latest_scrape('total_active_power')
|
|
||||||
if power > 0:
|
|
||||||
self.latest_scrape['import_from_grid'] = power
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user