Skip to content

Commit

Permalink
Merge pull request #1 from britiger/piko_2strings
Browse files Browse the repository at this point in the history
Add check for piko7.0 which only have 2 strings
  • Loading branch information
gieljnssns committed Jan 17, 2019
2 parents 0eb1d6f + f42bfb7 commit fcc3e62
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
30 changes: 26 additions & 4 deletions pikopy/piko.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,21 @@ def get_string2_current(self):

def get_string3_voltage(self):
"""returns the voltage from string 3 in V"""
return int(self._get_raw_content()[11])
raw_content = self._get_raw_content()
if len(raw_content) < 14:
# String 3 not installed
return None
else:
return int(raw_content[11])

def get_string3_current(self):
"""returns the current from string 3 in A"""
return float(self._get_raw_content()[13])
raw_content = self._get_raw_content()
if len(raw_content) < 14:
# String 3 not installed
return None
else:
return float(raw_content[13])

def get_l1_voltage(self):
"""returns the voltage from line 1 in V"""
Expand All @@ -178,11 +188,23 @@ def get_l2_power(self):

def get_l3_voltage(self):
"""returns the voltage from line 3 in V"""
return int(self._get_raw_content()[12])
raw_content = self._get_raw_content()
if len(raw_content) < 14:
# 2 Strings
return int(raw_content[11])
else:
# 3 Strings
return int(raw_content[12])

def get_l3_power(self):
"""returns the power from line 3 in W"""
return int(self._get_raw_content()[14])
raw_content = self._get_raw_content()
if len(raw_content) < 14:
# 2 Strings
return int(raw_content[12])
else:
# 3 Strings
return int(raw_content[14])

def _get_raw_content(self):
"""returns all values as a list"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


setup(name='pikopy',
version='1.0.0',
version='1.1.0',
author='Christian Stade-Schuldt',
author_email='stadeschuldt@gmail.com',
url='https://github.com/Tafkas/KostalPikoPy',
Expand Down

0 comments on commit fcc3e62

Please sign in to comment.