Motion state as string

I am working on a smartapp that has 3 triggers and motion to cause a light to go on and then using runIn, turn off after a time delay. The problem is that currently, once the time has been met, if you are actively moving, ie. motion active, the light still goes off. You then have to wait for motion to go inactive, and then active again to turn the light back on. What i am trying to do is get the motion state and see if it is active, if so reset the timer. Unfortunately i am having quite the trouble comparing the returned motion state with a string.

Have a look at the code in zone motion manager, you can find what you need in there.