From b94dc8f7cebadff20d40ae09534f368d3f2215a2 Mon Sep 17 00:00:00 2001 From: OFreddy <35624593+OFreddy@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:33:18 +0100 Subject: [PATCH] Specify number of inverters in config.ini (#148) * Specify number of inverters in config.ini Added config parameter to specify amount of computed inverters * Specify number of inverters in config.ini Changed config value name. Updated comments and Readme.md. * Specify number of inverters in config.ini Revised Readme and parameter name * Specify number of inverters in config.ini Footnotes don't seem to work * Specify number of inverters in config.ini Adopted style --- README.md | 5 ++++- config.ini | 5 +++++ dbus-opendtu.py | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c294991..2fefa29 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,8 @@ Within the project there is a file `/data/dbus-opendtu/config.ini`. Most importa |-------------------- | ------------- | | SignOfLifeLog | Time in minutes how often a status is added to the log-file `current.log` with log-level INFO | | NumberOfTemplates | Number ob Template Inverter to query | -| DTU | Which DTU to be used ahoy, opendtu or template REST devices Valid options: opendtu, ahoy, template | +| DTU | Which DTU to be used ahoy, opendtu or template REST devices Valid options: opendtu, ahoy, template | +| NumberOfInvertersToQuery | Number of Inverters to query. Set a value larger than "0" when not all inverters should be considered. *1 | | useYieldDay | send YieldDay instead of YieldTotal. Set this to 1 to prevent VRM from adding the total value to the history on one day. E.g. if you don't start using the inverter at 0. | | ESP8266PollingIntervall | For ESP8266 reduce polling intervall to reduce load, default 10000ms| | Logging | Valid options for log level: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET, to keep logfile small use ERROR or CRITICAL | @@ -100,6 +101,8 @@ Within the project there is a file `/data/dbus-opendtu/config.ini`. Most importa | Username | use if authentication required, leave empty if no authentication needed | | Password | use if authentication required, leave empty if no authentication needed | +*1: Please assure that the order is correct in the DTU, we can only extract the first one in a row. + #### Inverter options This applies to each `INVERTER[X]` section. X is the number of Inverter starting with 0. So the first inverter is INVERTER0, the second INVERTER1 and so on. diff --git a/config.ini b/config.ini index ddf9b51..194061d 100644 --- a/config.ini +++ b/config.ini @@ -8,6 +8,11 @@ NumberOfTemplates=0 # Which DTU to be used ahoy, opendtu, template DTU=opendtu +# If you want to exclude Inverter, specify how many of the Inverters you want to query. +# Please assure that the order is correct in the DTU, we can only extract the first one in a row. +# (0=compute number from json response; > 0 use only first x inverters) +NumberOfInvertersToQuery = 0 + # send YieldDay instead of YieldTotal useYieldDay=0 diff --git a/dbus-opendtu.py b/dbus-opendtu.py index 74dbaf0..dfd361a 100644 --- a/dbus-opendtu.py +++ b/dbus-opendtu.py @@ -33,6 +33,7 @@ def main(): config.read(f"{(os.path.dirname(os.path.realpath(__file__)))}/config.ini") logging_level = config["DEFAULT"]["Logging"].upper() dtuvariant = config["DEFAULT"]["DTU"] + number_of_inverters = int(config["DEFAULT"]["NumberOfInvertersToQuery"]) try: number_of_templates = int(config["DEFAULT"]["NumberOfTemplates"]) @@ -112,7 +113,8 @@ def _v(_p, value: float) -> str: actual_inverter=0, ) - number_of_inverters = service.get_number_of_inverters() + if number_of_inverters == 0: + number_of_inverters = service.get_number_of_inverters() if number_of_inverters > 1: # start our main-service if there are more than 1 inverter