Closed Cassio-4 closed 3 years ago
Also an error is encountered if 'to' is not specified. I think it should default to 'now'. This is using the verison that pip3 delivers, which is 0.1.30. Github has 0.2. I just tested with latest master and 'from' is now parsed correctly.
I don't see a missing to causing any error.
import pyzm
import pyzm.api as zmapi
import getpass
import traceback
import pyzm.ZMMemory as zmmemory
import pyzm.helpers.utils as utils
from pyzm.helpers.Base import ConsoleLog
print ('Using pyzm version: {}'.format(pyzm.__version__))
logger = ConsoleLog()
logger.set_level(2)
conf = utils.read_config('/etc/zm/secrets.ini')
api_options = {
'apiurl': utils.get(key='ZM_API_PORTAL', section='secrets', conf=conf),
'portalurl':utils.get(key='ZM_PORTAL', section='secrets', conf=conf),
'user': utils.get(key='ZM_USER', section='secrets', conf=conf),
'password': utils.get(key='ZM_PASSWORD', section='secrets', conf=conf),
'logger': logger, # use none if you don't want to log to ZM,
#'disable_ssl_cert_check': True
}
zmapi = zmapi.ZMApi(options=api_options)
event_filter = {
'from': '9 am',
'to': '7 pm',
'object_only':False,
'min_alarmed_frames': 0,
'max_events':5,
}
cam_events = zmapi.events(event_filter)
print ('I got {} events'.format(len(cam_events.list())))
for e in cam_events.list():
print ('Event:{} Cause:{} Notes:{}'.format(e.name(), e.cause(), e.notes()))
So, I am trying to retrieve events that happened 12 minutes ago, using this options dict (for example):
However, once I call the
Monitor.events(options=event_filter)
method I noticed this as a result: (I censored my token and URL, pay no mind to it)the
StartTime
andEndTime
parts of the request are the same timestamp (specifically, they're the'to'
timestamp from myevent_filter
dict), hence why I am unable to receive any events.While sorting through the code I couldn't really understand the line 51 of the Events Class. Shouldn't it be
from_list = options.get('from').split(" to ", 1)
instead offrom_list = options.get('to').split(" to ", 1)
Thanks a lot, sorry about any formatting or grammatical errors