Skip to content
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
4 changes: 1 addition & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ jobs:
run: isort ./ --check
- name: Run black
run: black ./ --check
- name: Run pyright
run: pyright
- name: Run test install
run: pip install .
run: pip install .
6 changes: 5 additions & 1 deletion e3dc/_e3dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(self, connectType: int, **kwargs: Any) -> None:
serialNumber (str): the serial number of the system to monitor - required for CONNECT_WEB
isPasswordMd5 (bool): indicates whether the password is already md5 digest (recommended, default = True) - required for CONNECT_WEB
configuration (Optional[dict]): dict containing details of the E3DC configuration. {"pvis": [{"index": 0, "strings": 2, "phases": 3}], "powermeters": [{"index": 0}], "batteries": [{"index": 0, "dcbs": 1}]}
port (int, optional): port number for local connection. Defaults to None, which means default port 5033 is used.
"""
self.connectType = connectType
self.username = kwargs["username"]
Expand Down Expand Up @@ -123,7 +124,10 @@ def __init__(self, connectType: int, **kwargs: Any) -> None:
self.ip = kwargs["ipAddress"]
self.key = kwargs["key"]
self.password = kwargs["password"]
self.rscp = E3DC_RSCP_local(self.username, self.password, self.ip, self.key)
self.port = kwargs.get("port", None)
self.rscp = E3DC_RSCP_local(
self.username, self.password, self.ip, self.key, self.port
)
else:
self._set_serial(kwargs["serialNumber"])
if "isPasswordMd5" in kwargs and not kwargs["isPasswordMd5"]:
Expand Down
8 changes: 6 additions & 2 deletions e3dc/_e3dc_rscp_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,22 @@ class CommunicationError(Exception):
class E3DC_RSCP_local:
"""A class describing an E3DC system connection using RSCP protocol locally."""

def __init__(self, username: str, password: str, ip: str, key: str):
def __init__(
self, username: str, password: str, ip: str, key: str, port: int | None = PORT
):
"""Constructor of an E3DC RSCP local object.

Args:
username (str): username
password (str): password (plain text)
ip (str): IP address of the E3DC system
key (str): encryption key as set in the E3DC settings
port (int, optional): port number. Defaults to PORT.
"""
self.username = username.encode("utf-8")
self.password = password.encode("utf-8")
self.ip = ip
self.port = port if port else PORT
self.key = key.encode("utf-8")
self.socket: socket.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.connected: bool = False
Expand Down Expand Up @@ -122,7 +126,7 @@ def connect(self) -> None:
try:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.settimeout(5)
self.socket.connect((self.ip, PORT))
self.socket.connect((self.ip, self.port))
self.processedData = None
self.connected = True
except Exception:
Expand Down