I spent some time this weekend getting my Russound CAA66 set up with Home Assistant, which needs a TCP to Serial gateway. Mine is plugged into a different Raspberry Pi on the network, and its python environment is not in the best state. So, I threw a Docker container together to run the service, and it’s running great. I figured I’d share here in case anyone else stumbles upon it while searching. Code is at https://github.com/kevinreedy/tcp_serial_redirect or you can spin it up by running:
docker run -itd \
--restart always \
--device /dev/ttyUSB0 \
-p 7777:7777 \
--name tcp_serial_redirect \
ghcr.io/kevinreedy/tcp_serial_redirect \
python tcp_serial_redirect.py --rts 1 --dtr 1 /dev/ttyUSB0 19200
You may need to replace the two instances of /dev/ttyUSB0
with your Serial Port if it differs. The container is built for ARMv6, ARMv7, ARM64, and AMD64, so it should run on whatever device you need.