Receiving warning when 'switch' is on after 30 minutes

I’ve a switch that I would like to monitor, how can I configure a rule to receive an email when this switch is on for longer than 30 minutes?

I guess the Low Battery warning is similar,

import org.openhab.core.library.types.DecimalType

val String mailTo = ""
val int lowBatteryThreshold = 10

rule "Battery Monitor"
when Time cron "0 0 19 * * ?"
    if (! Battery.allMembers.filter([state < lowBatteryThreshold]).empty) {
        val report = Battery.allMembers.filter([state instanceof DecimalType]).sortBy([state]).map[
            name + ": " + state.format("%d%%")

        val message = "Battery levels:\n\n" + report + "\n\nRegards,\n\nopenHab"

        sendMail(mailTo, "Low battery alert", message)

But I can’t work out how to tailor it to my needs.

Presuming that your switch on event is handled by a rule, too, you can simply start a timer:

rule "It switched on"
        Item MySwitch changed to ON
        Item MySwitch received command ON
        tAlertTimer = Timer.create(now.plusMinutes(30) [|
            sendEmail(mailTo, "Low battery alert", message)

Of course, cancel() the timer if it’s still running when/if the switch position returns to OFF before the timer fires.