trigger logs doesn't retrieve all logs
Closed this issue · 6 comments
Hi, I am trying to get the logs from a T100 device using the example in the H100 in the rust app and I get them but I don't get them all. Is there a maximum number of logs that can be retrieved?
I have modify the code so the call is:
let trigger_logs = t100.get_trigger_logs(5000, 0).await?;
I only have like 1400 logs registered so it should retrieve them all rather than only 907.
Is there a way to get them all?
Thanks for this, it is quite useful!
I'm not sure, as I haven't had a device with so many logs.
Can you please try with a page_size
of, say, 500 and then fetch the subsequent pages by providing the oldest (should be the last) id
as start_id
?
Hi, I have tried different things but I think the issue is like the API is not returning certain info as it grows or as time passes?
I have done a test today and I have retrieved the logs from 1603 to 725, then I try to retrieve 3 logs starting on id 725 and I get only one, the number 725.
I can't find anything on the internet any guidance to where could I find any more info would be much appreciated.
All the best,
Sorry for having taken so long to reply.
Can you please paste the output of
let mut cont = true;
let mut start_id = 0;
while cont {
let trigger_logs = t110.get_trigger_logs(100, start_id).await?;
println!("start id {:?}", trigger_logs.start_id);
println!("sum {:?}", trigger_logs.sum);
println!("len {:?}", trigger_logs.logs.len());
let last_log = trigger_logs.logs.last().unwrap();
start_id = match last_log {
T110Log::Close { id, timestamp } => {
println!("{timestamp}");
*id
}
T110Log::Open { id, timestamp } => {
println!("{timestamp}");
*id
}
T110Log::KeepOpen { id, timestamp } => {
println!("{timestamp}");
*id
}
};
println!("next start id {:?}", start_id);
cont = trigger_logs.logs.len() > 1;
}
In my tests, logs disappear after about 250 days.
It's most likely related to the age of the logs rather than their number.
My devices return the right number as sum
, so I'm not sure why yours isn't. Is it permanently connected to the internet and the Tapo app?
What's the timestamp of the oldest log you're able to retrieve?
Hi thanks a lot for replying,
I am sorry as well it took too long but I was working on another project and had to park this for some time.
After a long time without using the sensor I have plugged the hub again and connected to the T100 sensor and I could retrieve manually my logs from id 1728 (which was today) to 1229 that was on July 9th 2024. Then I set the sensor to be triggered every 4seconds and after an hour and a half I can retrieve only from log number 1904 to log 1029 which is July 10th. I cannot access any earlier log. I have checked in the app and in the app it is even worse, it doesn't go back further than October 9th. (today is November 8th).
I think in order to avoid losing data I will have to make some sort of service that runs the code every certain time and keep the logs somewhere safe so they are not lost when it generate new ones.
thanks for your help!
Thanks for the update.
Your experience is the same as mine, then. After a certain point, new logs start pushing older logs out.
Yes, running a script at intervals like hourly or daily will help you get around this limitation.