Local API - how to TurnOn/TurnOff fan

I am trying to write a script in homebridge to integrate my Bond Bridge to Homekit. There is one already on GitHub but I received no support from the author, as such, I am trying to write a simple one for my own use.

The Bond Local API documentation has been very useful and it has an example of how to set the speed and is working great:

curl -H "BOND-Token: f074b61f628018fd" -i http://192.100.0.61/v2/devices/79135791/actions/SetSpeed -X PUT -d "{\"argument\": 3}"

But I run into issue trying to use the same format to TurnOn/TurnOff the fan. I used the following command in a attempt to TurnOff the fan:

curl -H "BOND-Token: f074b61f628018fd" -i http://192.100.0.61/v2/devices/79135791/actions/TurnOff -X PUT -d "{\"argument\": 1}"

but it gave me the following error:

HTTP/1.1 400 Bad Request
Content-Length: 45

Content-Type: application/json; charset=utf-8
{"_error_id":7,"_error_msg":“bad argument”}

What have I done wrong? Anyone has any clue?

TurnOff command does not take an argument.

curl -H "BOND-Token: f074b61f628018fd" -i http://192.100.0.61/v2/devices/79135791/actions/TurnOff -X PUT -d "{}"
2 Likes

Thanks so much Joe! That cleared one hurdle for me to complete my script in Homebridge to control my Hunter Pacific fan using my Homekit.

I am now trying to script in my timer and I need some guidance for that again because I got an error when I use the following command to set 1 hour timer:

curl -H "BOND-Token: f074b61f628018fd" -i http://192.100.0.61/v2/devices/79135791/actions/SetTimer -X PUT -d "{\"argument\": 1}"

It gave me the follow errors:

HTTP/1.1 400 Bad Request
Content-Length: 54
Content-Type: application/json; charset=utf-8

{"_error_id":61,"_error_msg":“action not supported”}

SetTimer is one of the listed actions I can use.

Please help.

Hey @uswong !

I’m one of the Bond developers and will try to help you.

Having in mind that SetTimer is listed in the response of a GET in the actions endpoint, I assume that the only issue is the \ before the ".
Have you tried the command without the backslash?

I can debug deeper if you want me to, but would need you to send me your Bond and Device IDs.

Hi @endy, the \ before the " is required as the " is needed around the argument. In any case I did try it without the \ before the "

curl -H "BOND-Token: f074b61f628018fd" -i http://192.100.0.61/v2/devices/79135791/actions/SetTimer -X PUT -d "{"argument": 1}"

and it gave the following error:

HTTP/1.1 400 Bad Request
Content-Length: 50
Content-Type: application/json; charset=utf-8

{"_error_id":23,"_error_msg":“json parse error”}

you mentioned that SetTimer is a GET in the actions endpoint, would you be able to give an example of how to use it?

And also how to extract the information from Bond Bridge the timer I have set?

The following command does not give me any information of on my timer. It only give me the power and speed.

curl -H "BOND-Token: f074b61f628018fd" -i http://192.100.0.61/v2/devices/79135791/state

My Bond ID is ZZEJ51347.

Hey @uswong

Thanks for the additional info!

I created a testing/example Ceiling Fan over here. Didn’t use any of the suggested templates, so it is what we call a Raw Recorded device (believe that it is your case too since you didn’t mention any template).

Recorded only the “Timers” buttons (Timer Off, Timer 1h, Timer 2h, Timer 3h).
When performing a GET in the actions endpoint I can see the SetTimer action:

curl -H "BOND-Token:<TOKEN>" -i <IP>/v2/devices/<DEVICE ID>/actions -X GET -d '{}'
HTTP/1.1 200 OK
BOND-Flags: 4
Content-Length: 170
Content-Type: application/json; charset=utf-8

{"_":"510dde81","__":"00000000","SetTimer":{"_":"00000204"},"Stop":{"_":"00000204"}}

I got a success transmission using the following CURL command.
Good to point out that the only accepted argument values are the recorded ones: 3600 for 1h, 7200 for 2h, and 10800 for 3h. Argument 1 gave me the error 61 (action not supported) you were facing before.

curl -H "BOND-Token: <TOKEN>" -i <IP>/v2/devices/<DEVICE ID>/actions/SetTimer -X PUT -d '{"argument":3600}'
HTTP/1.1 200 OK
BOND-Flags: 132
Content-Length: 50
Content-Type: application/json; charset=utf-8

{"argument":3600,"_":"00000204","__":"00000204"}

So I recommend you to check your device’s recorded commands and record the timers buttons if missing.


About how to extract the information from Bond Bridge the timer set:
I don’t know a way of getting it from the Bridge right now. You may need to create a timer and keep tracking of it on your end.

May worth mentioning that we have plans to support “timer for all devices”, where the state endpoint shall include the timer info, but we don’t have a timeframe for it right now.
The only devices that does include timer on the state endpoint are Smart by Bond devices, that comes smart (with Bond) straight from the box.

2 Likes

So @endy , you’re saying for SetTimer actions on recorded fans, the Bond Bridge would only support immediately sending a timer (X hours or N minutes) command that had been recorded from the original remote, right?

And if the original remote had only commands for certain X hours or N minutes, those are the only timer values supported (once converted to seconds)?

If the original remote had no timer commands, no valid values would exist for the Bond Bridge to send to the corresponding command.

For any Smart by Bond fans purchased with a built-in Bond-capable receiver and remote, the Bridge wouldn’t be used, but those kinds of devices could have any arbitrary minutes value NN used as the parameter to send the Fan Off command in NN minutes?

1 Like

Thanks @endy. I am using Hunter Pacific LOGIC remote and there is no template for that within Bond Bridge. As such all the my devices are raw recorded device.

Hunter Pacific LOGIC remote control is a very comprehensive remote control. It has 4 speeds fan with 7 levels dimmable LED light. And it allows 1hr, 2hr, 3hr and 6 hr timer for the fan and for the light separately. Please click this link for more info on this remote control - LOGIC remote control.

It would be really wonderful if you guys would be considering putting this fantastic remote control as one of your templates?

The SetTimer command now works for me as long as I use the unit seconds rather than hours in the argument but the issue of not able to GET which timer I have set is an issue for my Homebridge script.

My work around now is to create another Celling Fan raw recorded device as a proxy for my Timer. I recorded my 1hr, 2hr, 3hr and 6hr timer as speed 1, 2, 3 and 6, and I use programming logic in my Homebridge script to associate this proxy Timer device with the Fan device. This is of course not very intuitive but it works fine for now. I am eagerly awaiting Olibra/Bond to make Bond Bridge to fully support the Timer function.

1 Like

@residualimages that’s correct!

For Smart by Bond fans you can set any amount of seconds.

The idea is to expand this functionality to every device (including bridged ones)

1 Like

Good to know that you got it working (with a bit of workaround) @uswong .

Sent you a private message asking for more info about the remote so we can try to create a template for it.