Tim-Craig/zm-applet

KeyError: 'MonitorIds'

Closed this issue · 9 comments

Hi There,

Thanks for zm-applet

I have a problem when I launch it, I get a KeyError: 'MonitorIds'
Could you point me in the right direction ?
I have zm 1.32.3
On the screen I have loading...

XAUTHORITY=$HOME/.Xauthority python /opt/zm-applet/zm_applet.py
pygame 1.9.4.post1
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/opt/zm-applet/zm_applet.py", line 130, in
app.run()
File "/opt/zm-applet/zm_applet.py", line 70, in run
self.app_context.event_bus.process_queue()
File "/opt/zm-applet/event_bus.py", line 20, in process_queue
listener.process_event(event, data)
File "/opt/zm-applet/controller.py", line 17, in process_event
event_function(data)
File "/opt/zm-applet/zm_applet.py", line 108, in refresh_monitor_group
new_tracker = ZmGroupTracker.create_from_json_api(data[0], data[1])
File "/opt/zm-applet/zoneminder/group_tracker.py", line 68, in create_from_json_api
tracker.load_from_json_api(zm_api_groups_json, zm_api_monitors_json)
File "/opt/zm-applet/zoneminder/group_tracker.py", line 93, in load_from_json_api
new_group, new_monitors = parse_group_info_from_api(zm_api_groups_json, zm_api_monitors_json)
File "/opt/zm-applet/zoneminder/group_tracker.py", line 49, in parse_group_info_from_api
groups = [parse_group_json(group['Group']) for group in group_api_json['groups']]
File "/opt/zm-applet/zoneminder/group_tracker.py", line 23, in parse_group_json
monitor_ids = groups_json['MonitorIds'].split(',')

thanks

Hi Oramarin,

It looks like zm-applet got an invalid response from you Zoneminder server. What response do you get from your Zoneminder server when you open a web browser to the monitors api view? To see the monitors api view open a web browser to your zoneminder host and add a "/api/monitors.json" to the end. For example if the url to your zoneminder box is http://localhost/zm (or http://localhost/zm/index.php) try the url http://localhost/zm/api/monitors.json.

Thanks Tim,

my url is a on a other server but I get a answer as expected with all the Monitor and Monitor_Status
and groups.json is also working, I joining a redacted version so you can see.

groups.json.txt
monitors.json.txt

and I "see him" getting the query to the server
apache.log.txt

Thanks again for your help

Hi Oramarin,

I see the groups don't have monitors associated to them and hence the 'monitor_ids' field is not present. It looks like zm-applet is not handling this scenario properly and throwing an error.

I try to get this bug fixed soon.

In the meantime, if you removing those two empty groups or add monitors to them, zm-applet should start working.

Hi Oramarin,

I fixed the problem, you can pull the latest version of zm-applet and try starting it up again.

Let me know if it works for you.

Thanks,

Tim

Hi Tim,

It is working. Thanks a lot !
I also upgrade zoneminder to 1.33.14 to get the api version 2 but I still have no monitor associated with the groups despite they are associated on the web interface. I will investigate.
I am also going to see that is detected once I wire the gpios of the pi.

Thanks again for sharing
Oramarin

Sorry to reopen
Just to mention that in 1.33 we don't have any monitor associated int the groups.json that I think you coded in zoneminder ?

Hi Oramarin,

Yes, the group configuration is in Zoneminder itself. The groups . One possibility is that have groups with no monitors associated to them. Another possibility is if you are using Zoneminder's user authentication it could be the user zm-applet uses to login doesn't have view access rights to any monitors in those groups.

You can check the group settings in Zoneminder console UI by clicking the text under the Date and time. Text is usually like "11 monitors (my group)".

Regards,

Tim

Hi Tim,
I don't have auth and in the groups appear ok the UI, no groups has no monitors in them.
maybe a bug with my zonemider or the 1.33 version.

indeed a zoneminder problem
Thanks for your help
Oramarin

Looking at the Zoneminder repo I see they have refactored groups table in the DB. It possible the refactoring broke the Groups API. I haven't upgraded to 1.33 yet. I'll try to upgrade when I find the time and see for myself.