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, https://github.com/openhab/openhab/wiki/Samples-Rules#get-an-email-when-battery-powered-devices-are-running-low-on-power

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

val String mailTo = "you@example.com"
val int lowBatteryThreshold = 10

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

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

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

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"
    when
        Item MySwitch changed to ON
        Item MySwitch received command ON
    then
        tAlertTimer = Timer.create(now.plusMinutes(30) [|
            sendEmail(mailTo, "Low battery alert", message)
        ]
end

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