Haiku Haiku Helper Code Help

jmorris644

Active Member
I have been using iRule to control my theater lighting and just recently they implemented slider controls. I am able to query HaikuHelper to get the level of a light /api/controller.unitWithNumber(43).level and get the level. But iRule cannot adequately deal with just the number bring returned. So I would like to do 2 things:
 
1. Surround the .level response with some text
2. Possibly tokenize all of the light levels that are non-zero in a response.
 
I am guessing that there is a way to expose a function to http just like the api itself but I cannot ascertain how to do it with the docs.
 
Any help would be greatly appreciated.
 
Thanks
 
Joe
 
Yes, this is very easy to do. Just define a function in the script that returns what you want and just call it via /api/yourfunction(43) for example.

In short, the API calls are just calling things in the same script environment as the script itself. So everything in your script environment is accessible via the API too.

PS. If iRule supports HTTP POST, it would be better to POST to /api rather than using the URL for the code, its just cleaner and more reliable that way.
 
Back
Top