From 99a7163b5ffe6c2a0b332b0d9ccbef00d2d58f6a Mon Sep 17 00:00:00 2001 From: Oliver Gregorius <98558972+olivergregorius@users.noreply.github.com> Date: Tue, 26 Nov 2024 21:13:22 +0000 Subject: [PATCH] #38: Reverted to slave=0, avoid propagating log messages to root logger --- README.md | 16 ++++++++-------- pyproject.toml | 2 +- sun2000_modbus/inverter.py | 3 ++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ea0398f..b32a774 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ to the device's internal Wifi access point. For information about how to connect ## Requirements -- Python >= 3.10 +- Python >= 3.9 ## Usage @@ -36,13 +36,13 @@ The above code snippet prints out the current input power value, e.g. `8.342 kW` During instantiation of a Sun2000 object the following parameters are accepted: -| Parameter | Description | -|-----------|---------------------------------------------------------------------------------------------| -| host | IP address | -| port | Port, usually 502, changed to 6607 on newer firmware versions. | -| timeout | Connection timeout | -| wait | Time to wait after connection before a register read can be performed. Increases stability. | -| slave | Number of inverter unit to be read, used in cascading scenarios. | +| Parameter | Description | +|-----------|-------------------------------------------------------------------------------------------------------------------------------------| +| host | IP address | +| port | Port, usually 502, changed to 6607 on newer firmware versions. | +| timeout | Connection timeout | +| wait | Time to wait after connection before a register read can be performed. Increases stability. | +| slave | Number of inverter unit to be read, used in cascading scenarios. Defaults to 0, but some devices need it to be set to other values. | ### Read metrics diff --git a/pyproject.toml b/pyproject.toml index 05e6926..d496a36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", ] dynamic = ["version", "description"] -requires-python = ">=3.10" +requires-python = ">=3.9" keywords = ["sun2000", "modbus", "photovoltaic"] dependencies = [ "pymodbus==3.7.4", diff --git a/sun2000_modbus/inverter.py b/sun2000_modbus/inverter.py index 12b7dcc..5a59ffe 100644 --- a/sun2000_modbus/inverter.py +++ b/sun2000_modbus/inverter.py @@ -12,10 +12,11 @@ handler = logging.StreamHandler() handler.setFormatter(log_format) logger.addHandler(handler) +logger.propagate = False class Sun2000: - def __init__(self, host, port=502, timeout=5, wait=2, slave=1): + def __init__(self, host, port=502, timeout=5, wait=2, slave=0): # some models need slave=1 self.wait = wait self.slave = slave self.inverter = ModbusTcpClient(host=host, port=port, timeout=timeout)