npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qsee-alerts

v0.0.0

Published

Create an SMTP server to capture alerts generated by Q-See NVRs

Downloads

4

Readme

Q-See Alerts

This module will create an SMTP on a given host:port combination to listen for incoming email messages from a Q-See NVR.

Setup

In order to use this module, you must instruct your NVR to send email alerts to this server by modifying the correct values in the config->network->email section of the web interface (or however your NVR has it labeled).

Note: this has only been tested on the Qth-8Cn-2 model, as that's what I have.

Here's an example from my NVR.

email-settings

  • SMTP Server - The IP address or hostname where this module will be listening
  • Port - The Port where this module will be listening
  • SSL Check - Whether or not to use SSL - this module currently does support it so leave it unchecked
  • Send Addr - called the "username" by this module - used for the extremely basic auth check (must look like an email address)
  • Password - called the "password" by this module - used for the same auth as above and can be pretty much anything
  • Receive Addr1 - must be set and must look like an email address, though this is discarded by this module
  • Attaching Image - whether or not you want to send image attachments with the email

Once these settings have been set properly, you can create an SMTP server with this module like this

var QSeeAlertsServer = require('qsee-alerts').QSeeAlertsServer;

var opts = {
    host: '0.0.0.0',           // SMTP Server listen host
    port: 10465,               // SMTP Server listen port
    username: '[email protected]',  // valid username for sending email, `Send Addr` in the NVR config
    password: 'bar'            // valid password for sending email.  `Password` in the NVR config
};

var qsee = new QSeeAlertsServer(opts);

// emitted when the server is listening and ready for new connections
qsee.on('ready', function () {
    console.log('server running');
});

// emitted whenever a recoverable error is encountered (can be ignored, useful
// for debugging)
qsee.on('warning', function (e) {
    console.error('[warning] %s', e.message);
});

// emitted whenever an alert is seen (an email is sent from the DVR)
qsee.on('alert', function (obj) {
    console.log(JSON.stringify(obj, null, 2));
});

Now all that's left is to generate some alerts, either by creating motion or disconnecting a camera... you should see output like:

server running
{
  "subject": "Alarm Message From Device qsee.",
  "date": "2017-03-22T05:36:44.942Z",
  "from": "[email protected]",
  "to": "[email protected]",
  "rawBody": "Device ID: 0, Device Name: qsee\n\n\nChannel ID: 3, Camera Name:Street\nAlarm Type:Motion Alarm, Time:2017-3-22 01:36:46\n\n",
  "data": {
    "Device ID": "0",
    "Device Name": "qsee",
    "Channel ID": "3",
    "Camera Name": "Street",
    "Alarm Type": "Motion Alarm",
    "Time": "2017-3-22 01:36:46"
  }
}
{
  "subject": "Alarm Message From Device qsee.",
  "date": "2017-03-22T05:36:57.474Z",
  "from": "[email protected]",
  "to": "[email protected]",
  "rawBody": "Device ID: 0, Device Name: qsee\n\n\nChannel ID: 2, Camera Name:Backyard\nAlarm Type:Motion Alarm, Time:2017-3-22 01:36:59\n\n",
  "data": {
    "Device ID": "0",
    "Device Name": "qsee",
    "Channel ID": "2",
    "Camera Name": "Backyard",
    "Alarm Type": "Motion Alarm",
    "Time": "2017-3-22 01:36:59"
  }
}

Attachments

If you would like to receive attachments (images) as well, you can call the constructor like:

var opts = {
    host: '0.0.0.0',
    port: 10465,
    username: '[email protected]',
    password: 'bar',
    parseAttachments: true
};

Now, when an alert is received, if there is an attachment with the email it will be contained in the attachments key like

{ attachments: { files: [ [Object] ] },
  subject: 'Alarm Message From Device qsee.',
  date: 2017-03-22T05:48:44.939Z,
  from: '[email protected]',
  to: '[email protected]',
  rawBody: 'Device ID: 0, Device Name: qsee\n\n\nChannel ID: 2, Camera Name:Backyard\nAlarm Type:Motion Alarm, Time:2017-3-22 01:48:46\n\n',
  data:
   { 'Device ID': '0',
     'Device Name': 'qsee',
     'Channel ID': '2',
     'Camera Name': 'Backyard',
     'Alarm Type': 'Motion Alarm',
     Time: '2017-3-22 01:48:46' } }
[ { data: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 c5 00 03 02 02 03 02 02 03 03 03 03 04 03 03 04 05 08 05 05 04 04 05 0a 07 07 06 ... >,
    filename: 'CH02_170322014847.jpg' } ]

Where attachments.files is an array of objects for each attachment seen that contains data (the raw buffer of the attachment) and filename (the name given by the NVR).

Alternatively, this module can save the attachments automatically to files if given attachmentsDir

var opts = {
    host: '0.0.0.0',
    port: 10465,
    username: '[email protected]',
    password: 'bar',
    parseAttachments: true,
    attachmentsDir: path.join(__dirname, 'data')
};

Now, when an alert is received, if there is an attachment with the email it will be contained in the attachments key like

{ attachments:
   { files: [ '/home/dave/dev/node-qsee-alerts/data/1490162119637/CH02_170322015523.jpg' ],
     dir: '/home/dave/dev/node-qsee-alerts/data/1490162119637' },
  subject: 'Alarm Message From Device qsee.',
  date: 2017-03-22T05:55:19.660Z,
  from: '[email protected]',
  to: '[email protected]',
  rawBody: 'Device ID: 0, Device Name: qsee\n\n\nChannel ID: 2, Camera Name:Backyard\nAlarm Type:Motion Alarm, Time:2017-3-22 01:55:21\n\n',
  data:
   { 'Device ID': '0',
     'Device Name': 'qsee',
     'Channel ID': '2',
     'Camera Name': 'Backyard',
     'Alarm Type': 'Motion Alarm',
     Time: '2017-3-22 01:55:21' } }

Where attachments has a files array of the full path to the files saved, and dir has a directory that was created to house all the attachments from a single alert

Installation

npm install qsee-alerts

License

MIT License