Originally Posted by meme
Just to be clear - my plugin does not have to be running and looking for a signal? It just has to test if gui.device_metadata_available is True before continuing - otherwise I will issue an error dialog to tell the user to wait and try again.
No. It is a signal, not a flag. You can't test it at random times.
Thinking about it, I understand one of the difficulties you are facing. You don't track connections and disconnections, so this one signal isn't sufficient. You need to know when the device connects and disconnects so you can know what this signal means.
Assuming Kovid accepts the change, I have added a second signal, gui.device_connected_changed.emit(connected). This signal is emitted whenever a device is connected or disconnected. The argument to the signal, connected, is True if a device has been connected, False otherwise.
In your init method, connect to these two signals. If you get device_connected_changed(False), mark the fact that there is no device and clear the device valid indication. If you get device_connected_changed(True), mark that fact, and prepare to receive the device_metadata_available signal. When you receive the device_metadata_available, note that fact, which the rest of your plugin will use to determine whether the info is available or not.
The initial condition is that there is no device.