Closed NickWaterton closed 4 years ago
Thanks for the good work! I've been wanting to change HomeAssistant's amcrest integration to use this feature for its motion detection binary sensor (as opposed to polling), but never got around to it. This is a great start!
I've played around with your code a bit and I think I have some good improvement suggestions. I'll provide those as part of a review I'll start now.
Also, this new method should be in event.py
instead of special.py
. I'm going to close this PR, but I'm going to take your great start and create a new PR. I'll give you a chance to review it before I merge it.
Added a new method
get_event_stream(eventcode='VideoMotion', callback, timeout)
Default eventcode is
VideoMotion
, this is a string and can be a comma separated list of event codes (no spaces allowed).callback
is optional, and is intended for when this method is used in aThread
(the best way to use it). The method will never return (unless there is an error or timeout) if callback is given. The events (string) are passed as the first argument tocallback
.timeout
is optional, and is a standardrequests
int, float or tuple. If not given, the default connect timeout is used, and the streaming timeout is 1 year.If no
callback
is given, the method will return the firsteventcode
string detected, if that occurs beforetimeout
has elapsed. Iftimeout
occurs first,None
is returned (as it is for an error).Example events look like:
Which can be parsed in
callback
.Example use: