sure_petcare icon indicating copy to clipboard operation
sure_petcare copied to clipboard

Read and write?

Open freekeys opened this issue 6 years ago • 7 comments

Hi, this looks awesome! Does this allow you to set the state (eg locked / unlocked) or just read the state? Thanks :)

freekeys avatar Jun 02 '18 17:06 freekeys

Read only at the moment, shouldn't be hard to implement, but not on my list of priorities at the moment.

rcastberg avatar Jun 02 '18 20:06 rcastberg

I would love to have "hey google, let the dogs in". What would it take to get the ability to lock and unlock the door via api?

minusreality avatar Sep 29 '18 17:09 minusreality

I've got 3 dogs, and I would love to be able to have something like "let the dogs in" via the API

mctom987 avatar Sep 29 '18 20:09 mctom987

It shouldn't be too hard, i haven't had any need for this so haven't worked on it, and haven't had much time to work on the code.

Patches are welcome.

rcastberg avatar Sep 30 '18 18:09 rcastberg

I don't yet know python, but here is an allegedly working example of changing the door lock configuration in PHP: https://github.com/alextoft/sureflap

minusreality avatar Oct 10 '18 20:10 minusreality

Here is how it's being done by alextoft in PHP:

it's an HTTP PUT to

$endpoint/api/device/PET_FLAP_ID/control 

containing the following json:

$json = { locking: $lock }

possible values for $lock:

0 = none (unlocked)
1 = out
2 = in
3 = both

and the following header:

Content-Type: application/json
Content-Length: strlen($json)
Authorization: Bearer $token

and the response will be

{ data: { locking: "0-3 lock value" }}

minusreality avatar Oct 10 '18 20:10 minusreality

This Issue has attracted some attention, including on reddit.

Demands on my and René's time are such that neither of us are likely to add write support to the API in any case but, even if I did have the time, I don't want to be responsible for causing trouble for Sure Petcare or for users of this API by fouling up their accounts by making inappropriate state-altering API calls.

Moreover, I don't want to encourage API users to jeopardise their accounts with Sure by putting excessive load on their infrastructure (which is why I added aggressive caching logic). Further still and last I knew, Sure Petcare was not yet ready to open up their API to the public. They've made it clear to me that use of this API is contrary to terms and conditions.

If and when that changes, I hope Sure Petcare will reach out to the open source community for development of bindings for their public API. I'll be happy to help as and when I can. They know how to get in touch with me.

Meanwhile, tread carefully and be responsible.

strix-technica avatar Nov 03 '18 13:11 strix-technica