Something similar was just discussed in this thread:
Basically, you need something to track the status of the switch when it is manually thrown. Take a look at my post and the one that follows by @lflorack. My solutions proposed using a variable in webCore to track the switch’s status. @lflorack suggest using a virtual switch to do the same. If you are not familiar with webCore, the @lflorack’s solution may be a bit simpler.