API questions and issues

But this gets me back to my original problem. I get a bunch of actions, for my fan I get DecreaseSpeed, IncreaseSpeed, SetSpeed, Stop, ToggleLight, TogglePower, TurnLightOff, TurnLight On, TurnOff and TurnOn. But some of them (TurnOn, TogglePower (only if the fan is off, works if the fan is on) and IncreaseSpeed) give me a System.Net.Webexception with a error message of (400) Bad Request.

That’s why I switched to commands, at least they seem to work consistently. I’d be glad to help you troubleshoot this, if you let me know what you need.

Across so many platforms / OS / code or script languages - all of them work with Actions for me, and others.

I’d go one by one with curl on the command line and identify for each Action that isn’t working for you if it works with curl and maybe is something VB.Net specifically that isn’t playing nice.
Some while back, people using Postman were having issues but we were able to identify and rectify.

If you want, let’s start with TurnOff. It, like many actions, needs to be called with a PUT and an empty payload:

curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -X PUT -i http://192.168.y.z/v2/devices/aaaaaaaa/actions/TurnOff -d {}

HTTP/1.1 200 OK
Content-Length: 18
Content-Type: application/json; charset=utf-8

{"_":"c518e0b2"}

or if using a VB / COM object:

PUT: 200|{"_":"c518e0b2"}

Now, it’s absolutely true if I do not PUT it, I can get a 404 (except somehow if I do it with a VB / COM object instead of curl, it seems like a get a 204):

curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.y.z/v2/devices/aaaaaaaa/actions/TurnOff -d {}

HTTP/1.1 404 Not Found
Content-Length: 0

GET: 204|

Or if i PUT it via curl, but without the empty payload, I can get an error:

curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.y.z/v2/devices/aaaaaaaa/actions/TurnOff 

curl: (52) Empty reply from server

It also errors out, but as a COM object error, if attempting to PUT via VB / COM object with an empty payload:

COM Error intercepted !
	err.number is: 		0x80020009 / -2147352567
	err.windescription:	Exception occurred.

	err.description is: 	The server returned an invalid or unrecognized response

	err.source is: 		WinHttp.WinHttpRequest
	err.retcode is: 	0x80072F78

I tried curl -H "BOND-Token: " -X PUT -i http://<IP Address>/v2/devices/2c9dd1bf/actions/TurnOn -d {} and I get a 400 Bad Request, while if I use TurnOff, it succeeds.

The response I get from Devices/ is:

{“name”:“Computer”,“type”:“CF”,“location”:“Office”,“actions”:[“DecreaseSpeed”,“IncreaseSpeed”,“ToggleLight”,“TurnOff”,“Stop”,“TogglePower”,“TurnOn”,“SetSpeed”,“TurnLightOn”,“TurnLightOff”],"":“ac02ae93”,“commands”:{"":“a0778620”},“state”:{"":“4742ff45”},“properties”:{"":“7a3d5cfe”},“skeds”:{"_":“c0441b96”}}

So the TurnOn action is listed.

Also of interest is the SetSpeed action, which I would think would need a parm, but I don’t see a way to tell that from the return above.

See the documentation here and here.

What changed between this:

and this?


(works for me, which doesn’t help you per se:

curl -H "BOND-Token: xxxxxxxxxxxxxxx" -X PUT -i http://192.168.y.z/v2/devices/aaaaaaaa/actions/TurnOff -d {}
HTTP/1.1 200 OK
Content-Length: 18
Content-Type: application/json; charset=utf-8

{"_":"c518e0b2"}

curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -X PUT -i http://192.168.y.z/v2/devices/aaaaaaaa/actions/TurnOn -d {}
HTTP/1.1 200 OK
Content-Length: 18
Content-Type: application/json; charset=utf-8

{"_":"95b58423"}

)

Nothing, if you look at the most recent email, it’s TurnOn that fails, TurnOff still works.

I kind of hate to have the code check for certain actions that require different handling. It would be nice when all the actions are returned in devices/ that it specified which actions require parameters. But I’ll just special case SetSpeed if that’s what is required.

Ah, so the posts above (I quoted post #5 but there are a couple), where you said TurnOff wasn’t working, you meant TurnOn was the one returning a 400 or a 404?
Today you’re saying TurnOff is, and has been, working - rather, it’s TurnOn is the one that hasn’t, and still doesn’t, work?


I don’t think the Bond team’s intent was for the entire API to be self-discoverable via queries. It can get you close, but programmers / integrators will still need to review the documentation (like you and I and others are doing) and handle different actions / devices / SBB vs Bridge / etc in different ways.

Another question, when I use the Bond Android App, the only “actions” I see are Toggle Light, Power Off, Increase Speed and Decrease Speed, which are the commands. So it looks like the Bond Android app is using commands not actions (which is what I have my app set up to do as well).

If it can help:
More than willing to test your app with my setup, since it’s a known scenario for me across multiple integrations and platforms.
We could test to see if an Actions version vs a Commands version has any functional difference in my home.

OK, do you want me to just send you the exe, or the exe and the source or …

Yes, that is correct, it is TurnOn that isn’t working.

And I can add debugging statements about what messages are being sent, if that’s helpful.

Sounds good - I know you mentioned a debug file is able to be generated to show the HTTP command history.

FYI - sent you a PM.

Did you get a chance to look at the app and figure out anything about why some actions aren’t working for me?

Did I miss a PM reply or email? I haven’t seen the reply / attachment come through anywhere.

Wanted to check and make sure you got the message from this morning.

I don’t have any PM from you, nor any email that I can see. Did you just reply to the PM here in the forum?