Skip to content
Open
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
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion distribute
Original file line number Diff line number Diff line change
Expand Up @@ -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"

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[metadata]
name = vedirect
version = 1.0.1
author = Mike Fife
author_email = jmfife@gmail.com
version = 1.1.1
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
Expand Down
45 changes: 35 additions & 10 deletions src/vedirect/vedirect.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/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
import time
from .vedirect_device_emulator import VEDirectDeviceEmulator
# from .vedirect_device_emulator import VEDirectDeviceEmulator
import sys
import logging
log = logging.getLogger(__name__)
Expand Down Expand Up @@ -223,13 +224,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 = {
Expand All @@ -244,7 +248,27 @@ def typecast(payload_dict):
'W': ['W', 1, 0]
}

def __init__(self, serialport='', timeout=60, emulate=''):
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='/dev/ttyUSB0', timeout=60, emulate=''):
""" Constructor for a Victron VEDirect serial communication session.

Params:
Expand Down Expand Up @@ -388,10 +412,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)

Expand Down