Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy of export_power and load_power registers for hybrid inverter #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions SunGather/registers-sungrow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1216,18 +1216,31 @@ registers:
accuracy: 0.1
unit: "kWh"
models: ["SH5K-20","SH3K6","SH4K6","SH5K-V13","SH5K-30","SH3K6-30","SH4K6-30","SH5.0RS","SH3.6RS","SH4.6RS","SH6.0RS","SH10RT","SH8.0RT","SH6.0RT","SH5.0RT"]
- name: "load_power_hybrid"
- name: "load_power"
level: 1
address: 13008
datatype: "S32"
unit: "W"
models: ["SH5K-20","SH3K6","SH4K6","SH5K-V13","SH5K-30","SH3K6-30","SH4K6-30","SH5.0RS","SH3.6RS","SH4.6RS","SH6.0RS","SH10RT","SH8.0RT","SH6.0RT","SH5.0RT"]
- name: "export_power_hybrid"
models: ["SH5K-20","SH3K6","SH4K6","SH5K-V13","SH5K-30","SH3K6-30","SH4K6-30","SH5.0RS","SH3.6RS","SH4.6RS","SH6.0RS","SH10RT","SH8.0RT","SH6.0RT","SH5.0RT"]
- name: "load_power_hybrid"
level: 1
address: 13008
datatype: "S32"
unit: "W"
models: ["SH5K-20","SH3K6","SH4K6","SH5K-V13","SH5K-30","SH3K6-30","SH4K6-30","SH5.0RS","SH3.6RS","SH4.6RS","SH6.0RS","SH10RT","SH8.0RT","SH6.0RT","SH5.0RT"]
- name: "export_power_hybrid"
level: 1
address: 13010
datatype: "S32"
unit: "W"
models: ["SH5K-20","SH3K6","SH4K6","SH5K-V13","SH5K-30","SH3K6-30","SH4K6-30","SH5.0RS","SH3.6RS","SH4.6RS","SH6.0RS","SH10RT","SH8.0RT","SH6.0RT","SH5.0RT"]
- name: "export_power"
level: 1
address: 13010
datatype: "S32"
accuracy: -1
unit: "W"
models: ["SH5K-20","SH3K6","SH4K6","SH5K-V13","SH5K-30","SH3K6-30","SH4K6-30","SH5.0RS","SH3.6RS","SH4.6RS","SH6.0RS","SH10RT","SH8.0RT","SH6.0RT","SH5.0RT"]
- name: "daily_battery_charge_from_pv"
level: 1
address: 13012
Expand Down
38 changes: 10 additions & 28 deletions SunGather/sungather.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,37 +323,19 @@ def scrape(self):
# Leave connection open, see if helps resolve the connection issues
#self.close()

# Create a registers for Power imported and exported to/from Grid
# Create registers for Power imported and exported to/from Grid
power = 0
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'):
try:
power = self.latest_scrape.get('meter_power', self.latest_scrape.get('export_power', 0))
if power < 0:
self.latest_scrape["export_to_grid"] = abs(power)
elif power >= 0:
self.latest_scrape["import_from_grid"] = power
except Exception:
pass
# 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'):
try:
power = self.latest_scrape.get('export_power_hybrid', 0)
if power < 0:
self.latest_scrape["import_from_grid"] = abs(power)
elif power >= 0:
self.latest_scrape["export_to_grid"] = power
except Exception:
pass

try: # If inverter is returning no data for load_power, we can calculate it manually
if not self.latest_scrape["load_power"]:
self.latest_scrape["load_power"] = int(self.latest_scrape.get('total_active_power')) + int(self.latest_scrape.get('meter_power'))
except Exception:
pass
power = self.latest_scrape.get('meter_power', self.latest_scrape.get('export_power', 0))
if power < 0:
self.latest_scrape["export_to_grid"] = abs(power)
elif power >= 0:
self.latest_scrape["import_from_grid"] = power
# If inverter is returning no data for load_power, we can calculate it manually
if not self.latest_scrape.get("load_power"):
self.latest_scrape["load_power"] = self.latest_scrape.get('total_active_power', 0) + power

# See if the inverter is running, This is added to inverters so can be read via MQTT etc...
# It is also used below, as some registers hold the last value on 'stop' so we need to set to 0
Expand Down