Help: I want "if motion is active then relay1 on Sonoff Dual is turn on"

Can you fix code below.
I want “if motion is active then relay1 on Sonoff Dual is turn on”
Thanks.
vtm-s%20sonoff%20dual

definition(
name: “if motion is active them switch turn on”,
namespace: “KichBan”,
author: “Võ Thanh Minh”,
description: “Automation”,
category: “Safety & Security”,
iconUrl: “https://s3.amazonaws.com/vtmsmartthings/vtms60.png”,
iconX2Url: “https://s3.amazonaws.com/vtmsmartthings/vtms120.png”,
iconX3Url: “https://s3.amazonaws.com/vtmsmartthings/vtms120.png”)
//Test: OK
preferences
{

section ("a few minutes?")
    {
     input name: "timeofP", type: "number", title: "a few minutes?", defaultValue:"1"
    }

section("Select Switch")
    {
        input("sw1","capability.switch",title:"Switch")
    }

section("Select Motion")
{
    input("motionCD", "capability.motionSensor",title:"Motion")
}
//

}
def installed()
{
init()
}
def updated()
{
unschedule()
init()
}

def init()
{
subscribe(motionCD,“motion”,motion_CD)
subscribe(sw1,“switch”,sw_1)
}

def motion_CD(evt)
{

if(evt.value=="active") 
{
        sw1.on()
        def timeP=timeofP*60
        runIn(timeP,lightOFF)
 }

}

def lightOFF()
{
def t=motionCD.currentValue(“motion”)
if(t==“active”)
{
def timeP=timeofP*60
runIn(timeP,lightOFF)
}
else
{
sw1.off()
}
}