Detection of the presence or absence of a tube, a connector or a container in an apparatus