Skip to content

Commit

Permalink
#13: added some debug output and safeguards for unit calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gentleman1983 committed Mar 10, 2024
1 parent e8d671c commit 8268361
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ginlong_solis_api_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ def prettify_json(input_json) -> str:
return json.dumps(json.loads(input_json), indent=2)

def calculate_unit_multiplicator(expected_unit, inverter_unit):
if len(inverter_unit) < 1:
logging.debug("Detected empty inverter unit. Returning multiplicator = 1")
return 1

fb_inv = inverter_unit[1]
fb_exp = expected_unit[1]
multiplicator = calculate_factor(fb_inv) / calculate_factor(fb_exp)
logging.debug("Call for caluculating multiplicator using expected unit '%s' and inverter unit '%s' resulting in multiplicator '%s'.", expected_unit, inverter_unit, multiplicator) # pylint: disable=line-too-long
return multiplicator

def calculate_factor(fb_factor):
Expand Down

0 comments on commit 8268361

Please sign in to comment.