I had some motion on one of my cameras ~30 mins ago but look at the following:
>>> await blink.get_videos_metadata(since=str(datetime.now(timezone.utc) - timedelta(hours=1)), stop=2)
[]
>>> await blink.get_videos_metadata(since=str(datetime.now(timezone.utc) - timedelta(hours=2)), stop=2)
[]
>>> await blink.get_videos_metadata(since=str(datetime.now(timezone.utc) - timedelta(hours=3)), stop=2)
[]
>>> await blink.get_videos_metadata(since=str(datetime.now(timezone.utc) - timedelta(hours=4)), stop=2)
[]
>>> await blink.get_videos_metadata(since=str(datetime.now(timezone.utc) - timedelta(hours=5)), stop=2)
[]
>>> await blink.get_videos_metadata(since=str(datetime.now(timezone.utc) - timedelta(hours=6)), stop=2)
[{'id': 15873035115, 'created_at': '2025-11-22T14:12:13+00:00', ...
I expect timedelta of 1 hour to catch it, but it doesn't until a delta of 6 hours. My timezone is UTC - 5.
I looked at the get_videos_metadata function implementation and noticed this behavior:
>>> datetime.now(timezone.utc)
datetime.datetime(2025, 11, 22, 14, 47, 36, 693905, tzinfo=datetime.timezone.utc)
>>> util.get_time(datetime.now(timezone.utc).timestamp())
'2025-11-22T14:47:46-0500'
Those two dates should be the same but they seem different due to the UTC offset. I believe there's a TZ handling bug.
This seems to give the correct result:
dt = datetime.now(timezone.utc) - timedelta(hours=1) + datetime.now().astimezone().utcoffset()
await blink.get_videos_metadata(since=str(dt), stop=2)
As an aside, the stop parameter is confusing since the code uses for page in range(1, stop). This means stop=2 is needed for the first page.
I had some motion on one of my cameras ~30 mins ago but look at the following:
I expect
timedeltaof 1 hour to catch it, but it doesn't until a delta of 6 hours. My timezone is UTC - 5.I looked at the
get_videos_metadatafunction implementation and noticed this behavior:Those two dates should be the same but they seem different due to the UTC offset. I believe there's a TZ handling bug.
This seems to give the correct result:
As an aside, the
stopparameter is confusing since the code usesfor page in range(1, stop). This meansstop=2is needed for the first page.