Yes China had a complex machine run off of steam power during the Song Dynasty 960-1279 AD. But that machine was not the equivalent of the machine developed in by the Scottsman James Watt and still wasn't the first iteration of the Steam Engine. The first steam engine was produced in the first century Egypt. The Ottoman empire had a steam engine in the Sixteenth Century. England produced a steam engine in the seventeenth century England by Thomas Savory. So Watts isn't credited with the first steam engine but the first commercially viable engine which was broadly adapted to rail, shipping and industrial uses which the earlier iterations including china's were not suited to.
First rudimentary steam engine was the Aeolipile produced in the first century in Roman Egypt. In this light one can also say China had the steam engine during the Song Dynasty(960-1279).
History of Steam Engine
The first recorded rudimentary steam engine was the aeolipile described by Heron of Alexandria in 1st-century Roman Egypt.1 Several steam-powered devices were later experimented with or proposed, such as Taqi al-Din's steam jack, a steam turbine in 16th-century Ottoman Egypt, and Thomas Savery's steam pump in 17th-century England.
Science During the Song Dynasty
Chinese steam-powered machine
The steam engine invented by James Watts and patented in 1769 was arguable the most important invention of the Industrial Revolution, but it still took 60 years for it to penetrate the economy of Industrial Britain. Its first commercial application was in 1776, but it was not until 1830 that the first railroad appeared and 1839 before the first steam ship appeared. So Watts isn't credited with the first steam engine but the first commercially viable engine which was broadly adapted to rail, shipping and industrial uses which the earlier iterations including china's were not suited to.
China's Sciences / engineering took a different path from those of Europe. That different path put them at a disadvantage in developing or refining steam power in a few key disciplines. china unlike Europe never developed machine tools for metal working and never independently developed technical drawing ability.
Discovering Steam Power in China, 1840s-1860s
The technology that supported the steam engine was unknown in China. The Chinese technological tradition had developed in directions quite different from that of the West. Chinese artisans built sophisticated machines and were highly skilled in handling various materials, especially wood. Their metal castings also reached a high level of precision and quality, but they did not have a strong tradition of creating machine tools to work on metal. Furthermore, although technical trading and instructions were handed down orally and by way of drawings and models, Chinese drawing conventions did not involve clear geometric rules of projection. When production work required designers and workmen to be different people, designers supplemented their drawings (tu) with scale models (yang), because they were well aware of the limitations of drawings for communicating instructions. Unlike their European counterparts, who exploited the power of drawings in visual communication, Chinese artisans put their trust in models.