Lots of stuff with an Aoetic Smart switch 6

The Reason:
I live in the country and have a water pump, I wanted to be able to monitor cycle times for the pump, along with being able to easily turn the pump off when I leave the house, and turn it back on when I return.
The Items:
WaterPumpWatts=Watts reported by the Smart Switch
WaterPumpSwitch=Smart Switch Power ON/OFF
Security Switch= VRS15 Scene Capable Push On/Off 120 Volt switch, because it allows node groups. Turns security system on/off.
WaterPump_ResetMeter=switch witch resets KWh accumulator on Smart Switch
PumpRun, PumpStop=Date time variables

The first rule, sends an a text to my phone, using the mail action whenever the pump starts or stops pumping water.

import org.eclipse.smarthome.core.library.types.DateTimeType

var String PumpRun = "off"
var String PumpRun1 = "off"

//Send a message when the Well Pump stops running
rule "PumpState"
when
	Item WaterPumpWatts changed
then
    if (PumpRun == "on" && WaterPumpWatts.state < 100) 
    {
       	
       	PumpRun = "off"
       	postUpdate(Pump_Stop, new DateTimeType())
       	Thread::sleep(10000)
		sendMail("Yourph#here@vtext.com", Pump_Stop.state.format("%tR") +" "+ Pump_Stop.state.format("%tD"), " Pump Stopped")
    }
//Send a message when the Well Pump starts running
else
    if (PumpRun == "off" && WaterPumpWatts.state > 800) 
    {
    	PumpRun = "on"
		postUpdate(Pump_Run, new DateTimeType())
		Thread::sleep(10000)
		sendMail("Yourph#here@vtext.com", Pump_Run.state.format("%tR") +" "+ Pump_Run.state.format("%tD"), " Pump Running")
	}
end

The next two rules turn the pump “Off”, when the Security system is “on” and turn the pump “on”, when the security system is “off”

//Turn Pump Power On when Security is Off
 
rule "SecOffPumpOn"
when
	Item Security_Switch changed from ON to OFF
then
    {
		sendCommand(WaterPumpSwitch, ON)
	}
end

And

//Turn Pump Power Off when Security is On

rule "SecOnPumpOff"
when
	Item Security_Switch changed from OFF to ON
then
    {
    	sendCommand(WaterPumpSwitch, OFF)
	}
end 

The last rule resets the KWh cumulative meter in the Smart Switch at 00:01.00 am on the first day of every month.

rule "MoEndReset"

	when
		Time cron "0 1 0 1 1/1 ? *"
		then
		{ 
		sendCommand(WaterPump_ResetMeter,ON)
		Thread::sleep(5000)
		sendCommand(WaterPump_ResetMeter,OFF)
		}
		end