I’m using the HAOS in a VM.
Modbus TCP is working fine, however, when I use Modbus serial in ASCII mode, the requests are always sent in RTU format:
Home Assistant 2023.2.3
Supervisor 2023.01.1
Operating System 9.5
Frontend 20230202.0 - latest
# ==================================================================================
# Get PV Inverter info from Modbus TCP Gateway
# ==================================================================================
- name: MacSolar
type: serial
baudrate: 9600
bytesize: 8
method: ascii
parity: N
port: /share/ttyInverter
stopbits: 1
sensors:
- name: "MacSolar AC Power Soc"
data_type: uint16
address: 8
slave: 240
unique_id: macsolar_ac_power
state_class: measurement
unit_of_measurement: W
device_class: power
scale: 1
precision: 0
scan_interval: 10
This is what I see on my socat redirector (which is what I use to connect my inverter modbus ascii rs485 port to my TCP network):
> 2023/02/15 15:04:15.000542784 length=8 from=2480 to=2487
f0 03 00 08 00 01 10 e9
That frame above is RTU It should be ASCII
I can see the transmit light flashing on my TCP gateway (so the requests are reaching the gateway), but there is no response (as it is RTU format, which the inverter doesn’t understand).
If I test the same TCP gateway on windows, so I can eliminate my TCP gateway + Inverter, I can see the proper ascii traffic, which should always end in 0x0D 0x0A
3A 46 30 30 33 30 30 30 30 30 30 31 34 46 39 0D 0A
Changing the method between ascii and rtu makes no difference. It seems the serial is stuck in RTU mode.
I did this originally as the HA modbus implementation doesn’t seem to allow me to overide the framer and set it to framer =ModbusAsciiFramer (which I could do in Python) If that worked, I could ditch socat + serial redirection and do Modbus ASCII over TCP.