python-ring-doorbell icon indicating copy to clipboard operation
python-ring-doorbell copied to clipboard

time data does not match format

Open jubishop opened this issue 1 year ago • 2 comments

from running the listen command, on every event i get on the command line:

Ring CLI
INFO:firebase_messaging.fcmpushclient:Registered with FCM
INFO:firebase_messaging.fcmpushclient:Succesfully logged in to MCS endpoint
Listening, press enter to cancel
 ERROR:firebase_messaging.fcmpushclient:Unexpected exception calling notification callback
Traceback (most recent call last):
  File "/Users/jubi/Library/Python/3.9/lib/python/site-packages/firebase_messaging/fcmpushclient.py", line 425, in _handle_data_message
    callback(ret_val, msg.persistent_id, obj)
  File "/Users/jubi/Library/Python/3.9/lib/python/site-packages/ring_doorbell/listen/eventlistener.py", line 250, in _on_notification
    re = self._get_ding_event(gcm_data)
  File "/Users/jubi/Library/Python/3.9/lib/python/site-packages/ring_doorbell/listen/eventlistener.py", line 207, in _get_ding_event
    datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S.%f%z")
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2024-05-14T19:29:28Z' does not match format '%Y-%m-%dT%H:%M:%S.%f%z'

jubishop avatar May 14 '24 19:05 jubishop

so at least on my machine, line 207 of eventlistener.py needs to become:

datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%SZ")

jubishop avatar May 14 '24 22:05 jubishop

sorry i'm too much of a python noob to know how to run your tests to make a proper git commit here. i just know changing that line makes it work for me. my guess is, looking at the format that was failing, that for whatever reason my device is not providing milliseconds (thus no .%f at the end of the strptime format). You could check for that using a regex and then run the right one, or put this first one in a try and then run the second in a catch (or whatever the equivalent is in python). in any case, thanks for this library! once i fixed that line, it's working great for me to listen for events and then trigger a recording with a different security camera via ZoneMinder.

jubishop avatar May 15 '24 01:05 jubishop

There hasn't been any activity on this issue recently. This issue has been automatically marked as stale because of that. It will be closed if no further activity occurs. Please make sure to update to the latest ring_doorbell version and check if that solves the issue. Thank you for your contributions.

github-actions[bot] avatar Aug 14 '24 00:08 github-actions[bot]

This is fixed by https://github.com/tchellomello/python-ring-doorbell/pull/378 which has now been released in version 0.9.0.

sdb9696 avatar Aug 22 '24 06:08 sdb9696