karioja / vedirect

Simple VE.Direct reader for Python
MIT License
94 stars 38 forks source link

how to install #9

Closed riker65 closed 3 years ago

riker65 commented 3 years ago

Hi

do you have some hints how to install or use setup.py

or just run it with /dev/ttyUSB1 I only want to read data from BMV shunt

errors I face:

Example `python3 examples/vedirect_print.py --port /dev/ttyUSB1

Traceback (most recent call last): File "examples/vedirect_print.py", line 5, in from vedirect import Vedirect ModuleNotFoundError: No module named 'vedirect' Setup: python3 setup.py usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help

error: no commands supplied ` thanks for supporting

karioja commented 3 years ago

You could try something like

PYTHONPATH=. python3 examples/vedirect_print.py

This will add the current directory to the Python module search path and allow python to find the vedirect module under the vedirect directory.

https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH

For the setup.py you need to provide the install command.

python3 setup.py install

https://docs.python.org/3/install/index.html

riker65 commented 3 years ago

thanks , working now for the example

how to run vedirect with designated USB1?

python3 vedirect.py --port /dev/ttyUSB1

karioja commented 3 years ago

Running the vedirect_print.py example using /dev/ttyUSB1 would be

PYTHONPATH=. python3 examples/vedirect_print.py --port /dev/ttyUSB1

riker65 commented 3 years ago

Running the vedirect_print.py example using /dev/ttyUSB1 would be

PYTHONPATH=. python3 examples/vedirect_print.py --port /dev/ttyUSB1

ok thanks this worked.

what is vedirect/vedirect.py used for?

thanks a lot

karioja commented 3 years ago

vedirect/vedirect.py is the library code implementing the Victron VE.Direct protocol.

riker65 commented 3 years ago

ah ok understood

another questions: how to add user and password of MQTT broker?

riker65 commented 3 years ago

would this work?

` parser.add_argument('--mqttuser', help='MQTT broker address', type=str, default='user') parser.add_argument('--mqttpw', help='MQTT broker address', type=str, default='pw') parser.add_argument('--mqttbrokerport', help='MQTT broker port', type=int, default='1883') parser.add_argument('--topicprefix', help='MQTT topic prefix', type=str, default='bmv/') args = parser.parse_args() ve = Vedirect(args.port, args.timeout)

found the solution:

    client.username_pw_set(args.mqttuser,args.mqttpw)
    print("Connecting...")

must be called before connecting