pyzm: a python wrapper (leverages 1.34 features)

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

pyzm: a python wrapper (leverages 1.34 features)

Post by asker »

Hi folks,
The mainline ZM API docs have been updated to point to pyzm, a python module that provides access to:
  • ZM 1.34's new token system
  • ZM's shared memory (for real time monitor state access)
  • ZM's logging function
  • ZM's APIs
  • The Event Server
The goal is to do what ZM's perl modules do for Python (Memory/Logger/SHM) and more (APIs and Event Server access). There is proper documentation as well including a working example


I would strongly recommend 3rd party users to start using pyzm instead of their own legacy wrappers as it offers better integration, more secure access to ZM (tokens) and will be maintained. It's an early release, so I'd welcome PRs/contributions.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
snake
Posts: 337
Joined: Sat May 21, 2016 2:20 am

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by snake »

asker wrote: Sat Jan 18, 2020 5:22 am I would strongly recommend 3rd party users to start using pyzm instead of their own legacy wrappers as it offers better integration, more secure access to ZM (tokens) and will be maintained. It's an early release, so I'd welcome PRs/contributions.
Good to hear there will be more options, but I have some hardware which uses ZMTrigger, so hopefully there isn't a master plan to deprecate old functionality, just because it's old. I'd like to see backwards compatibility kept for old stuff. Well, maybe not backwards compatibility, but just don't remove zmtrigger, or X10... Those are optional by default, and 'just work' in a private LAN.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by asker »

Absolutely no plans to retire. These are wrappers so they will wrap around core ZM functionality (triggers are core). A good example of who may use this is Home Assistant. After 1.33 change login their plugin broke and we started receiving help requests on this issue.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
ruffledrooster
Posts: 4
Joined: Mon Mar 06, 2017 6:20 pm

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by ruffledrooster »

Not sure if this is the right place to do this or not but I couldn't find any other area that seemed more fitting. First off, I have done some testing and using this python module is awesome! Have used python now for a few years and this module makes it so much easier to connect to my zm instances and get the data that I need without having to comb through a bunch of json. Had a few questions in regards to the module though...is there a way to ignore SSL verification? I am still using self-signed certs on a few of my servers and in looking through the source code, it seems like you are basically doing the same thing I was doing before this module came about...using the requests module and sessions. Changing it to ignore ssl verification is quite simple, just add verify=False to each of the requests calls. Anyways, wasn't sure if that was something that was available or maybe a future 'feature'? :wink: Secondly, I have no second question because I answered it as I was typing the first. Thank you in advance.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by asker »

ruffledrooster wrote: Thu Mar 26, 2020 1:42 pm Not sure if this is the right place to do this or not but I couldn't find any other area that seemed more fitting. First off, I have done some testing and using this python module is awesome! Have used python now for a few years and this module makes it so much easier to connect to my zm instances and get the data that I need without having to comb through a bunch of json. Had a few questions in regards to the module though...is there a way to ignore SSL verification? I am still using self-signed certs on a few of my servers and in looking through the source code, it seems like you are basically doing the same thing I was doing before this module came about...using the requests module and sessions. Changing it to ignore ssl verification is quite simple, just add verify=False to each of the requests calls. Anyways, wasn't sure if that was something that was available or maybe a future 'feature'? :wink: Secondly, I have no second question because I answered it as I was typing the first. Thank you in advance.
I just updated pyzm to 0.1.9 - when you initialize the APIs, I've added a new attribute called "disable_ssl_cert_check" if True will do what you want.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
ruffledrooster
Posts: 4
Joined: Mon Mar 06, 2017 6:20 pm

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by ruffledrooster »

Just updated to 0.1.9 and it works perfectly. Thank you again for the prompt response, greatly appreciated.
ibrewster
Posts: 31
Joined: Sat Aug 31, 2019 4:18 pm

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by ibrewster »

So I was trying this out, and it works well for the most part, except for the "alarm_state" and "is_alarmed" functions in ZMMemory. Looking at the code, I'm not quite sure that they *could* work as written. In the ZMMemory class, you define a dictionary

Code: Select all

alarm_state
(line 55 of ZMMemory.py), but this is shortly overwritten by the function

Code: Select all

def alarm_state
on line 124.

Looking at that function, it declares a "global alarm_state", but there *is* no global alarm_state. Then, on line 140, it seems to be calling itself:

Code: Select all

'state':alarm_state(d['shared_data']['state'])
the is_alarmed function has a similar issue, in that it is trying to access the "global" alarm_state object (which is apparently supposed to be a dictionary here), but the only alarm_state object is the function.

I can fix this easily enough, but I wanted to mention it in case I'm the one missing something here.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by asker »

pyzm is work in progress. If there are bugs, please open an issue in the pyzm github repo. If you have fixed it, please do a PR.
https://github.com/pliablepixels/pyzm
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by asker »

alarm_state was fixed.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by david1234 »

I have start to work with pyzm - just great for my needes

one question :
how can I tell the state of the server ?
is it running on Record\ Stop \ Default mode ?

I have found how to change using

Code: Select all

zmapi.stop()
zmapi.start()
zmapi.set_state("Record")
Thanks ,
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: pyzm: a python wrapper (leverages 1.34 features)

Post by asker »

Have you looked at the example file and docs?
https://pyzm.readthedocs.io/en/latest/source/pyzm.html

For your question, see states API
https://pyzm.readthedocs.io/en/latest/s ... html#state
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Post Reply