Who's calling my driver commands? How can I get that?

Is there a way for my driver to get the name of the rule or app that is running one of my custom commands?

Why do you want / need to know this?

At the bottom of your device's edit page, there is a list of apps that use your device as well as the parent. You can usually then go to the app and set up logging. That logging would indicate when the command is called.

If it your custom command, you can change the command definition in Metadata to include an input of source. The add that to the custom command calls from the calling apps to include the source.

In the method, change the call to "def custCmd(source = null) {" and add a lie to log the method and source. (the source = null allows you to also call the command w/out the additional input.

2 Likes

Cool, thanks. I'm just curious at this point. I may require a parameter for certain commands.

If you just want to see a history of which apps are making calls into your device’s commands, you can view that by going into the Device page, then clicking the EVENTS link near the top. You should see a page that looks like the following. The Produced By column show the name of the App that made the call.

1 Like

Is there any way to access this information in an event handler in an app? The event object sent to an app does have an undocumented "producedBy" property, but that property seems to always be null from what I can tell in my testing.

The actual event itself is always produced by the device itself (by the driver code). The command is what will have something calling it, but those "event" logs I do not thing are visible to other apps.

1 Like

It would be nice if we could access it. Hopefully the existence of that property in the Event object means they are planning to use it at some point.