An electronic switch for controlling a device 170 by switching a function of the device at least in dependence on a sleep stage of a human. The switch includes an EEG data interface configured to receive brain activity data from an EEG sensor 120 configured to monitor electrical activity of the brain of the human during a training phase, an EEG sleep classifier 125 configured to classify sleep stages of the human from the received brain activity data, and a body data interface configured to receive body activity data from an alternative sensor 130 configured to monitor a bodily function of the human both during the training phase and during a subsequent usage phase. The alternative sensor is different from the EEG sensor, and the electronic switch further includes an alternative sleep classifier 135 and a machine learning system 140, the machine learning system being configured to train the alternative sleep classifier 135 to classify a sleep stage of the human from the received body activity data, the learning system using sleep stages classified by the EEG sleep classifier 125 and concurrent body activity data received from the alternative sensor as training data, wherein in the usage phase, the device 170 is controlled in dependency on sleep stages of the human classified by the alternative sleep classifier 135. A control logic 150 is configured to at least determine that the classified sleep stage is one of a set of particular sleep stages and to switch a function of the device at least in dependency on said determination.