HA connect and interact with a TCP socket server

I have a server that takes simple commands:

e.g

SET LIGHT ON
SET LIGHT OFF
GET LIGHT

The first set the state of the name, and both returns the state after the command has run.

I can do this relatively easily with a script.

Is there a way to set this up in the configuration ?

Thanks,
Andrew

BTW My HA instance is in a container

Then you can change the switch to a light with this if you want: