PETLIBRO Cloud integration (non Tuya !) WIP

Have mitm working with petlibro + ios - so I can provide logs from that if you need.
Would really like to see manual feeding made available, but I don’t know enough of HA to make an extension yet :slight_smile:
I’ve dropped you the manual feeding info via chat.

Hey, ive been trying to read the packets from app to api and vice versa. But its encrypted via tls.1.3 how did you go about unencrypting the data?

The way I did it with iOS was using

This allows me to mitm anything coming out of my phone

Thanks for the link. I tried to do something like this with an emulated android device, and using a programme called fidler but newer android apps seem to have to specifically allow CA Certificates, otherwise it doesnt work…

Looks like i may need to edit the apk itself on android to get it working.

Thanks again anyway :slight_smile:

Hey Mezzle, before adding this extension I was trying to get the API to use the “feed now” feature in a “HTTP switch” like this user did with another brand of cat feeder Any chance your manual feeding info would work with this method? (would you mind sharing it with me too?) I cant wait to have the feeding now option on HA too. Thank you

I’ve started building the ability into the addon (and learning enough of HA’s code to do so!).

Here’s the call:-

POST /device/device/manualFeeding HTTP/1.1
source: IOS
language: EN
timezone: Europe/London
version: 1.3.62
accept-encoding: gzip
content-length: 92
host: api.us.petlibro.com
content-type: application/json; charset=utf-8
token: redacted

{"deviceSn":"SERIALNUMBER","grainNum":1,"requestId":"50ef5fdf9c8146bdba873934b1041200"}

HTTP/1.1 200 OK
Server: nginx/1.22.1
Date: Mon, 26 Aug 2024 00:15:42 GMT
Content-Type: application/json;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers

26
{"code":0,"msg":"Feeding...","data":3}
0

I believe that requestId is just a random MD5 to try and provide idempotency (if for whatever reason the request goes through multiple times, it’ll only feed once)
the grainNum is the “amount” - in 1/12th cup increments (or whatever equivalent you’ve set it to). The smallest amount you see on the manual feeding button is “1” - multiply it to get more :slight_smile:

You’ll need to use the token provided by logging in first - which will be the difficult bit.

also, make sure you set deviceSn to the right device!

2 Likes

Thank you so much! thanks to you I was able to make a Siri Shortcut and now I just press a philips hue button and it feeds my cat ( no more holding 5sec to unlock the feeder or opening petlibro app).

2 Likes

Would you be willing to share more api call urls?

Just realized I have the Tuya version, sooo. I applaud the efforts but won’t be able to help after all.

i have made a great start on adding support for PLAF301 i feel in my fork of this. of course i am certain there is a bunch of changes to the structure of things that you want to do @flifloo this is my first time coding in python, so i am sorry if things are a bit messy.
here are the current sensors and controls:

if someone wants to test to see how it works for them, try and use my fork. let me know what you think.

keep in mind that i will be itterating a lot - so i cant guarantee that everything will be working as you download it.

what i will be working on next is trying to implement control over the individual scheduled daily feedings.
i am also going to try and convert the manual feed switch into a button entity instead, as that is probably more appropriate.

3 Likes

I also bought a Petlibro feeder, the PLAF203S specifically, a few weeks ago and was surprised that my model differs from the old PLAF203 (non S variants) that support local tuya.

I have been following this thread and the other one about the petlibro feeders (PetLibro cat feeder) which also provided valuable information to support my own reverse engineering efforts.

My personal goal was to have the device running locally with the feeding features and not having to communicate with Petlibro’s platform at all.

I published my findings including a working AppDaemon python integration on my github: https://github.com/icex2/plaf203

Some key highlights:

  • Local integration using AppDaemon
  • Communicate with feeder using its default MQTT protocol
  • (Nearly) fully reverse engineered application level messaging protocol on top of MQTT
  • Kinda “everything” works except for the video and audio streaming because it uses a 3rd party SaaS platform

Please take some time and have a thorough read of the readme I provided.

2 Likes

I’m thinking of getting the plaf103 which is how I stumbled across this thread. Based on the conversation so far, is it correct to assume that all the calls to make this work with HASS are still being routed out to Petlibro’s servers?

Thanks!

Unfortunately, for the newer models yes. I believe there is someone who’s got into another device, which may provide some information - but for now, we only know that the device communicates to an MQTT server, which is controlled by the API - I know there are people out there trying to get into this though

1 Like

I just got the water fountain as a gift. I was excited for integrate into TUYA but now I’m seeing that there is a HACS options.
But after install and config, I don’t see my water fountain yet.
if I can provide any assistance or help, please let me know

I have both the PLWF105 water fountain and the PLAF103 granary feeder. I’m also available to help test and give feedback.