How can I know programmatically which device is connected to my host?

Considering that the hailort package is installed on the system, you can use the hailortcli tool to query the device(s) that connected on that system:

hailortcli fw-control identify

The output should look like this:
image