The device (6) has a detergent tray (7) for containing detergent in the form of powder, liquid or semi-liquid e.g. gel, and a receptacle (8) for containing water. The detergent tray is rotated after water is filled in the receptacle. A trigger (9) is moved when water level in the receptacle exceeds a threshold value, so as to rotate the detergent tray independent of the quantity of the detergent contained in the detergent tray. The trigger includes a float (18) that is placed partly in the receptacle, where the float rotates about an axle (11). An independent claim is also included for a washing machine.