Support fetch, update of device record history (Litter Box)#233
Support fetch, update of device record history (Litter Box)#233sovanyio wants to merge 30 commits into
Conversation
| mode: box | ||
| old_pet_id: | ||
| name: Old Pet ID | ||
| description: The original Pet ID that the device recorded (use "-1" or "0" if it was unknown/unrecognized). |
There was a problem hiding this comment.
This section is also missing the "-2" : I've forgotten what this "-2" means...
I'm also worried that the user won't understand what to put here, it's not very clear, and I admit I don't really know how to make it clearer.
|
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 |
|



📝 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! 🐾