def METHOD_NAME(self,state,id,events):
    if state:
        if id==actPower.id:
            for event in events:
                    if event[0] == 4:
                        if event[3] == 1: #source has become activated
                            self.SDL["source"] = (1,)
                        elif event[3] == 0: #source has become deactivated
                            self.SDL["source"] = (0,)
                        else: #unexpected value
                            PtDebugPrint("xPoweredLightSwitch.OnNotify:\t'%s' ERROR---got bogus msg - source = %d" % (varstring.value,self.SDL["source"][0]))
                    PtDebugPrint("xPoweredLightSwitch.OnNotify:\t'%s' got msg - source = %d" % (varstring.value,self.SDL["source"][0]))
                    if self.SDL["source"][0]==1 and self.SDL["switch"][0]==1: # if switch was already on and power now turns ON
                        respOn.run(self.key,events=events)
                    if self.SDL["source"][0]==0 and self.SDL["switch"][0]==1: # if switch was already on and power now turns OFF
                        respOff.run(self.key,events=events)
        if id==actSwitch.id:
            if self.SDL["switch"][0] == 1: #switch has become activated
                self.SDL["switch"] = (0,)
            elif self.SDL["switch"][0] == 0: # switch has become deactivated
                self. SDL["switch"] = (1,)
            else: #unexpected value
                PtDebugPrint("xPoweredLightSwitch.OnNotify:\t'%s' ERROR---got bogus msg - switch = %d" % (varstring.value,self.SDL["switch"][0]))
            PtDebugPrint("xPoweredLightSwitch.OnNotify:\t'%s' got msg - switch = %d" % (varstring.value,self.SDL["switch"][0]))
            if self.SDL["switch"][0]==1 and self.SDL["source"][0]==1: # if source was already on and switch now turns ON
                respOn.run(self.key,events=events)
            if self.SDL["switch"][0]==0 and self.SDL["source"][0]==1: # if source was already on and switch now turns OFF
                respOff.run(self.key,events=events)
    if id==respOn.id:
        PtDebugPrint("xPoweredLightSwitch.OnNotify:\tsending msg '%s' clicked, pulled or otherwise activated." % (varstring.value))
        note = ptNotify(self.key)
        note.setActivate(1.0)
        note.addVarNumber(varstring.value,1.0)
        note.send()
        return