From 7df29a1441c397e196ff8c293c6a444acbc0036b Mon Sep 17 00:00:00 2001 From: Jordan Liss Date: Wed, 11 Dec 2024 00:44:37 -0800 Subject: [PATCH 1/4] Update vedirect.py --- src/vedirect/vedirect.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/vedirect/vedirect.py b/src/vedirect/vedirect.py index 8e360bd..04e3323 100644 --- a/src/vedirect/vedirect.py +++ b/src/vedirect/vedirect.py @@ -244,6 +244,26 @@ def typecast(payload_dict): 'W': ['W', 1, 0] } + mon = { + "Solar charger": -9, + "Wind turbine": -8, + "Shaft generator": -7, + "Alternator" : -6, + "Fuel cell" : -5, + "Water generator" : -4, + "DC/DC charger": -3, + "AC charger": -2, + "Generic source": -1, + "Battery monitor (BMV)": 0, + "Generic load": 1, + "Electric drive" : 2, + "Fridge" : 3 , + "Water pump" : 4, + "Bilge pump" : 5, + "DC system" : 6, + "Inverter" :7 + } + def __init__(self, serialport='', timeout=60, emulate=''): """ Constructor for a Victron VEDirect serial communication session. From 35a95b9f659245eb57e4cf9e6cab871f8b574160 Mon Sep 17 00:00:00 2001 From: Jordan Liss Date: Tue, 7 Jan 2025 23:42:03 -0800 Subject: [PATCH 2/4] Updated to work for smart shunts --- src/vedirect/vedirect.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/vedirect/vedirect.py b/src/vedirect/vedirect.py index 04e3323..e62a14c 100644 --- a/src/vedirect/vedirect.py +++ b/src/vedirect/vedirect.py @@ -9,7 +9,7 @@ import serial import argparse import time -from .vedirect_device_emulator import VEDirectDeviceEmulator +# from .vedirect_device_emulator import VEDirectDeviceEmulator import sys import logging log = logging.getLogger(__name__) @@ -223,13 +223,16 @@ def lookup(key_int, lookup_list): 'ERR': int_base_guess, 'CS': int_base_guess, 'BMV': str, 'FW': str, 'PID': str, 'SER#': str, 'HSDS': int_base_guess, 'MODE': int_base_guess, 'AC_OUT_V': int, 'AC_OUT_I': int, 'AC_OUT_S': int, - 'WARN': int_base_guess, 'MPPT': int_base_guess} + 'WARN': int_base_guess, 'MPPT': int_base_guess, 'MON': int} @staticmethod def typecast(payload_dict): new_dict = {} for key, val in payload_dict.items(): - new_dict[key] = VEDirect.types[key](val) + try: + new_dict[key] = VEDirect.types[key](val) + except Exception as e: + print("Had an error when parsing the VEDirect types. The error was {}".format(e)) return new_dict fmt = { @@ -264,7 +267,7 @@ def typecast(payload_dict): "Inverter" :7 } - def __init__(self, serialport='', timeout=60, emulate=''): + def __init__(self, serialport='/dev/ttyUSB0', timeout=60, emulate=''): """ Constructor for a Victron VEDirect serial communication session. Params: @@ -408,10 +411,11 @@ def main(): parser.add_argument('--loglevel', help='logging level - one of [DEBUG, INFO, WARNING, ERROR, CRITICAL]', default='ERROR') args = parser.parse_args() + args.port = '/dev/ttyUSB0' logging.basicConfig(level=args.loglevel.upper()) - if not args.port and not args.emulate: - print("Must specify a port to listen.") - sys.exit(1) + # if not args.port and not args.emulate: + # print("Must specify a port to listen.") + # sys.exit(1) ve = VEDirect(args.port, args.timeout, args.emulate.upper()) ve.read_data_callback(print_data_callback, args.n) From 002df255d6d6e206998bff88ee226ad989e9aec3 Mon Sep 17 00:00:00 2001 From: Jordan Liss Date: Wed, 8 Jan 2025 09:55:30 -0800 Subject: [PATCH 3/4] Updated the distribution with my info --- README.md | 27 +++++++++++++++++++++++---- distribute | 2 +- pyproject.toml | 6 +++--- setup.cfg | 6 +++--- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 029101f..32db966 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,34 @@ This is a forked version of a package originally created by Janne Kario (https:/ ## Installation To install directly from GitHub: + +``` +$ python3 -m pip install "git+https://github.com/Jordan-seebyte/vedirect-JL" +``` + +[NOT SURE IF THIS STILL WORKS] If you have cloned or forked the repo already to your local directory and want to use it in live (editable mode): +``` +$ python3 -m pip install -e "." +``` + +If you want to build the repo into a whl file, run the following: + +``` +python setup.py bdist_wheel + ``` -$ python3 -m pip install "git+https://github.com/jmfife/vedirect[examples]" + +If you want to build the repo into a tar.gz file, run the following: + +``` +python setup.py sdist + ``` +If you want to install the built library you can by doing the following: -If you have cloned or forked the repo already to your local directory and want to use it in live (editable mode): ``` -$ python3 -m pip install -e ".[examples]" +python -m pip install [LOCATION OF THE TAR>.GZ or the WHL FILE] ``` -Note in both cases above, the dependencies needed to run the examples are also installed. ## Check diff --git a/distribute b/distribute index af1223b..fdb99da 100755 --- a/distribute +++ b/distribute @@ -5,5 +5,5 @@ python3 -m build python3 -m twine upload --skip-existing dist/* -# users can also install from the Git repo using "python3 -m pip install git+https://github.com/jmfife/vedirect" +# users can also install from the Git repo using "python3 -m pip install git+https://github.com/Jordan-seebyte/vedirect-JL" diff --git a/pyproject.toml b/pyproject.toml index ca32c49..ac08071 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,10 +3,10 @@ requires = ["setuptools>=54.0", "wheel"] build-backend = "setuptools.build_meta" [project] -name = "vedirect_jmfife" -version = "1.1.0" +name = "vedirect-JL" +version = "1.1.1" authors = [ - { name="J. M. Fife", email="jmfife@gmail.com" }, + { name="Jordan Liss", email="jordanliss13@gmail.com" }, ] description = "Read Victron VEDirect Devices" readme = "README.md" diff --git a/setup.cfg b/setup.cfg index 601e8f7..5425da9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,12 +1,12 @@ [metadata] name = vedirect version = 1.0.1 -author = Mike Fife -author_email = jmfife@gmail.com +author = Jordan Liss +author_email = jordanliss13@gmail.com description = VE.Direct interface for Victron devices long_description = file: README.md long_description_content_type = text/markdown -url = https://github.com/jmfife/vedirect +url = https://github.com/Jordan-seebyte/vedirect-JL classifiers = Programming Language :: Python :: 3 License :: OSI Approved :: MIT License From 820fe466e19f465997faa12b9c4d81acc8bd52e6 Mon Sep 17 00:00:00 2001 From: Jordan Liss Date: Wed, 8 Jan 2025 14:50:46 -0800 Subject: [PATCH 4/4] Made more updates --- setup.cfg | 2 +- src/vedirect/vedirect.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 5425da9..91bb4a8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = vedirect -version = 1.0.1 +version = 1.1.1 author = Jordan Liss author_email = jordanliss13@gmail.com description = VE.Direct interface for Victron devices diff --git a/src/vedirect/vedirect.py b/src/vedirect/vedirect.py index e62a14c..4796f18 100644 --- a/src/vedirect/vedirect.py +++ b/src/vedirect/vedirect.py @@ -1,10 +1,11 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# -# Forked from karioja at https://github.com/karioja/vedirect -# # 2019-01-16 JMF Modified for Python 3 and updated protocol from # https://www.sv-zanshin.com/r/manuals/victron-ve-direct-protocol.pdf +# +# Forked from jmfife https://github.com/jmfife/vedirect in 2025 +# Now called https://github.com/Jordan-seebyte/vedirect-JL + import serial import argparse