Support fetch, update of device record history (Litter Box)#233
Support fetch, update of device record history (Litter Box)#233sovanyio wants to merge 38 commits into
Conversation
|
Hey @sovanyio, great idea thanks for your contribution I took the time to do a full code review and left some comments with a few things worth fixing before merging. Nothing major, mostly code quality and one small bug in the Polish translation. Feel free to reach out if you want to discuss any of the points above |
… leave up to user automation, rename record update to reflect litter box context, get latest record by correct type instead of only most recent, pr comments
for more information, see https://pre-commit.ci
|
Pushed most of those changes, working on the blueprint but not going to finish that one today. Much cleaner: Jezza34000/py-petkit-api#75 :) |
… mqtt setting of helpers
… mqtt triggers, parallel run mode
for more information, see https://pre-commit.ci
|
@Jezza34000 blueprint added, tested the correction half, will update tomorrow for verification on the mqtt trigger for it--my cats aren't playing along tonight |
|
Hi, thanks for submitting the changes. I'm away from home for a few days, I'll look at it early next week. |
…han history update trigger
|
FYI I think my combined blueprint might need some more work on the frigate mqtt trigger--will let you know when that's ironed. |
|
Blueprint is ready to go |
|
Hi @sovanyio |
|
|
Hi @sovanyio , I’m getting back to you regarding that PR. |
|
I only have the one litterbox with two cats currently, but I had some changes to the blueprints (will probably just remove these and post them as gists, or something)--so I can explore this. I've not noticed any slowdowns but I'm running fairly recent hardware so maybe just haven't noticed. |
for more information, see https://pre-commit.ci
|
Updated with cacheing for the serialization concern, removed the blueprint, and added an event dispatch to easily push records to long term storage. I ended up modding my litterbox to get the camera inside (so I could also get eyes on what they were doing for health..) so the og blueprint I had here wasn't useful to me anymore, saved it here if anyone wants it: https://gist.github.com/sovanyio/92697be7361ab7d2e83143dcc1e3b619 Hoping to get to similar automation parity in the future, but need to do some frigate+ training since the cats are now most of the video frames (or get a new camera)--default models aren't catching the Cat main object right now so I have moved to this flow:
Automation: https://gist.github.com/sovanyio/3c68b7820beeabe7152e923f1a6b3c79 |
|



📝 Proposed Change / Description
This PR adds support for fetching a litter box's device record state as well as update it if incorrect.
I have 2 cats with pretty similar weights so Petkit often fails to properly identify them and I would otherwise like to have their (correct) weight trends and usage easily seen in HA, without the manual daily checking and correction that I often don't do through the stock app. Basically a DIY implementation of the "ai" camera on the more expensive models, when combined with Frigate and custom model classification.
I have this working locally along with a Frigate automation that checks for agreement of the Petkit record guess with Frigate's classification and updates Petkit's api (including weight, similar to the app). Otherwise useful for folks that find the log useful as a general monitoring tool and want to have the info centralized and not have to touch that bloated app trying to sell you more stuff.
I wasn't sure what the weight threshold was for the app to trigger the weight update/confirmation prompt so this currently has a hardcoded check to see if it is off by 500g and then updates if so. Definitely room to improve this or implement differently, if anyone happens to know what the app is doing from the decompilation--this was based on my sniffing of the app traffic. Perhaps having a HA-notification asking for update confirmation before doing it when there is weight disagreement, but I'm not really sure when an incorrect record update would be wanted without updating the weight associated.
The frigate detection and correction automation uses two helpers:
input_text.last_cat_seen_on_cat_camerainput_datetime.time_cat_seen_on_cat_camerafrigate detection automation
🔖 Type of change
🐾 Affected devices
Specific type:
Specific category :
If your device is not listed, please specify it here:
🧪 How has this been tested?
Device(s) tested on:
PetKit Pura Max 2
Other devices you own when the test was done:
✅ Checklist
pre-commit run -ahooks and all checks passmain📸 Screenshots / Logs (optional)
Today's weights aren't that close, but they usually are!
log table
ℹ️ Additional context
Description of changes:
Thanks for the helping paw! 🐾