Replies: 9 comments
-
hi @PKOE05 , I would advise you to check this repository, as this was already done by another project. But feel free to contribute as the converter might require a different approach. As I don't have such a TCP/IP RS485 converter, I wont be able to help. |
Beta Was this translation helpful? Give feedback.
-
Hello good evening,
i know this repository (it uses an esp32 with rs485 interface, this ist not
suitable for non hardware-people), but that is not what i want to propose.
What i mean: you have any tcp/ip to rs485 converter (i myself own a PW21).
In your software i only supply an ip-address and a port (for example 502).
Your communication with ABL should be the same only the medium changes and
you have not to worry about hardware. This ist he way as evcc works. Instead
of sending your modbus-code to serial port you send the same to a tcp/ip
port. This would be great.
Thanks for your quick answer.
Peter
|
Beta Was this translation helpful? Give feedback.
-
well, without such an adapter, it's impossible to tell. Feel free to fork the code and try it by yourself, getting inspired by other code repository using similar adapters. |
Beta Was this translation helpful? Give feedback.
-
@PKOE05 have you tried entering the IP and the port in my user interface? If your adapter accepts serial communication this way it should work. But keep in mind that the ABL communicates in MODBUS ASCII with some specifics which your adapter may refuse. See my screenshot attached for how to enter an IP and a port. |
Beta Was this translation helpful? Give feedback.
-
Hello,
yes i tried. Response: No Connection
Here a code snippet from a working connection, I never tried to build a home-assistant integration.
class IpConn():
def __init__(self, host, port, deviceid):
self.host = host
self.port = port
self.deviceid = deviceid
def SendReadABL(self, startadress, register):
"""Sendet ein Kommando an die ABL"""
# Alle Aufrufe wie in Doku als 0x01 für 1
# out: Antwort in 'response'
# zurückgegeben werden die Registerinhalte, abhängig von der Anzahl angeforderter Register
# als HEX-Zahlenstring
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.host, self.port))
#ABL will aufgeweckt werden, 2 x Firmware abfrage
s.send(b':010300010002f9\r\n')
time.sleep(0.1)
s.send(b':010300010002f9\r\n')
time.sleep(0.1)
I think it’s nearly the same as you do, the only difference ist the connection. Modbus decribes the logik, not the transport layer. Maybe you can implement TCP/IP.
Thanks
Peter
Von: matfroh ***@***.***>
Gesendet: Montag, 24. Februar 2025 17:23
An: matfroh/abl_emh1_modbus ***@***.***>
Cc: PKOE05 ***@***.***>; Mention ***@***.***>
Betreff: Re: [matfroh/abl_emh1_modbus] Using TCP/IP --> RS485 Converter (Issue #4)
@PKOE05 <https://github.com/PKOE05> have you tried entering the IP and the port in my user interface? If your adapter accepts serial communication this way it should work. But keep in mind that the ABL communicates in MODBUS ASCII with some specifics which your adapter may refuse. See my screenshot attached for how to enter an IP and a port.
IMG_7624.jpeg (view on web) <https://github.com/user-attachments/assets/171b1f4d-838f-45d1-9dfe-604bca72272e>
—
Reply to this email directly, view it on GitHub <#4 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AWXWI2Q63N3LIN2CFIUFUQL2RNBNPAVCNFSM6AAAAABXWVCL7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZYHE4DIMRWGQ> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AWXWI2S6SIAIWKYGEF6ECTD2RNBNPA5CNFSM6AAAAABXWVCL7WWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTU7VYHEQ.gif> Message ID: ***@***.*** ***@***.***> >
<https://avatars.githubusercontent.com/u/98977054?s=20&v=4> matfroh left a comment (matfroh/abl_emh1_modbus#4) <#4 (comment)>
@PKOE05 <https://github.com/PKOE05> have you tried entering the IP and the port in my user interface? If your adapter accepts serial communication this way it should work. But keep in mind that the ABL communicates in MODBUS ASCII with some specifics which your adapter may refuse. See my screenshot attached for how to enter an IP and a port.
IMG_7624.jpeg (view on web) <https://github.com/user-attachments/assets/171b1f4d-838f-45d1-9dfe-604bca72272e>
—
Reply to this email directly, view it on GitHub <#4 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AWXWI2Q63N3LIN2CFIUFUQL2RNBNPAVCNFSM6AAAAABXWVCL7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZYHE4DIMRWGQ> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AWXWI2S6SIAIWKYGEF6ECTD2RNBNPA5CNFSM6AAAAABXWVCL7WWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTU7VYHEQ.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
-
My advice, enable logging as per HA documentation, analyse the response, fork the code, play, try AI to help you adapt the code :-) |
Beta Was this translation helpful? Give feedback.
-
Hi @PKOE05 , while looking at some other elements, I found a hint of what it would take for you to modify the code. Having a variable choosing the type of connection (serial or tcpip) would mean a lot of code writing.
Now this is how the TCP IP connection is initiated, partly visible in your snippet, but as well how the message would then need to be formatted:
|
Beta Was this translation helpful? Give feedback.
-
Hi,
exactly this I have tried (if IP or if serial), thats not the solution, it produces a lot of „spagetti“ code. I am being thinking about the following: What is necessary for any wallbox to be controlled by software? We need to set the current, we need to set on/off for charging, we need to know which current is possible 3 phases, 1 phase or switching automatically. For checking the amount of delivered power may be usefull.
With this information is it possible to control the wall box regarding sun power available.
I am not very skilled in Python, but as the class-objekt affords: May be it is possible top write a „connection“, regardless oft he hardware (TCP/IP – RS485 – whatever).
Logic:
Define Connection
Define Type
For example: Read Current (with connection, with type) --> Type specific Import or subprogram whatever
I think in this way it is possible to abstract the connection and the type of wallbox.
In your code you use different ways to talk to the wallbox, after my opinion the way with the registers is the way to go.
def SendWallbox(self, startadress, register, connection, type):
I have written a simple not abstracted module as you do.
I will try in this direction, maybe it takes some time. Maybe you know the addon „evcc“. It´s very powerful, but also not a free software. I think such a powerful program is not needed by most people. Maybe more simplicity is the right way.
Thank you for your email
Peter
Von: matfroh ***@***.***>
Gesendet: Mittwoch, 5. März 2025 09:47
An: matfroh/abl_emh1_modbus ***@***.***>
Cc: Peter Koersgen ***@***.***>; Mention ***@***.***>
Betreff: Re: [matfroh/abl_emh1_modbus] Using TCP/IP --> RS485 Converter (Issue #4)
Hi @PKOE05 <https://github.com/PKOE05> , while looking at some other elements, I found a hint of what it would take for you to modify the code. Having a variable choosing the type of connection (serial or tcpip) would mean a lot of cod writing.
But here is how I initialize the connection either serial adapter and how I deliver the message:
‘’’
import serial
Initialize the RS485 adapter
serial_adapter = serial.Serial(
port="/dev/ttyUSB0",
baudrate=9600,
timeout=1
)
Send a message
serial_adapter.write(b"Your message here")
Read the response
response = serial_adapter.read(1024)
‘’’
Now this is how the TCP IP connection is initiated, partly visible in your snippet, but as well how the message would then need to be formatted:
‘’’
import socket
Initialize the Ethernet connection
host = "192.168.1.100" # IP of the Ethernet receiver
port = 12345 # Port number
Create a socket
ethernet_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ethernet_socket.connect((host, port))
Send a message
ethernet_socket.sendall(b"Your message here")
Read the response
response = ethernet_socket.recv(1024)
Close the socket (optional, if not persistent)
ethernet_socket.close()
‘’’
—
Reply to this email directly, view it on GitHub <#4 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AWXWI2R4KI7YGJJ5OMLAWPL2S22ZVAVCNFSM6AAAAABXWVCL7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMBQGI2DONZXGA> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AWXWI2X3WBKVO6YEPBISUJ32S22ZVA5CNFSM6AAAAABXWVCL7WWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTVA6KBNU.gif> Message ID: ***@***.*** ***@***.***> >
<https://avatars.githubusercontent.com/u/98977054?s=20&v=4> matfroh left a comment (matfroh/abl_emh1_modbus#4) <#4 (comment)>
Hi @PKOE05 <https://github.com/PKOE05> , while looking at some other elements, I found a hint of what it would take for you to modify the code. Having a variable choosing the type of connection (serial or tcpip) would mean a lot of cod writing.
But here is how I initialize the connection either serial adapter and how I deliver the message:
‘’’
import serial
Initialize the RS485 adapter
serial_adapter = serial.Serial(
port="/dev/ttyUSB0",
baudrate=9600,
timeout=1
)
Send a message
serial_adapter.write(b"Your message here")
Read the response
response = serial_adapter.read(1024)
‘’’
Now this is how the TCP IP connection is initiated, partly visible in your snippet, but as well how the message would then need to be formatted:
‘’’
import socket
Initialize the Ethernet connection
host = "192.168.1.100" # IP of the Ethernet receiver
port = 12345 # Port number
Create a socket
ethernet_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ethernet_socket.connect((host, port))
Send a message
ethernet_socket.sendall(b"Your message here")
Read the response
response = ethernet_socket.recv(1024)
Close the socket (optional, if not persistent)
ethernet_socket.close()
‘’’
—
Reply to this email directly, view it on GitHub <#4 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AWXWI2R4KI7YGJJ5OMLAWPL2S22ZVAVCNFSM6AAAAABXWVCL7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMBQGI2DONZXGA> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AWXWI2X3WBKVO6YEPBISUJ32S22ZVA5CNFSM6AAAAABXWVCL7WWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTVA6KBNU.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
-
Thanks, i know the code is a bit messy, but I needed something working rapidly and I’m quite happy with the result. If you are on a tight budget, consider wiring a network cable to the charger, as this can typically be used for rs485 connection and once you upgrade to a network ready charger, you are already wired. On a side-note, I suggest you investigate your 1-phase 3-phase switch as this will not be possible here. If this is something you want to achieve, look for another hardware, because although technically possible by software, you will most probably not comply to local regulations. Also, keep in mind that writing such settings on a device might only be possible a limited number of times, depending on how this is written on the hardware. The Emh1 was not built for that purpose and you may permanently damage it, and/or not even talking about fire risk… If you don’t mind, i’ll move this to a discussion topic, there might be other people interested to help. Right now, the component is not visible in HACS, but the request has been made and we might see it their in 3-4 months. PS: any chance to remove the email-trail in you replies, as this is directly feeding into GitHub ;-) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Great solution, i propose to expand the project using a tcp/ip converter to rs485. Usually the wall box is in the car-port and the home-assistant instance is in the basement of a house. Mostly there ist a wifi oder wired connection, rather than a serial connection.
Beta Was this translation helpful? Give feedback.
All reactions