# Dev Integration for Zoneminder

**URL:** <https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483>\
**Category:** Développement\
**Created:** [August 28, 2021, 3:58pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483 "2021-08-28T15:58:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [August 28, 2021, 3:58pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/1 "2021-08-28T15:58:45Z")

</div>

Hello,

I am currently developing an integration that uses Zoneminder APIs (open-source video surveillance software that supports cameras of your choice).

On Gladys V3, I had developed a home-made module based on SSH that launched a Perl command, so not very clean… but it still serves me today to activate/deactivate video surveillance depending on whether we enter or leave the house.  
So to migrate to V4, I absolutely need to have this solution available.

A preview:

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/b/b51a3e2c4dc5b7230e38f29aea772261095421fe.png)

So I did this quickly, I think I will build a home version first.

So I post this here, in case anyone else uses ZM and would like to integrate it with Gladys…  
I discovered that ZM exposes quite a few APIs, for my part, for the time being, I limit myself to putting a camera in `Modect` or `Monitor` mode, but in the future, we could consider much more…

---

<div class="post-metadata">

**Author:** ![damalgos](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@damalgos](https://community.gladysassistant.com/u/damalgos)\
**Post date:** [August 30, 2021, 8:03am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/2 "2021-08-30T08:03:41Z")

</div>

Hello sympa integration, so does it update the image in the dashboard?

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [August 30, 2021, 7:39pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/3 "2021-08-30T19:39:08Z")

</div>

Not at the moment, I haven’t looked at how to integrate an image into the dashboard, after that it may be redundant with the `Display a camera` box already available.

---

<div class="post-metadata">

**Author:** ![damalgos](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@damalgos](https://community.gladysassistant.com/u/damalgos)\
**Post date:** [August 30, 2021, 8:39pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/4 "2021-08-30T20:39:09Z")

</div>

Exactly, you can add a camera and add an associated image to this camera and the box will work

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [August 31, 2021, 1:33am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/5 "2021-08-31T01:33:51Z")

</div>

Absolutely, it’s a really nice integration anyway!

Don’t hesitate if you need help @Jean-Philippe to integrate it with the «&nbsp;display a camera&nbsp;» box 🙂

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [August 31, 2021, 5:37am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/6 "2021-08-31T05:37:19Z")

</div>

@damalgos Yes, I thought I saw that when I set the type to CAMERA  
The problem is that the associated features are specific (such as usage mode, detection, passive, etc.), so to have a switchable mode, I added a feature type SWITCH, but the category is not the same, so in the box, it gave undefined values everywhere and without an icon.  
In this case, maybe I could add feature types for the CAMERA category?

---

<div class="post-metadata">

**Author:** ![damalgos](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@damalgos](https://community.gladysassistant.com/u/damalgos)\
**Post date:** [August 31, 2021, 6:13am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/7 "2021-08-31T06:13:07Z")

</div>

What is the switchable mode then?  
But yes, of course, if you need to add, add it 😉

For the image, it depends on what the API can give you. It might give you just a URL and you’re all set (just do the same as the camera module). If, on the other hand, it sends you a JPEG for example, you can do it like this:  
[Gladys/server/services/netatmo/lib/update/netatmo.updateCamera.js at netatmo · thibautmery/Gladys · GitHub](https://github.com/thibautmery/Gladys/blob/netatmo/server/services/netatmo/lib/update/netatmo.updateCamera.js#L22) (Netatmo integration, there is a part where the image is downloaded and added)

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [August 31, 2021, 6:19am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/8 "2021-08-31T06:19:58Z")

</div>

> [@Jean-Philippe](#):
>
> In this case, could I maybe add features like for the CAMERA category?

Exactly 🙂 If your camera handles additional features, you can create new feature types.

In Gladys v4, we are trying to have something uniform regardless of the model/brand/technology, so the behavior is generic everywhere.

Example here: if you give the Gladys camera type to your zoneminder cameras, it means that natively we will be able to manage phrases in Telegram like «&nbsp;show me the living room camera&nbsp;», as well as the display on the dashboard.

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [August 31, 2021, 6:43am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/9 "2021-08-31T06:43:01Z")

</div>

ok I will go in this direction, I will see what the netatmo module does, then I need to see if I can retrieve the image via zoneminder.

Regarding the modes, the first use is that a camera (or a monitor as we can have several monitors from the same camera for different uses) can be in several modes, for example:

- Motion detection with recording on detection
- Simple playback without recording
- Playback with continuous recording
- And other modes that I do not use

So I want to be able, with minimal use of the module, to change this mode. When we are at home, we switch to Simple Playback, and when the house is empty, to Detection.

---

<div class="post-metadata">

**Author:** ![damalgos](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@damalgos](https://community.gladysassistant.com/u/damalgos)\
**Post date:** [August 31, 2021, 6:49am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/10 "2021-08-31T06:49:48Z")

</div>

> [@Jean-Philippe](#):
>
> ok I’ll go in that direction, I’ll see what the netatmo module does, then I need to see if I can retrieve the image via zoneminder.

Quickly I saw this: `wget "http://yourserver/cgi-bin/zms?mode=single&monitor=1&user=xxx&pass=yyy" -O foo.jpg`  
So it’s possible that you can retrieve the image and therefore do as I did in netatmo 🙂

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [August 31, 2021, 8:33pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/11 "2021-08-31T20:33:49Z")

</div>

> [@damalgos](#):
>
> /cgi-bin/zms?mode=single&monitor=1&user=xxx&pass=yyy

It works indeed, the password isn’t even checked 🤫

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [September 1, 2021, 4:25pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/12 "2021-09-01T16:25:47Z")

</div>

You need to enable authentication in ZoneMinder, by default it’s open access

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [September 1, 2021, 7:25pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/13 "2021-09-01T19:25:55Z")

</div>

That’s normally the case, I don’t really know what’s going on … well, my ZM isn’t open on the internet, it’s not a big deal.

@damalgos I looked at your netatmo integration, I’m trying to understand how Gladys requests the update of the jpg?  
I don’t plan to poll the image at regular intervals on the server side, I thought the image should be requested when the user requests the dashboard, is that right? In that case, how does the front-end request the back-end?

Edit 1:  
Ok I see in `server/lib/device/camera/camera.getImage.js`:  
`return Promise.resolve(deviceFeature.last_value_string);`

Edit 2:  
Should I put a poll\_frequency on the Image feature..?

Edit 3:  
It’s good I found it ^^

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [September 4, 2021, 2:14pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/14 "2021-09-04T14:14:55Z")

</div>

I’m making progress, I’ve added the appropriate categories and I have my image on the dashboard.

However, while adding categories, I also added:

```json
CAMERA: {
    IMAGE: 'image',
    MODE: 'mode',
    MOTIONS: 'integer',
    POWER: 'power'
}

```

MODE = the camera mode (motion capture, continuous recording, etc.)  
MOTIONS = the number of captured events (read only)  
POWER = whether the camera is on or off (from a Zoneminder perspective)

This is good, but on the Box side, I see this:

```javascript
// for now, we only supports binary on/off and sensors
if (feature.read_only || SUPPORTED_FEATURE_TYPES.includes(feature.type)) {
     roomDeviceFeatures.push(featureOption);
}

```

Therefore, I cannot modify the camera’s state or mode in the dashboard.  
Similarly, I had tested at the beginning by setting the mode to type SWITCH, but it’s not ideal to know that 1 = recording, 2 = surveillance, etc.

So, how can I have a dropdown menu, for example, with the proposed modes in the dashboard? I think this is not yet planned/coded/started?

But can I manage this in a scene anyway?

On the `model` side, the `min` and `max` are mandatory in the feature. Does this mean that a numerical value must always be recorded, and that we need to do the mapping on the integration side?

Edit:  
I added the Zoneminder alarm state, i.e., whether the camera is in Alarm due to an intrusion detection.  
And so I looked for which category.type to put. On the box (`SensorDeviceFeature.js`), I see that currently if it’s not a Motion, Presence, or Opening sensor, the rendering is the default one.

```html
<td>{props.deviceFeature.name}</td>
    {SPECIAL_SENSORS.indexOf(props.deviceFeature.category) === -1 && (
      <td class={cx('text-right', { 'text-nowrap': props.deviceFeature.last_value !== null })}>
        {props.deviceFeature.last_value !== null && props.deviceFeature.last_value}
        {props.deviceFeature.last_value === null && <Text id="dashboard.boxes.devicesInRoom.noValue" />}
        {props.deviceFeature.last_value !== null && (
          <span>
            {' '}
            <Text id={`deviceFeatureUnitShort.${props.deviceFeature.unit}`} />
          </span>
        )}
      </td>
    )}

```

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/c/ceecf8c5e22cc3e4fc1df25cea71d9308b1a9dec.png)

Is there a dedicated type for Alarm (in general), I saw a Category «&nbsp;Siren&nbsp;» .. I await your feedback before going further with my classification.

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [September 4, 2021, 4:00pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/15 "2021-09-04T16:00:04Z")

</div>

@pierre-gilles

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/b/b932e37c421adf5f7976949b10ebf8a1ba22620e.png)

😍 😍 😍

I see too much usage when you’re not at home via Telegram, finish launching my OpenVPN, the browser, going to the Zoneminder interface…

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [September 5, 2021, 2:37am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/16 "2021-09-05T02:37:57Z")

</div>

> [@Jean-Philippe](#):
>
> Good, it’s fine but on the Box side, I see this:

Yes, that’s normal. In this box, we only display devices that we can manage in the UI 🙂 After that, nothing prevents you from adding a new component in the front end to manage a new type of device!

Each device display in the front end is managed here: [Gladys/front/src/components/boxs/device-in-room/device-features at master · GladysAssistant/Gladys · GitHub](https://github.com/GladysAssistant/Gladys/tree/master/front/src/components/boxs/device-in-room/device-features)

> [@Jean-Philippe](#):
>
> So how, on the one hand, could I have a drop-down menu for example with the proposed modes, in the dashboard? I think it’s not yet planned / coded / started?

It’s up to you to create a frontend component that does it 🙂

In Gladys 4, we avoid making «&nbsp;super generic&nbsp;» components (except when they can be factored between integrations) to instead make components really adapted, defined in the code (and not in the database), which allows:

- Having translations (since Gladys is available in several languages)
- The behaviors of these components are versioned and tested (we use Cypress for frontend tests)

In short, for you, it would be a «&nbsp;drop-down list&nbsp;» component with several states, specific to the Zoneminder integration, right?

> [@Jean-Philippe](#):
>
> But can I manage it in a scene anyway?

Same, you need to add this component with the values you want in the scene control action and in the scene trigger

Example: [Gladys/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx at master · GladysAssistant/Gladys · GitHub](https://github.com/GladysAssistant/Gladys/blob/master/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx#L54)

**Note:** it may seem like a lot of work, but it’s the philosophy of v4: we take the time to do things well, and we prefer to have a product that requires a bit more work for the developer, but so that in the end the user experience is the best 🙂

> [@Jean-Philippe](#):
>
> Is there a type dedicated to the Alarm (in general), I saw a «&nbsp;Siren&nbsp;» category… I’m waiting for your feedback before going further with my classification…

Alarm for what? I don’t think so. Siren is just an outdoor siren (you know the boxes that make noise)

> [@Jean-Philippe](#):
>
> 😍 😍 😍
> 
> I see the use when you are not at home via Telegram, finish launching my OpenVPN, the browser, going to the Zoneminder interface…

Magnificent!! 😍

Otherwise, have you already tested Gladys Plus for remote access? It’s end-to-end encrypted, and I recently added a free 14-day trial if you want to test it 🙂

> **[Gladys Plus | Gladys Assistant](https://gladysassistant.com/fr/plus/)**
>
> Add more features to Gladys Assistant with Gladys Plus

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [September 11, 2021, 7:41pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/17 "2021-09-11T19:41:21Z")

</div>

I will look into how to add the front-end component to handle this.

Regarding the alarm, I was thinking of surveillance alarms, the ones that go off when a burglar enters 😃  
In my case, if my camera detects motion, it goes into «&nbsp;alarm&nbsp;» mode and sends me a notification on my Gladys3 instance.

For Gladys Plus, I haven’t tested it on Gladys4, currently my instance is just in development on my PC, I will test it when I switch over 😉

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [September 12, 2021, 5:59am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/18 "2021-09-12T05:59:13Z")

</div>

> [@Jean-Philippe](#):
>
> Regarding the alarm, I was thinking about surveillance alarms, the one that rings when a thief enters 😃  
> In my case, if my camera detects movement, it switches to “alarm” and sends me a notification on my Gladys3 instance.

We don’t yet have native alarm management, I would like to do something really clean in «&nbsp;arm/disarm&nbsp;» mode for your home with a nice UI and triggers/actions in scenes to be able to react to this state change (IF movement AND armed alarm THEN…)

But I think that in the meantime you can manage with another binary type (0/1), it will do the job in the meantime 🙂

You can upvote the feature here if you want to see it in Gladys:

> [@Gestion état de l'alarme de la maison (armée/désarmée)](https://community.gladysassistant.com/t/gestion-etat-de-lalarme-de-la-maison-armee-desarmee/6326/4):
>
> C’est ce que j’aimerai faire aussi, avec deux choses : Le plan en 2D ou 3D de la maison Le mode “verrouillage” de la maison

> [@Jean-Philippe](#):
>
> For Gladys Plus, I haven’t tested on Gladys4, currently my instance is just in dev on my pc, I will test when I switch 😉

Cool, don’t hesitate at that time if you have any questions, we can take the time together to make sure everything is well configured, there are many possibilities with Gladys Plus and I try to support the installation as much as possible!

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [September 12, 2021, 8:25pm UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/19 "2021-09-12T20:25:43Z")

</div>

I saw on the `rtsp-camera` integration that you can add a box to the dashboard.  
But is it possible, via an integration, to add features to devices usable from the `device of a room` box to avoid adding a dedicated box?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [September 13, 2021, 2:04am UTC](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483/20 "2021-09-13T02:04:22Z")

</div>

> [@Jean-Philippe](#):
>
> Is it possible, via an integration, to add features to devices usable from the `room device` box to avoid adding a dedicated box?

Absolutely! 🙂 If you create a new pair (Category + type) for a device, it is entirely possible to manage this new pair in the «&nbsp;room device&nbsp;» box.

What kind of control are you thinking of?

[Next page](https://community.gladysassistant.com/t/dev-integration-pour-zoneminder/6483.md?page=2)
