def playfield_switch_hit(self, **kwargs):
        """A switch tagged with '<this playfield name>_active' was just hit,
        indicating that there is at least one ball on the playfield.

        """
        if (not self.balls or (kwargs.get('balls') and self.balls - kwargs['balls'] < 0)):
            self.mark_playfield_active()

            if not self.num_balls_requested:
                if self.machine.game:
                    self.unexpected_balls = 1

                if self.machine.config['machine']['glass_off_mode']:
                    self.log.debug("Playfield_active switch hit with no balls "
                                   "expected. glass_off_mode is enabled, so "
                                   "this will be ignored.")
                else:
                    self.log.debug("Playfield_active switch hit with no balls "
                                   "expected. glass_off_mode is not enabled, "
                                   "setting playfield ball count to 1")

                    self.balls = 1
                    self.machine.events.post('unexpected_ball_on_' + self.name)

    # def _ball_added_handler(self, balls):
    #     self.log.debug("%s ball(s) added to the playfield", balls)
    #     self.balls += balls
dataset/ETHPy150Open missionpinball/mpf/mpf/devices/playfield.py/Playfield.playfield_switch_hit/original