Simple Http Command to control fan light

Disappointing we didn’t get randomly lucky yet.

From my view… Unfortunately I think it is best served by you being on network and utilizing curl to find / demonstrate correct setup, then trying to tweak the integration instead.

I did see some HS forum posts where the headers parameter was giving them issues so I suppose you could try the _token in the body option vs the header.

This would be the curl version on a Windows machine (note the \ escaped " signs):
curl -X PUT http://192.168.1.xxx/v2/devices/0000006e/actions/ToggleLight -d "{\"_token\": \"xxxxxxxxxxxxxxxx\"}"

and this would be something like the equivalent URLAction:
&hs.URLAction("http://192.168.1.xxx/v2/devices/0000006e/actions/ToggleLight","PUT","{""_token"": ""xxxxxxxxxxxxxxxx""}","")
(adapted from here and there)

make sure you’re using PUT not POST. I’ve seen you reference both. :slight_smile:

tried this format, no error but no response from the light either. The host machine that Homeseer runs on is Linux - HomeTroller Zee S2 (basically a PI device).

Do you have VNC access to the Linux shell?

I have used PuTTY to access it remotely

Maybe you can use curl via a PuTTY session

If you can somehow get the body of the HTTP 400 reply, Bond sends a human-readable error message telling you exactly what is wrong with the request :slight_smile:

I also polled the device using the following command to make sure the action was supported. Here is the output:

curl -H “BOND-Token: xxxxxxxxxxxxxxxxxx” -i http://192.168.1.xxx/v2/devices/0000006e

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

{“name”:“Sitting Room Fan”,“type”:“CF”,“location”:“Lounge”,“actions”:[“TurnOff”,“SetSpeed”,“ToggleLight”,“Stop”,“TogglePower”,“TurnOn”,“IncreaseSpeed”,“DecreaseSpeed”,“TurnLightOn”,“TurnLightOff”],"":“f0dcbf8a”,“commands”:{"":“8a731537”},“state”:{"":“aae5c0df”},“properties”:{"":“5a4f828a”}}

1 Like

So I have remotely access the Linux system and can execute CURL commands with the following results but the light did not turn on.

homeseer@HomeTrollerZeeS2 ~ $ curl -H “BOND-Token: xxxxxxxxxxxxx” -i http://192.168.1.xxx/v2/devices/0000006e/actions/ToggleLight
HTTP/1.1 200 OK
Content-Length: 48
Content-Type: application/json; charset=utf-8

{“power”:0,“speed”:2,“light”:0,"_":“2db616ba”}

What now?

try this:
curl -H “BOND-Token: xxxxxxxxxxxxx” -X PUT -i http://192.168.1.xxx/v2/devices/0000006e/actions/ToggleLight -d {}
(also note to self, remember to get the case correct on the commands when you’re trying to help people. :slight_smile: )

That’s confirming things are working on the API level / your devices / commands. Thanks for providing that confirmation.
Since you don’t have to change the action via -X parameter with those “list devices” / “list actions” curl commands, they are a little more simple, and a good way to verify things.

Here is error I get

curl: (5) Couldn’t resolve proxy ‘PUT’
curl: (5) Couldn’t resolve proxy ‘PUT’

SO SORRY! Bad typing on my part. Case sensitive.

-X instead of -x

Tried the -X version with the following error:

curl: (6) Couldn’t resolve host ‘xxxxxxxxxxxxxxx”’
HTTP/1.1 401 Unauthorized
Content-Length: 0

can you copy paste the entire curl command string, or compare directly with mine below?

This is what is working via both my Raspberry Pi and my Windows computer:

curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -X PUT -i http://192.168.1.xxx/v2/devices/0000006e/actions/ToggleLight -d {}

did a cut and paste (filling in the xxxxx with appropriate info) and now I just get the following:
HTTP/1.1 401 Unauthorized
Content-Length: 0

Okay, I myself am trying now via PuTTY instead of remoted in via VNC.

UPDATE: Was able to execute with the same copy-pasted command in PuTTY.

Can you confirm in the BOND app that the token is still the same? I think I saw one other user had issues with the token changing once on them / a reboot of the BOND Bridge and using the new token resolved their issues (even though the token isn’t supposed to randomly change and mine never have without a full reset).
I am able to replicate your issue only by intentionally using an incorrect token.

I shutdown my putty session and started a new one and the command worked!!!

Now can we translate that into a homeseer URL command :slight_smile:

1 Like

We are now entering the “I don’t know this system so I dig through forums only” realm…

Some posts indicate the URLAction doesn’t actually send PUT actions even though it should and is documented as an option?

other posts say to use Big5 plugin to get more robust HS3 options?

The documentation for HS3’s implementation of PUT seems a little weird to me:

PUT
(Replaces [puts] a file at the URL)

dim s
dim sPage
dim sHead

sPage = (routine to read a file into the variable sPage)

s = hs.URLAction("http://someserver.com/putithere/putit.htm", "PUT", sPage, "")

Check out a script someone created for Bond - its all gibberish to me as I am not a programmer but maybe you can pull useful info out of it

1 Like