We’re working on support for several technologies of 2-way motors. The motors sometimes take a while to respond, so we cannot wait for their reply before responding to the API client’s action request. So, we are thinking of doing the following:
- Client makes the action request as usual:
curl -iH "Bond-Token: xxx" bondip/v2/devices/x/actions/Open -x PUT -d {}
- Today, the reply you get is:
HTTP/1.1 200 OK
Connection: close
BOND-Flags: 132
Content-Length: 34
Content-Type: application/json; charset=utf-8
{"_":"00000000","__":"00000000"}
I’m proposing that—only for devices that support 2-way communication—you get:
HTTP/1.1 200 OK
Connection: close
BOND-Flags: 132
BOND-UUID: aabbccdd11223344
Content-Length: 34
Content-Type: application/json; charset=utf-8
{"_":"00000000","__":"00000000", "_status": "pend"}
And then you can get updated action status by either listening on BPUP (or MQTT for the Bond Home app), or by polling the same HTTP endpoint but using the specified request ID:
curl -iH "Bond-Token: xxx" -H "BOND-UUID: aabbccdd11223344" bondip/v2/devices/x/actions/Open -x PUT -d {}
If you choose to poll, an interval of 300 ms is recommended, with a 7 sec timeout. Note that these subsequent requests do not generate new RF signals because the Bridge caches the request by UUID and will not take action twice for the same UUID. It’s just a way to get an update on the request.
The values for _status
are:
pend
— request is waiting to be sent by the Bridgesent
— request has been sent to the device, waiting for a replyack
— request has been acknowledged by the devicenack
— device rejected the request for some reasontimeout
— Bridge did not get a reply from the device in the allotted time window, but the request may have been received (technology specific, but never more than 7 seconds)fatal
— many attempts were made to communicate with the device, but they have all failed
Our intention with this is two-fold:
-
Not to break any existing implementation. (For this reason we avoid using
202 Accepted
as we had previously proposed.) -
To allow all UIs to show a happy indicator to a user when we get
ack
. Note that we expect there to be many cases where the uplink is not as reliable as the downlink, so we recommend against showing a user-facing error for everytimeout
, only showing an error onfatal
andnack
status.
We will also usually have a signal strength reading, and battery feedback if applicable, but those are just normal fields on the API. The above is the tricky part for us to get right. Your feedback is appreciated.