Simple Http Command to control fan light

Is there a simple format to use in web browser to send a fan light on or off command? I see in the api docs it’s all curl but looks like http commands. I know how to get the needed info like device ID, IP address and token which are all shown in the Bond App in the setting info.

curl is just one method which can used.

Any tool or script, etc. which can PUT, GET, POST, PATCH, or DELETE commands over HTTP will likely work, with varying forms of adapting to platform-specific idiosyncrasies.

How, or via what method / device, are you trying to issue the HTTP commands?

Hi, thanks for response.

My home automation system let’s me do basic scripting and if I setup a virtual device like a bedroom fan light, I can launch a simple http script command using GET (have done this for other device integrations) based on turning on or off the virtual device.

What I need is the http format of what is needed for the bond bridge to turn on a fan light or turn it off.

Here is an example of the basic command I use now to control a camera:

&hs.URLAction(“http://IPADDRESS of CAMERA/set_alarm.cgi?motion_armed”,“GET”,"","")

Again all I need is the above format with what info is needed to pass along in the http command with necessary bond bridge/device info to make a light turn on or off.

Thank you

Would still recommend that you test using curl on a computer on the same network, just to make sure you have all the right bits of information (IP address, device ID, token, etc).

Once you have confirmed via curl (or if you’re confident / brave and don’t want to test first), let’s look at your desired format.

This is for HomeSeer I expect?
I don’t have it myself, but I saw the documentation here, along with reading over some HS forums.
Should be something like this, replacing the curly braces with relevant parts:

&hs.URLAction(“http://{IP address of BOND Bridge}/v2/devices/{device_id}/actions/ToggleLight”,“PUT”,"{}",“BOND-Token: {API token}”)

If curl works but HS URLAction doesn’t work, there are a couple other formats we can try to make HS more happy.

Hey @FrankThompson - did you integrate with HomeSeer already? I know back in the day you were eager to do so, but I think the last time I saw you posting was before Actions and State were available in the Local API.

Correct for Homeseer. I will test the command you provided pulling the Bond info needed using the bond app in the settings info. The homeseer controller is local to bond device so will be testing all over local network.

A Homeseer plugin for Bond would be great. I was using IFTTT to integrate the environments but that is a hooky way to do it.

Doing some internet guessing here, but I think @FrankThompson on this forum is sirmeili on the HS forums, and he looks to be an active plug-in developer (Harmony remote plug-in for example). Maybe you can team up with him?

IFTTT was a nice service until I went full local control. Now, local control is a priority for me for all my devices.

Good luck, @rlavista! Keep us posted.

test results failed with the following info returned:

Jan-01 10:51:58 AM

Event
Running script and waiting: &hs.URLAction(“http://192.168.1.199/v2/devices/0000006e/actions/ToggleLight”,“PUT”,"{}",“BOND-Token: xxxxxxxxxxxxxxxx”)
Jan-01 10:52:02 AM

Error
Compiling script /tmp/K3.vb: Symbol is not valid.
Jan-01 10:52:02 AM

Error
Compiling script /tmp/K3.vb: Expected ‘)’.

Don’t copy paste as there is a mix of " in there. Type it out?

does the format look right though?

tried again after another retype and no error this time!! Keep you posted to further testing

2 Likes

Yeah those different quote characters drive me nuts too!

Let me know if you find that you end up needing a GET request for calling actions. This seems to be the case for Shelly, and if it were the case also for another system we’d bump priority of a workaround.

Though Homeseer didn’t post any error in executing the command, the command didn’t work as the fan light did not respond. So if you have another method for me to try, please send it along. Thank you.

I’d recommend using cURL as Residual suggested. That way you can test the exact URL before you use it via HomeSeer

Unfortunately I am remote from the system so cURL testing is not possible for a couple of weeks. I can only test via Homeseer commands right now so if there are other format options to try please let me know.

I’ve seen some systems not need the “{}” in the body parameter.

We also have the option of putting the Bond-Token in the body vs in the header argument of the URLaction call.

HomeSeer definitely supposedly supports PUT calls so likely just needs tweaking until we find the right combination.

Here is current format, please let me know other options you would like me to try.

&hs.URLAction(“http://192.168.1.199/v2/devices/0000006e/actions/ToggleLight",“PUT”,"{}","BOND-Token: xxxxxxxxxxxxxxxx”)

I’d say first let’s try an empty data parameter vs “{}” (though I think technically that’s incorrect, I think I remember seeing an integration with some system that needed it to be just “”?)

hs.URLAction(“http://192.168.1.199/v2/devices/0000006e/actions/ToggleLight",“PUT”,"","BOND-Token: xxxxxxxxxxxxxxxx”)

Are there any logs that you can get from HomeSeer? After an HTTP request, you should either get (A) a syntax/parameter error from HS prior to the request being generated, (B) a connection timeout error because a connection could not be established from HS to Bond, © an HTTP error from Bond (HTTP status code other than 2XX), or (D) a success code from Bond (HTTP 200/204/201).

Without that feedback, its going to be like target shooting on a moonless night.

I have playing with various formats. So far this command has yielded an error. I have tried by eliminating the {} for GET and PUT and that does not produce an error. In all cases, the light does not respond.

Jan-03 4:02:06 PM

Event
Running script statement immediately: &hs.URLAction(“http://192.168.1.xxx/v2/devices/0000006e/actions/ToggleLight",“GET”,"{}","BOND-Token: xxxxxxxxxxxx”)
Jan-03 4:02:12 PM

Error
In URLAction GET: Cannot send data when method is: GET

Tried another version on the command and the following error:
Jan-03 4:07:14 PM

Event
Running script statement immediately: &hs.URLAction(“http://192.168.1.xxx/v2/devices/0000006e/actions/ToggleLight",“POST”,"{}","BOND-Token: xxxxxxxxxxxx”)
Jan-03 4:07:35 PM

Error
In URLAction POST: The remote server returned an error: (400) Bad Request.