Correct way to add an entity to a hub - on the fly

I am looking for an example or some pointers as to how I can add an entity to a hub device (not using config flow).

A little description of my “hub” ( I assume this is correct?). I have a python library that connects to a device via telnet. The device can have multiple devices attached, the details of what devices is not know at the start. All I get is a message via telnet that the status of the device has changed on/off and which device it is (this is a unique value).

What I would like to do is when the message is received, I am currently using a callback within my coordinator.py. It checks if that entity exists (using unique value), if not it gets created. Otherwise it simply updates the status.

I sort of had it working using the following:

self.hass.states.set(entity_id, state, attributes)

I also have tried using AddEntitiesCallback module but cannot seem to figure the syntax for this to work.

Another option would be to call a config flow? But again I am not sure if this is the right approach or how I would do this?

Any pointers of how to add an entity on the fly would be great?

Thanks.