Haiku Unit Event call URL

jmorris644

Active Member
I have been reading the API document and trying to determine if I can have HaikuHelper call a URL based on a unit event. It looks like the only unit event works with user settings only.

What I am trying to do is have Haiku helper call a URL on a different web server when a state of a monitored unit changes. I am specifically looking to get the level of lights.

Is this feasible?

Thanks

Joe
 
Yes, it should be very easy to do. There are a few ways to do it. Can you give more details on what you are trying to do so we can pick the best method? And what type of lighting system are you using?
 
I have an HAI OmniPro II. Here is an example URL I would like to call when the level of a light(unit) changes.

http://myserver.com/mypage.asp?unit=HaiUnitNumber&level=HaiUnitLevel

Does that help? To describe exactly what I am doing on the remote web server side will take a LOT of typing.

If possible, I would prefer to do this for specific units.

Joe
 
Okay so I've looked at the options, and there is no event for the light level change currently in HaikuHelper. Right now these are ways of doing it:

- You can connect to the live websocket stream and get instant update of all events

- You can set up a timer that keeps checking the lights you are interested in for their level and report any changes

Now, instead, what I can do is have the a onUnitLevelChange() event added in the next update, that will make it very easy for you. You will be notified of all level changes and you can act as needed on the units you require. So in the mean time you can use one of the above two options, but as of the next update you'll be able to do it very easily.
 
I noticed that the documentation about unit events on page 54 did not change. Are you returning just the unit number or the unit number and level?

Thanks

Joe
 
I always get my copy from here

http://cocoontech.com/forums/topic/20582-haikuhelper-javascript-json-api-documentation/

Maybe you are putting it in a different place now? I jsut checked again, and it is not there.

Thanks

Joe
 
Ah that copy may be out of date. You should use the copy that is included with HaikuHelper, its in the Help menu.
 
LOL, that assumes that we all do our development on the Mac. Not I have to export that PDF file and move it across the network to my windows server where I am doing my programming. :)

Joe
 
Ok, I apologize. I don't fully understand how the scripting works in HH.

I have crated this function but it is not working. I am able to test all of the code on the called server and that code is working. I am afraid I am missing something simple.

Code:
// Welcome to HaikuHelper's JavaScript Bridge!
// Click the help button at the bottom of this window to get started
function onUnitLevelChange(43) {
var level = controller.unitWithNumber(43).level();
var req = new XMLHttpRequest();
var getURL = "http://192.168.1.4/UpdateLightStatus.asp?unit=43" + "&level=" + level;

req.open ("GET",getURL);
req.send();
}

Joe
 
The argument is an object, representing the Unit, so the code should be more like:

Code:
function onUnitLevelChange(unit) {
    if(unit.number == 43) {
        var req = new XMLHttpRequest();
        var getURL = "http://192.168.1.4/UpdateLightStatus.asp?unit=" + unit.number + "&level=" + unit.level;

        req.open ("GET", getURL);
        req.send();
    }
}

The event will be called for any unit's level change. So you need to check for unit #43 (or any other relevant units).
 
Back
Top