Closed clemefr closed 1 year ago
Converting this script to Python3 is not that easy. It makes use of 'binary' strings, which are incompatible with Python3.
Strings From a developer’s point of view, the largest change in Python 3 is the handling of strings. In Python 2, the str type was used for two different kinds of values – text and bytes, whereas in Python 3, these are separate and incompatible types.
I have ported the script to Python3 and it needed lots of changes. In my point of view it makes no sense to make one script for both Python versions (and to be still a kind of readable).
Now my question to @rellit: Do you like resol-vbus to be Python3 compatible?
If yes, do you like to add a new script e.g. resol3.py
or do you like to make a release of the current resol.py and switch to a single new Python3 resol.py and not maintaining the Python2 any more as Python2 is EOL since beginning of 2020 ...
I am willing to contribute my work.
Ok, no one interested?
I pushed the Python3 code for testing in my repositories python3 branch here.
I can not test the LAN connection, as I use tty / serial. Hope someone can confirm that it works.
Could someone please test the LAN connection. I would prefer the resol3.py
solution as it might still make sense to support Python2. As soon as the LAN connection is confirmed I will do a pull request.
Hi, Python3 works with KM2 to Ethernet. Only had to change some encoding did it on python 3.8 Hope it helps.
Tried https://github.com/hmueller01/resol-vbus-python/tree/python3 on python 3.10.4 with the following result:
python resol.py
Traceback (most recent call last):
File "/home/jmueller/Scripte/resol-vbus-python-python3/resol.py", line 261, in
I'm using LAN connection telnet 192.168.49.129 7053 Trying 192.168.49.129... Connected to 192.168.49.129. Escape character is '^]'. +HELLO
I have a Deltasol MX (no spec file yet, but i was hoping to get at least some results using DeltaSolBXPlus.json) connected to KM2 with Firmware 1.2.0
Exactly the same here (except: I have created the specfile for MX). DeltaSolMX connected via LAN - messages as following:
Traceback (most recent call last): File "/usr/local/bin/resol.py", line 261, in <module> load_data() File "/usr/local/bin/resol.py", line 49, in load_data send("DATA\n") File "/usr/local/bin/resol.py", line 87, in send sock.send(dat) TypeError: a bytes-like object is required, not 'str'
I think there are more type errors. I tried send("DATA\n".encode())
but no success. It would be nice if the script runs on python3.
@df8oe Have you tried https://github.com/hmueller01/resol-vbus-python/tree/python3 ?
Yes - that is the version my report is related to. Sadly there is no issue report possible.
I investigated more (but I am not a Python specialist at all):
There are alredy strings which are send via LAN. Especially the login process uses strings. I have added some prints to look what happens and after the login line
send("PASS %s\n" % config.vbus_pass)
Resol answers with
ERROR: Not authorized to start data mode
I tried also
send("PASS vbus\n".encode('ascii'))
but Resol rejects me.
I worked it out: https://github.com/hmueller01/resol-vbus-python/pull/1
It is working now via LAN stable - PR is nor merged yet...
Tx @df8oe. I just created PR #13.
I try to convert your code to python 3 like this:
Receive 1024 bytes from stream
def recv(): dat = sock.recv(1024).decode() return dat
Sends given bytes over the stram. Adds debug
def send(dat): sock.send(dat.encode())
and got the following error: File "resol.py", line 72, in recv dat = sock.recv(1024).decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 0: invalid start byte
Any help ?