Hello,
You can enable either Modbus TCP or Serial master via WebUI. Then you can use ubus commands for Modbus. These can be either TCP or Serial:
ubus -v list modbus_master
ubus call modbus_master tcp.test '{...}'
ubus call modbus_master serial.test '{...}'
For example:
ubus call modbus_master serial.test '{"id":1,"timeout":1,"function":3,"first_reg":1,"reg_count":"1","data_type":"16bit_int_hi_first","no_brackets":1,"serial_type":"/dev/rs485","baudrate":9600,"databits":8,"stopbits":1,"parity":"None","flowctrl":"None"}'
Also, not sure if you need it, but if you want to run SSH commands from python, take a look here.
Kind Regards,