From 1532703ff48fe4f87ceb32adf66a160121e332f2 Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 09:32:47 +0200 Subject: [PATCH 01/32] add logging capability --- bin/kamstrup.py | 19 +++++++++++++++++++ bin/libkamstrup.py | 9 ++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/bin/kamstrup.py b/bin/kamstrup.py index 71c15dd..85baca2 100755 --- a/bin/kamstrup.py +++ b/bin/kamstrup.py @@ -6,8 +6,11 @@ """ import argparse +import logging +import logging.handlers import os import shutil +import sys import syslog import time import traceback @@ -19,6 +22,18 @@ import libkamstrup as kl import GracefulKiller as gk +logging.basicConfig( + level=logging.INFO, + format="%(module)s.%(funcName)s [%(levelname)s] - %(message)s", + datefmt="%Y-%m-%d %H:%M:%S", + handlers=[ + logging.handlers.SysLogHandler( + address="/dev/log", facility=logging.handlers.SysLogHandler.LOG_DAEMON + ) + ], +) +LOGGER: logging.Logger = logging.getLogger(__name__) + # fmt: off parser = argparse.ArgumentParser(description="Execute the kamstrup daemon.") parser_group = parser.add_mutually_exclusive_group(required=True) @@ -143,6 +158,10 @@ def set_led(dev, colour): if OPTION.debug: DEBUG = True print(OPTION) + if len(LOGGER.handlers) == 0: + LOGGER.addHandler(logging.StreamHandler(sys.stdout)) + LOGGER.level = logging.DEBUG + LOGGER.debug("Debugging on.") mf.syslog_trace("Debug-mode started.", syslog.LOG_DEBUG, DEBUG) print("Use +C to stop.") diff --git a/bin/libkamstrup.py b/bin/libkamstrup.py index a27e7c2..eb9d5d7 100755 --- a/bin/libkamstrup.py +++ b/bin/libkamstrup.py @@ -3,7 +3,9 @@ """Common functions for use with the KAMSTRUP electricity meter""" import datetime as dt +import logging import re +import sys import syslog import traceback @@ -14,6 +16,7 @@ import constants +LOGGER: logging.Logger = logging.getLogger(__name__) class Kamstrup: # pylint: disable=too-many-instance-attributes """Class to interact with the P1-port.""" @@ -46,7 +49,11 @@ def __init__(self, debug=False): # pylint: disable=too-many-instance-attributes self.list_data = [] self.debug = debug - if self.debug: + if debug: + if len(LOGGER.handlers) == 0: + LOGGER.addHandler(logging.StreamHandler(sys.stdout)) + LOGGER.level = logging.DEBUG + LOGGER.debug("Debugging on.") self.telegram = [] def get_telegram(self): From fc44307a68bfc0f0d797b57aa88e2cbde4ce626f Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 09:43:59 +0200 Subject: [PATCH 02/32] implement logger --- bin/kamstrup.py | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/bin/kamstrup.py b/bin/kamstrup.py index 85baca2..fdd0ff0 100755 --- a/bin/kamstrup.py +++ b/bin/kamstrup.py @@ -85,47 +85,41 @@ def main(): set_led("mains", "green") except Exception: # noqa set_led("mains", "red") - mf.syslog_trace( - "Unexpected error while trying to do some work!", - syslog.LOG_CRIT, - DEBUG, + LOGGER.critical( + "Unexpected error while trying to do some work!" ) - mf.syslog_trace(traceback.format_exc(), syslog.LOG_DEBUG, DEBUG) + LOGGER.error(traceback.format_exc()) raise if not succes: set_led("mains", "orange") - mf.syslog_trace("Getting telegram failed", syslog.LOG_WARNING, DEBUG) + LOGGER.warning("Getting telegram failed") # check if we already need to report the result data if time.time() > rprt_time: - mf.syslog_trace("Reporting", False, DEBUG) - mf.syslog_trace(f"Result : {API_KL.list_data}", False, DEBUG) + LOGGER.debug("Reporting") + LOGGER.debug(f"Result : {API_KL.list_data}") # resample to 15m entries data, API_KL.list_data = API_KL.compact_data(API_KL.list_data) - mf.syslog_trace(f"Remainder: {API_KL.list_data}", False, DEBUG) + LOGGER.debug(f"Remainder: {API_KL.list_data}") try: - mf.syslog_trace(f"Data to add (first) : {data[0]}", False, DEBUG) - mf.syslog_trace(f" (last) : {data[-1]}", False, DEBUG) + LOGGER.debug(f"Data to add (first) : {data[0]}") + LOGGER.debug(f" (last) : {data[-1]}") for element in data: sql_db.queue(element) except Exception: # noqa set_led("mains", "red") - mf.syslog_trace( - "Unexpected error while trying to queue the data", - syslog.LOG_ALERT, - DEBUG, + LOGGER.critical( + "Unexpected error while trying to queue the data" ) - mf.syslog_trace(traceback.format_exc(), syslog.LOG_ALERT, DEBUG) + LOGGER.error(traceback.format_exc()) raise # may be changed to pass if errors can be corrected. try: sql_db.insert(method="replace") except Exception: # noqa set_led("mains", "red") - mf.syslog_trace( - "Unexpected error while trying to commit the data to the database", - syslog.LOG_ALERT, - DEBUG, + LOGGER.critical( + "Unexpected error while trying to commit the data to the database" ) - mf.syslog_trace(traceback.format_exc(), syslog.LOG_ALERT, DEBUG) + LOGGER.error(traceback.format_exc()) raise # may be changed to pass if errors can be corrected. # electricity meter determines the tempo, so no need to wait. @@ -136,15 +130,15 @@ def main(): ) # gives the actual time when the next loop should start # determine moment of next report rprt_time = time.time() + (report_interval - (time.time() % report_interval)) - mf.syslog_trace(f"Spent {time.time() - start_time:.1f}s getting data", False, DEBUG) - mf.syslog_trace(f"Report in {rprt_time - time.time():.0f}s", False, DEBUG) - mf.syslog_trace("................................", False, DEBUG) + LOGGER.debug(f"Spent {time.time() - start_time:.1f}s getting data") + LOGGER.debug(f"Report in {rprt_time - time.time():.0f}s") + LOGGER.debug("................................") else: time.sleep(1.0) # 1s resolution is enough def set_led(dev, colour): - mf.syslog_trace(f"{dev} is {colour}", False, DEBUG) + LOGGER.debug(f"{dev} is {colour}") in_dirfile = f"{APPROOT}/www/{colour}.png" out_dirfile = f'{constants.TREND["website"]}/{dev}.png' @@ -162,7 +156,7 @@ def set_led(dev, colour): LOGGER.addHandler(logging.StreamHandler(sys.stdout)) LOGGER.level = logging.DEBUG LOGGER.debug("Debugging on.") - mf.syslog_trace("Debug-mode started.", syslog.LOG_DEBUG, DEBUG) + LOGGER.debug("Debug-mode started.") print("Use +C to stop.") # OPTION.start only executes this next line, we don't need to test for it. From 0d8241be85e5bdb8299507fc10f546b07fcb7d9a Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 09:48:17 +0200 Subject: [PATCH 03/32] implement logger --- bin/libkamstrup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/libkamstrup.py b/bin/libkamstrup.py index eb9d5d7..cf42389 100755 --- a/bin/libkamstrup.py +++ b/bin/libkamstrup.py @@ -165,6 +165,7 @@ def _translate_telegram(self, telegram): mf.syslog_trace(f" {element}", syslog.LOG_INFO, self.debug) mf.syslog_trace("*** Extracted from telegram:", syslog.LOG_INFO, self.debug) mf.syslog_trace(f" {telegram}", syslog.LOG_INFO, self.debug) + LOGGER.debug(f" {telegram}") idx_dt = dt.datetime.now() epoch = int(idx_dt.timestamp()) @@ -213,7 +214,7 @@ def _convert_time_to_text(date_to_convert): # recalculate 'sample_epoch' df_out["sample_epoch"] = df_out["sample_time"].apply(_convert_time_to_epoch) - mf.syslog_trace(f"{df_out}", False, self.debug) + LOGGER.info(f"{df_out}", False, self.debug) result_data = df_out.to_dict("records") # list of dicts df = df[df["sample_epoch"] > np.max(df_out["sample_epoch"])] # pylint: disable=E1136 From 61d4cde6e89d991d62f61e35a74729fecd96f0da Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:02:17 +0200 Subject: [PATCH 04/32] implement logger --- bin/libkamstrup.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/bin/libkamstrup.py b/bin/libkamstrup.py index cf42389..fdf9ff5 100755 --- a/bin/libkamstrup.py +++ b/bin/libkamstrup.py @@ -83,13 +83,13 @@ def get_telegram(self): # remember meaningful content telegram.append(line) except serial.SerialException: - mf.syslog_trace("*** Serialport read error:", syslog.LOG_CRIT, self.debug) - mf.syslog_trace(traceback.format_exc(), syslog.LOG_CRIT, self.debug) + LOGGER.critical("*** Serialport read error:") + LOGGER.error(traceback.format_exc()) valid_telegram = False receiving = False except UnicodeDecodeError: - mf.syslog_trace("*** Unicode Decode error:", syslog.LOG_CRIT, self.debug) - mf.syslog_trace(traceback.format_exc(), syslog.LOG_CRIT, self.debug) + LOGGER.critical("*** Unicode Decode error:") + LOGGER.error(traceback.format_exc()) valid_telegram = False receiving = False @@ -156,16 +156,12 @@ def _translate_telegram(self, telegram): # ['0-0:96.13.0', '', ''] text message # not recorded except ValueError: - if self.debug: - mf.syslog_trace( - "*** Conversion not possible for element:", - syslog.LOG_INFO, - self.debug, - ) - mf.syslog_trace(f" {element}", syslog.LOG_INFO, self.debug) - mf.syslog_trace("*** Extracted from telegram:", syslog.LOG_INFO, self.debug) - mf.syslog_trace(f" {telegram}", syslog.LOG_INFO, self.debug) - LOGGER.debug(f" {telegram}") + LOGGER.critical( + "*** Conversion not possible for element:" + ) + LOGGER.error(f" {element}") + LOGGER.error("*** Extracted from telegram:") + LOGGER.error(f" {telegram}") idx_dt = dt.datetime.now() epoch = int(idx_dt.timestamp()) From 89cebffad7c30c8638aae1892f733ce932bc8630 Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:05:07 +0200 Subject: [PATCH 05/32] additional debugging --- bin/libkamstrup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/libkamstrup.py b/bin/libkamstrup.py index fdf9ff5..7c0f90a 100755 --- a/bin/libkamstrup.py +++ b/bin/libkamstrup.py @@ -119,6 +119,7 @@ def _translate_telegram(self, telegram): Returns: (dict): data converted to a dict. """ + LOGGER.debug(f" {telegram}") for element in telegram: try: line = re.split(r"[\(\*\)]", element) @@ -215,4 +216,6 @@ def _convert_time_to_text(date_to_convert): df = df[df["sample_epoch"] > np.max(df_out["sample_epoch"])] # pylint: disable=E1136 remain_data = df.to_dict("records") + LOGGER.debug(f"Result: {result_data}") + LOGGER.debug(f"Remain: {remain_data}\n") return result_data, remain_data From 2d27b06abcda109b1a685e62ed062623f05338be Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:07:00 +0200 Subject: [PATCH 06/32] debug --- bin/libkamstrup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/libkamstrup.py b/bin/libkamstrup.py index 7c0f90a..1d00833 100755 --- a/bin/libkamstrup.py +++ b/bin/libkamstrup.py @@ -211,7 +211,7 @@ def _convert_time_to_text(date_to_convert): # recalculate 'sample_epoch' df_out["sample_epoch"] = df_out["sample_time"].apply(_convert_time_to_epoch) - LOGGER.info(f"{df_out}", False, self.debug) + LOGGER.info(f"{df_out}") result_data = df_out.to_dict("records") # list of dicts df = df[df["sample_epoch"] > np.max(df_out["sample_epoch"])] # pylint: disable=E1136 From cd868afa9c64ce51032470c3e11fa658c02e14fd Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:10:56 +0200 Subject: [PATCH 07/32] additional logging --- bin/kamstrup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/kamstrup.py b/bin/kamstrup.py index fdd0ff0..e8b9b4a 100755 --- a/bin/kamstrup.py +++ b/bin/kamstrup.py @@ -101,9 +101,8 @@ def main(): data, API_KL.list_data = API_KL.compact_data(API_KL.list_data) LOGGER.debug(f"Remainder: {API_KL.list_data}") try: - LOGGER.debug(f"Data to add (first) : {data[0]}") - LOGGER.debug(f" (last) : {data[-1]}") for element in data: + LOGGER.debug(f" : {element}") sql_db.queue(element) except Exception: # noqa set_led("mains", "red") From 28fbb2fc3a83c63a547dc79ac63d43a8e9c0de3d Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:11:56 +0200 Subject: [PATCH 08/32] and one more --- bin/kamstrup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/kamstrup.py b/bin/kamstrup.py index e8b9b4a..3ece215 100755 --- a/bin/kamstrup.py +++ b/bin/kamstrup.py @@ -161,4 +161,4 @@ def set_led(dev, colour): # OPTION.start only executes this next line, we don't need to test for it. main() - print("And it's goodnight from him") + LOGGER.debug("And it's goodnight from him") From f4173eaf1e2e22ee4314a5dd2714fd5493cf897b Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:18:42 +0200 Subject: [PATCH 09/32] update logging --- bin/kamstrup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/kamstrup.py b/bin/kamstrup.py index 3ece215..6b69beb 100755 --- a/bin/kamstrup.py +++ b/bin/kamstrup.py @@ -99,10 +99,9 @@ def main(): LOGGER.debug(f"Result : {API_KL.list_data}") # resample to 15m entries data, API_KL.list_data = API_KL.compact_data(API_KL.list_data) - LOGGER.debug(f"Remainder: {API_KL.list_data}") try: for element in data: - LOGGER.debug(f" : {element}") + # LOGGER.debug(f"{element}") # is already logged by sql_db.queue() sql_db.queue(element) except Exception: # noqa set_led("mains", "red") From cb6d384f3093321bc96b5b4afda54df4c2602a41 Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:41:07 +0200 Subject: [PATCH 10/32] one too many --- bin/libkamstrup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/libkamstrup.py b/bin/libkamstrup.py index 1d00833..6167123 100755 --- a/bin/libkamstrup.py +++ b/bin/libkamstrup.py @@ -211,7 +211,6 @@ def _convert_time_to_text(date_to_convert): # recalculate 'sample_epoch' df_out["sample_epoch"] = df_out["sample_time"].apply(_convert_time_to_epoch) - LOGGER.info(f"{df_out}") result_data = df_out.to_dict("records") # list of dicts df = df[df["sample_epoch"] > np.max(df_out["sample_epoch"])] # pylint: disable=E1136 From 58d9eae49d65c425b0dd57aad914a3da4fc37c86 Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:47:24 +0200 Subject: [PATCH 11/32] add pre-commit hook for black --- .pre-commit-config.yaml | 4 ++++ environment.yml | 1 + 2 files changed, 5 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..643b5b6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,4 @@ +- repo: https://github.com/pre-commit/mirrors-black + rev: stable + hooks: + - id: black diff --git a/environment.yml b/environment.yml index 0274c8a..e00e905 100644 --- a/environment.yml +++ b/environment.yml @@ -14,6 +14,7 @@ dependencies: - pandas # - pandas-stubs - pip + - pre-commit - pyarrow # This won't install on anything other than Linux (notably Raspberry Pi): # - pyserial=3.5 From 74b4606cb9148c42955adc09e02722e1f4e4d23d Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:49:16 +0200 Subject: [PATCH 12/32] test --- bin/kamstrup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/kamstrup.py b/bin/kamstrup.py index 6b69beb..bf6d56c 100755 --- a/bin/kamstrup.py +++ b/bin/kamstrup.py @@ -123,9 +123,7 @@ def main(): # electricity meter determines the tempo, so no need to wait. pause_interval = 0.0 # faux variable - next_time = ( - pause_interval + time.time() - ) # gives the actual time when the next loop should start + next_time = (pause_interval + time.time()) # gives the actual time when the next loop should start # determine moment of next report rprt_time = time.time() + (report_interval - (time.time() % report_interval)) LOGGER.debug(f"Spent {time.time() - start_time:.1f}s getting data") From 6b7e685f86d0ab6c8d59b423fd2e494db9aee248 Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 10:57:27 +0200 Subject: [PATCH 13/32] pre-commit update --- .pre-commit-config.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 643b5b6..a558189 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,12 @@ -- repo: https://github.com/pre-commit/mirrors-black - rev: stable + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/psf/black + rev: 22.10.0 hooks: - id: black From 51f503b2993fa1ffd2aee131f50040f41efc74ed Mon Sep 17 00:00:00 2001 From: "Maurice (mausy5043) Hendrix" Date: Sun, 28 Jul 2024 11:00:03 +0200 Subject: [PATCH 14/32] formatting update --- .github/dependabot.yml | 1 - README.md | 6 +++--- bin/kamstrup.py | 16 +++++++------- bin/libkamstrup.py | 9 ++++---- docs/HARVI.md | 2 +- docs/ZAPPI.md | 18 ++++++++-------- docs/trends.md | 48 +++++++++++++++++++++--------------------- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7528e09..91abb11 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,4 +9,3 @@ updates: directory: "/" # Location of package manifests schedule: interval: "weekly" - \ No newline at end of file diff --git a/README.md b/README.md index b61a1ad..a65bec1 100644 --- a/README.md +++ b/README.md @@ -18,15 +18,15 @@ and [ZAPPI v2](https://myenergi.com/) API using Raspberry Pi ### Installing -Clone the repository somewhere handy. Adding the `lektrix` directory to your `$PATH` may help. -To install run `lektrix --install`. +Clone the repository somewhere handy. Adding the `lektrix` directory to your `$PATH` may help. +To install run `lektrix --install`. Use `lektrix --uninstall` to uninstall. ### Usage `lektrix ` -`--hours HOURS`, `--days DAYS`, `--months MONTHS`, `--years YEARS` +`--hours HOURS`, `--days DAYS`, `--months MONTHS`, `--years YEARS` Create a bar graph of the given number of HOURS/DAYS/MONTHS/YEARS `--balance`, `--balances` diff --git a/bin/kamstrup.py b/bin/kamstrup.py index bf6d56c..7d05ff5 100755 --- a/bin/kamstrup.py +++ b/bin/kamstrup.py @@ -85,9 +85,7 @@ def main(): set_led("mains", "green") except Exception: # noqa set_led("mains", "red") - LOGGER.critical( - "Unexpected error while trying to do some work!" - ) + LOGGER.critical("Unexpected error while trying to do some work!") LOGGER.error(traceback.format_exc()) raise if not succes: @@ -105,9 +103,7 @@ def main(): sql_db.queue(element) except Exception: # noqa set_led("mains", "red") - LOGGER.critical( - "Unexpected error while trying to queue the data" - ) + LOGGER.critical("Unexpected error while trying to queue the data") LOGGER.error(traceback.format_exc()) raise # may be changed to pass if errors can be corrected. try: @@ -123,9 +119,13 @@ def main(): # electricity meter determines the tempo, so no need to wait. pause_interval = 0.0 # faux variable - next_time = (pause_interval + time.time()) # gives the actual time when the next loop should start + next_time = ( + pause_interval + time.time() + ) # gives the actual time when the next loop should start # determine moment of next report - rprt_time = time.time() + (report_interval - (time.time() % report_interval)) + rprt_time = time.time() + ( + report_interval - (time.time() % report_interval) + ) LOGGER.debug(f"Spent {time.time() - start_time:.1f}s getting data") LOGGER.debug(f"Report in {rprt_time - time.time():.0f}s") LOGGER.debug("................................") diff --git a/bin/libkamstrup.py b/bin/libkamstrup.py index 6167123..5b64f8c 100755 --- a/bin/libkamstrup.py +++ b/bin/libkamstrup.py @@ -18,6 +18,7 @@ LOGGER: logging.Logger = logging.getLogger(__name__) + class Kamstrup: # pylint: disable=too-many-instance-attributes """Class to interact with the P1-port.""" @@ -157,9 +158,7 @@ def _translate_telegram(self, telegram): # ['0-0:96.13.0', '', ''] text message # not recorded except ValueError: - LOGGER.critical( - "*** Conversion not possible for element:" - ) + LOGGER.critical("*** Conversion not possible for element:") LOGGER.error(f" {element}") LOGGER.error("*** Extracted from telegram:") LOGGER.error(f" {telegram}") @@ -213,7 +212,9 @@ def _convert_time_to_text(date_to_convert): df_out["sample_epoch"] = df_out["sample_time"].apply(_convert_time_to_epoch) result_data = df_out.to_dict("records") # list of dicts - df = df[df["sample_epoch"] > np.max(df_out["sample_epoch"])] # pylint: disable=E1136 + df = df[ + df["sample_epoch"] > np.max(df_out["sample_epoch"]) + ] # pylint: disable=E1136 remain_data = df.to_dict("records") LOGGER.debug(f"Result: {result_data}") LOGGER.debug(f"Remain: {remain_data}\n") diff --git a/docs/HARVI.md b/docs/HARVI.md index 713ff3e..98a4d5b 100644 --- a/docs/HARVI.md +++ b/docs/HARVI.md @@ -1,7 +1,7 @@ # HARVI ## Payload cgi-jstatus-H... -Call: `https://s__.myenergi.net/cgi-jstatus-H########` +Call: `https://s__.myenergi.net/cgi-jstatus-H########` Where: * `s__` is the server-id diff --git a/docs/ZAPPI.md b/docs/ZAPPI.md index 29908e0..aeb1fd0 100644 --- a/docs/ZAPPI.md +++ b/docs/ZAPPI.md @@ -49,7 +49,7 @@ // C1 = EV ready to receive charge // C2 = Charging // F = Fault - 'pwm': 4100, // Pulse Width Modulation [% * 100] + 'pwm': 4100, // Pulse Width Modulation [% * 100] // percentage of 60A that can be delivered // 4100 = 24.6 A 'rac': 4, // Residual AC @@ -93,7 +93,7 @@ Note: Energy is in Joules; divide by 60 get average Watts; divide by 3 600 000 t 'exp': 16560, // Exported period total [J] 'frq': 5006, // Line frequency [centiHertz] 'gen': 480 // Energy consumed by inverter (usually at night) [J] - 'gep': 2409600, // Energy production (solar panels) period total [J] + 'gep': 2409600, // Energy production (solar panels) period total [J] 'h1b': 123, // Imported energy used for EV period total [J] 'h1d': 14706420, // Produced energy diverted to EV (?) period total [J] 'hr': 6, // Hour of the Day (UTC!) (if applicable and non-zero) @@ -107,11 +107,11 @@ Note: Energy is in Joules; divide by 60 get average Watts; divide by 3 600 000 t truncated ``` -`gep` should match hourly PV totaliser -`imp` imported from grid; should match hourly P1 totaliser (T1,in + T2,in; KAMSTRUP) -`exp` exported to grid; should match hourly P1 totaliser (T1,out + T2,out; KAMSTRUP) +`gep` should match hourly PV totaliser +`imp` imported from grid; should match hourly P1 totaliser (T1,in + T2,in; KAMSTRUP) +`exp` exported to grid; should match hourly P1 totaliser (T1,out + T2,out; KAMSTRUP) `h1d` should match EV consumption -`h1b`: device 1 boost -`h1d`: device 1 divert -`h2b`: device 2 boost -`h2d`: device 2 divert +`h1b`: device 1 boost +`h1d`: device 1 divert +`h2b`: device 2 boost +`h2d`: device 2 divert diff --git a/docs/trends.md b/docs/trends.md index c4118e2..962cc9f 100644 --- a/docs/trends.md +++ b/docs/trends.md @@ -11,49 +11,49 @@ `--hours HOURS` : Create a bar graph of electricity usage per hour for the given number of hours. Example: -`lektrix/bin/lg-trend.py --hours 84` +`lektrix/bin/lg-trend.py --hours 84` ![alt](lex_pasthours_mains.lg.png) -Two different modifiers are possible: -`--balance` +Two different modifiers are possible: +`--balance` ![alt](lex_pasthours_mains_balance.png) -`--balances` +`--balances` ![alt](lex_pasthours_mains_balances.png) -`lektrix/bin/lg-trend.py --days 84` +`lektrix/bin/lg-trend.py --days 84` ![alt](lex_pastdays_mains.lg.png) - -`--balance` + +`--balance` ![alt](lex_pastdays_mains_balance.png) -`--balances` +`--balances` ![alt](lex_pastdays_mains_balances.png) -`lektrix/bin/lg-trend.py --months 36` +`lektrix/bin/lg-trend.py --months 36` ![alt](lex_pastmonths_mains.lg.png) -`--balance` +`--balance` ![alt](lex_pastmonths_mains_balance.png) `--balances` ![alt](lex_pastmonths_mains_balances.png) ### Balancing -Balancing is a mathematical excercise that is meant +Balancing is a mathematical excercise that is meant to study the effect of energy storage. -`--balances` shows what would happen if all the -energy that is exported in the unbalanced case could -be used optimally. So, the (red) imported energy is first +`--balances` shows what would happen if all the +energy that is exported in the unbalanced case could +be used optimally. So, the (red) imported energy is first canceled out by any (blue) exported energy before -creating the graph; effectively maximising the (green) +creating the graph; effectively maximising the (green) own usage part. -`--balance` does the same as the `--balances` option, -however now the T1 and T2 counters are strictly kept -separate. +`--balance` does the same as the `--balances` option, +however now the T1 and T2 counters are strictly kept +separate. So, energy exported during the peak hours is only canceled out against the energy imported during those same peak hours. @@ -64,13 +64,13 @@ same peak hours. `ms-trend.py