A node.JS module that attempts to bridge the gap between your ONVIF camera's motion detection and Motion.
Forked from zmonvif-events and converted for node.JS.
If you like this project you can support me.
$ npm install --save node-onvif-events
const MotionDetection = require('node-onvif-events');
var configMotion = new MotionDetection({
url: 'http://192.168.0.230/onvif/device_service/ ', // Onvif Service URL
id: 1,// Any id
hostname: '192.168.0.230', // IP from your Device
username: 'admin', // User
password: 'pass0rd', // Password
port: 80 // Onvif Service Port
});
// Starts Monitoring
configMotion.start();
const MotionDetection = require('node-onvif-events');
var lastState = null;
var configMotion = new MotionDetection({
url: 'http://192.168.0.230/onvif/device_service/ ', // Onvif Service URL
id: 1,// Any id
hostname: '192.168.0.230', // IP from your Device
username: 'admin', // User
password: 'pass0rd', // Password
port: 80 // Onvif Service Port
});
function motion() {
console.log("Motion Detected!!");
}
function motionStop() {
console.log("Motion Stopped!!");
}
function checkState(){
setInterval(function () {
var motionState = configMotion.getMotionState();
if(motionState === true && motionState !== lastState){
motion()
}
else if (motionState === false && motionState !== lastState){
motionStop();
}
lastState = configMotion.getMotionState();
}, 1000)
}
configMotion.start();
checkState();