Create a custom component which connects with a device using socket

I created a custom component. Created socket connection on the device IP and port. Need to update its state continuously in the api/states json even if changed by IR remote.

How to send the command to fetch the state of the device to be sent continuously to the device?

That’s a sensor platform and those platforms have a polling interval.

Alright. Thank you.