Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pet litter usage record missing #3

Merged
merged 1 commit into from
Feb 23, 2025
Merged

Conversation

tete1030
Copy link
Contributor

My pets' litterbox usage data is missing. After fixing this, it works again.

@tete1030 tete1030 requested a review from Jezza34000 as a code owner February 22, 2025 20:04
@Jezza34000
Copy link
Owner

Hi @tete1030,
Thank you for you PR
What is you litter box ?
What kind of data was missing ?

@tete1030
Copy link
Contributor Author

My device is Pura Max. Integration version 1.9.0. The data missing was each pet's last_use_duration, last_litter_usage and last weight. The commit was based on analysis of code types, data_records of Litter type should be typed LitterRecord and also the fields used in the code are presented only in LitterRecord.

@tete1030
Copy link
Contributor Author

tete1030 commented Feb 23, 2025

Before upgrading to 1.9.0, my integration version was 1.7.0, which works mostly well. From dependency I think the pypetkitapi version was 1.11.3.

By 'mostly well` I would like to bring up with you another issue I'm currently investigating, not directly relevant to current issue I believe, because it has being a problem occasionally since early versions (Dec, 2024). I will open another PR when I found the root cause.

The old problem is, one of my two cats is missing the field last_use_date for the whole reboot cycle every 3 or 4 cycles. My reboot cycle is to restart home assistant every day for doing backups. Only one specific cat's last_use_date field is missing, other fields like last_use_duration or the other cat's data is perfectly well.

CleanShot 2025-02-23 at 11 32 47@2x

@Jezza34000
Copy link
Owner

OK indeed you are right, my isinstance was not checking the correct dataclass. Thank you for this.
For the second subject that you raise, the problem is :
The way in which the information is obtained means that if during the current day the cat has not yet gone into the litter box, I have no information. I tried to solve this by using the "restore" function of HomeAssitant but it did not work correctly. I will check it again

Last point I wanted to thank you for your donation, These donations are very important to maintain motivation. 👍

@Jezza34000 Jezza34000 merged commit 38c5a1f into Jezza34000:main Feb 23, 2025
1 of 2 checks passed
@Jezza34000
Copy link
Owner

@tete1030
Copy link
Contributor Author

tete1030 commented Feb 23, 2025

Glad I can help. Keep up the good work!

On the second issue I want to clarify that it's not about the empty data when pet has not use it yet since reboot.

The above screenshot shows data of the same pet in the same time range. You can see at around 11am both last_use_duration and last_weight_measurement had been updated, while last_use_date kept empty until the next reboot. From the code, it looks like the three values are updated together. The only reason I gather responsible for last_use_date being empty is stat.timestamp being constantly None.

Anyway, I'm adding logs to verify this assumption. will get back to you later.

Edit:
By last_use_date I mean last_litter_usage
And last_weight_measurement is actually last_measured_weight in the code
And last_use_duration => last_duration_usage

@tete1030
Copy link
Contributor Author

I might have found the problem

Issue: Jezza34000/homeassistant_petkit#35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants