zoneminder icon indicating copy to clipboard operation
zoneminder copied to clipboard

After update zoneminder v1.37.66 zmapi have trouble ,maybe is not compatible?

Open mdonadel83 opened this issue 7 months ago • 1 comments

After update zoneminder v1.37.66 if you try the simple function :

import pyzm
import pyzm.api as zmapi
import getpass
import traceback
import pyzm.ZMMemory as zmmemory
import pyzm.helpers.utils as utils
import pyzm.helpers.globals as g



print ('Using pyzm version: {}'.format(pyzm.__version__))

g.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),
    'api_push_token':utils.get(key='PUSHOVER_APP_TOKEN', section='secrets', conf=conf),
    'api_push_key':utils.get(key='PUSHOVER_USER_KEY', section='secrets', conf=conf),
    '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()))

the return is:

Traceback (most recent call last):
  File "/home/mauro/test.py", line 37, in <module>
    cam_events = zmapi.events(event_filter)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pyzm/api.py", line 368, in events
    self.Events = Events(api=self, options=options)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pyzm/helpers/Events.py", line 24, in __init__
    self._load(options)
  File "/usr/local/lib/python3.12/dist-packages/pyzm/helpers/Events.py", line 122, in _load
    currevents += int(pagination.get('current'))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

mdonadel83 avatar Jul 11 '25 18:07 mdonadel83

current is no longer present in results. Not sure why. Need to test for it's existence before trying to use it. Maybe fixed by 83d3c2f

connortechnology avatar Jul 11 '25 20:07 connortechnology