Trigger an app or device through script?

Hi,

I am trying to write a testing framework to generate events to apps using custom device handlers that send multiple events to the app.

For example, for an app that turns lights off, after motion inactive for 3 min
I want to write a device handler for a motion sensor that will send motion active and inactive events to the app for testing its behavior.

Now, I want to trigger this motion sensor through a script and not manually by going to the Samsung app and tapping on the device icon.

Can you suggest ways for doing that?

One idea is that I have web event kind of something, or else I can use the android monkey to automate the manual process of tapping on device tile.

I will really appreciate the help