SecKatie / wyzeapy

36 stars 26 forks source link

Wyzeapy time related code not transportable and get_event_list possibly have a design flaw #4

Closed faanskit closed 3 years ago

faanskit commented 3 years ago

Issue 1 In get_event_list() in base_client.py, the following time functions is used:

"begin_time": int(str(datetime.date.today().strftime("%s")) + "000"),

strftime("%s") is not supported on Windows. For more info what is supported for strftime(), see this link.

This results in the following error on Windows:

Traceback (most recent call last):

  File "C:\Users\-\AppData\Local\Programs\Python\Python39\lib\site-packages\wyzeapy\client.py", line 237, in get_latest_event
    raw_events = self.client.get_event_list(device, 10)['data']['event_list']
  File "C:\Users\-\AppData\Local\Programs\Python\Python39\lib\site-packages\wyzeapy\base_client.py", line 432, in get_event_list
    "begin_time": int(str(datetime.date.today().strftime("%s")) + "000"),

ValueError: Invalid format string

Issue 2 This method also has a built in flaw. Possible number of events differs depending of time-of-day. 1am will only provide 1hrs of possible hits, but 11pm will provide 23hrs of possible hits.

Propose to change to a function relative to now. Suppose 2hrs x 60 minutes x 60 seconds should be enough. "begin_time": int(str(int(time.time() - (2 * 60 * 60))) + "000"),

This should fix both issue as time.time() is transportable, and the function now works as intended (?)

SecKatie commented 3 years ago

Worth fixing. Can we separate the fix for this issue from the addition of Wyze Sensor v1?

faanskit commented 3 years ago

Sure, can I also add "2" to this list? Captures also sound events from cameras.

        "event_value_list": [
            "1",
            "2",
            "13",
            "10",
            "12"
SecKatie commented 3 years ago

Do we want sound? For the cameras I think users would only want the device to trigger on motion.

That is the understanding of the feature right now.

faanskit commented 3 years ago

Well, if you don't want sound events - you disable them in the Wyze app.

In my system, motion triggers a lot of false positives so I had to reduce sensibility. But sound has worked well for me. Captured a few birds striking the window with sound detection.

Then there are of course other events that at least I would want to capture. Like fire-alarm, etc.. But I don't know how these are signalled.

My preference would be to send event_value_list: [] to catch all.

SecKatie commented 3 years ago

Ok, lets see if we can get feedback from some other stakeholders. Maybe this needs to be configurable in some way. I am not sure how that would be implemented but depending on what the other community members think we can consider our options.