And when I create such a device I can click on the command "doThis" to execute it (as the log proves).
But how can I call such functions from Rule Machine and use the returned value?
"Run Custom Action" allows only to execute a driver command, without any chance to get the value; And "Set Variable" does not offer the use of Custom Actions...
@bravenel, do you have any idea to accomplish such mission?
Thanx again, but in Dominic Meglioās example there are no functions defined:
None of his Attributes uses parameters (IMHO according to the specification it's not allowed), and also none of his Commands.
If you think about using an Attribut to only return the value of a previous called Custom Action: That would not be reliable, because of the concurrent executions of such methods.
Will you describe a use-case for this functionality? It may be possible to find a workaround, but it would help to understand why you are asking for this functionality.
I am currently working on utility devices, which among other things allow (almost) any calculations.
But of course the usecases for such a feature would be endless...
Could you pass a caller-specified UID as a parameter to the command and then update an attribute with the response, embedding the UID and the result in a way that could be tokenized by this feature for further interpretation?
It would require a pair of RM rules to send the command and observe a change on the attribute for each response.
The attribute is where the value is stored in the driver. This is the result of a sendEvent. A command is where the math is done, and those take parameters. So, RM calls a Custom Action for the device, passing the value as a parameter. The command method does the math and puts the result in the attribute using sendEvent. RM can Wait for Conditions with a Custom Attribute changed, thus getting the result back in %value%.