Configuration serial, mysql, and script python

Hello everyone
I’m new to HA and I do not know this but I would like to integrate it with my current DIY home automation system.
Currently my DIY system is made up of 10 arduino connected via RS485. One of these arduino is connected to the serial port of a Raspberry Py via USB.

on the raspberry works a Python script that for every event receives a message arrey = [ID, x, y] where
ID = identifies the arduino number
x = identifies the type of status / sensor parameter
y = the value of the parameter

for each message received, the python script records the states or values ​​in a mysql db and performs some automatisms.
The script can also send messages to turn on, turn off etc …

The question is, if I wanted to integrate the sensors / states into HA what could be the best optimal way to communicate with HA?
Es.
a) having the HA message read directly from serial? how can I do?
b) insert in the existing python script something that sends the message also to HA? does the way exist?
c) to read HA states / values ​​in db mysql?

I think keeping things as simple as possible is probably your best criteria.

c) is possible using the existing sql sensor, but you are left running your python script and an extra database. HA already has its own sql database.

b) is the option I would choose, modifying your existing python program by translating the messages into MQTT messages to be sent to HA, and removing your SQL database. This also provides for two way communication if your arduinos also receive commands.

a) Would be best, as it would be simplest, but I don’t know of a way to do that. :unamused:

Thanks a lot for the answer

in case I decide to implement mqtt in the script do you have any examples or useful links to deepen?

I would just use the paho-mqtt python package and the utility interface single to publish a message whenever you need to send data.

If you want to receive data from MQTT it gets more complicated, but the explanations on that page are as good as anywhere.