Moonshine-IDE / ZoneMinder-tvOS

AppleTV Solution To ZoneMinder Streaming Using Moonshine Form Builder
0 stars 0 forks source link

Display Alarm Status from ZoneMinder API #5

Open JoelProminic opened 1 year ago

JoelProminic commented 1 year ago

@MarkProminic suggested today that we add the alarm status to the Camera UI. This state can indicate if there is enough activity on the camera that the camera is being recorded. Once we collect this information, we could add features like:

This led to a discusion about using the ZoneMinder API. We did some more investigation after the meeting and found the following leads.

Note that the ZoneMinder API requires authentication. You can authenticate from the web UI - I'll send the credentials privately. Don't hard-code the credentials in the code - we'll need to find a smarter way to handle this. I also see an option to use an API key.

This call gives details about the monitor/camera. Unfortunately, this doesn't have the alarm status, but it may be useful later:

https://%server%/zm/api/monitors/%ID%.json

Instead you can try something like this, which returns the Alarm status:

https://%server%/zm/api/monitors/alarm/id:%ID%/command:status.json

{
  "status": "0",
  "output": "0"
}

We think this is the mapping for the statuses

    $Statuses = array(
      -1 => 'Unknown',
      0 => 'Idle',
      1 => 'PreAlarm',
      2 => 'Alarm',
      3 => 'Alert',
      4 => 'Tape'
    );
JoelProminic commented 1 year ago

For later testing, we can force a camera to an alarm state like this:

https://%server%/zm/api/monitors/alarm/id:%id%/command:on.json