A valve for agricultural spraying machines. The valve is used to control a flow rate of a spray medium in accordance with a valve position. For this purpose, the valve comprises an electrically operated actuator, which can change the valve position of the valve. The valve comprises an electrical energy store, which stores electrical energy for operating the actuator. The valve further has a control and evaluation unit, which is configured to charge the electrical energy store and to control the actuator. The electrical energy store has a capacity that ensures at least two switching operations of the valve. The control and evaluation unit is configured to control the actuator to generate a periodic movement with a defined number of movement strokes and a defined amplitude for shaking free the valve by the help of the electrical energy store if the valve is soiled or gridlocked.