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

Add check for piko7.0 which only have 2 strings #1

Merged
merged 1 commit into from
Jan 17, 2019
Merged
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
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