A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
Read the statement by Michael Teeuw here.
[npm library] @bugsounet/pir
-
@bugsounet/pir
I created this library if you want use a pir sensor in your module.
This library is very simplified and ready for use in yournode_helper.jsThis library is used in MMM-Assistant2Display
single node routine for PIR sensor read
Installation
npm install @bugsounet/pirIn the ending of installation, if you use
electronyou can do electron rebuild step.Do you want to execute electron rebuild ? [Y/n] Your choice:Sample with pir contructor
const Pir = require("@bugsounet/pir") this.config = { gpio: 17, reverseValue: false } var debug= false this.pir = new Pir(this.config, callback, debug) this.pir.start() setTimeout(() => { this.pir.stop() } , 5000) function callback(status, err) { console.log("[PIR:CALLBACK] Status: " + status) if (err) console.log("[PIR:CALLBACK] " + err) }constructor of pir
Pir(pirConfig, callback, debug)
pirConfig {}
gpio- BCM-number of the sensor pin.reverseValue- reverse presence detector value.
callback (status,error)
callback return with event status:
PIR_INITIALIZED: Pir constructor is initializedPIR_STARTED: Pir start detection confirmationPIR_STOP: pir stop detection confirmationPIR_DETECTED: pir user presence detectedPIR_ERROR: pir error
callback
errorreturn withPIR_ERRORif error detected, it will return it with error value
debug
if you want debuging information, just set to
trueFunctions
start(): start pirstop(): force stop pir
