TCP Ip comand to retrieve statusv (hex)

hi,
have a domotic system, with no intergrations, i can send however TCP IP commands to the system to turn on / off a light or something, i have a php script todo that

but now i also want to retrieve the status of a light/switch

so i need to send a hexadecimal string to an IP, then i retrieve a status in hexadecimal output, that string contanins the status of a light, like 0 for off, 1 for on

how can i accomplish this in home assistant? can someone put me on the right track?

thnx