The device has an optical scanning head with a radiation source, as well as with a sensor. The scanning head transmits a signal toward a background, e.g., a washbasin, and receives signals diffusely reflected from that background. The signals received are sent to an electronic control unit for controlling, e.g., a valve. The device is arranged, e.g., in the water outlet of a washstand appliance.