Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

homebridge-dafang-mqtt-republish

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-dafang-mqtt-republish - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

7

config.schema.json

@@ -57,2 +57,9 @@ {

"description": "MQTT topic that homebridge-camera-ffmpeg is subscribed to."
},
"cooldown": {
"title": "Cooldown (Seconds)",
"type": "integer",
"placeholder": 0,
"minimum": 0,
"description": "Set to 0 to disable."
}

@@ -59,0 +66,0 @@ }

40

index.js

@@ -11,2 +11,9 @@ const mqtt = require('mqtt');

this.cameras = {};
this.config.cameras.forEach(camera => {
this.cameras[camera.name] = {};
this.cameras[camera.name].motion = false;
this.cameras[camera.name].timer = null;
});
if (api) {

@@ -34,7 +41,32 @@ this.api = api;

if (msg == 'ON') {
this.log.debug('Publishing MQTT Message - ' + camera.homebridge_topic + ': ' + camera.name);
client.publish(camera.homebridge_topic, camera.name);
this.cameras[camera.name].motion = true;
if (!this.cameras[camera.name].timer) {
this.log.debug('Publishing MQTT Message - ' + camera.homebridge_topic + ': ' + camera.name);
client.publish(camera.homebridge_topic, camera.name);
} else {
this.log.debug('Motion set received, but cooldown running: ' + camera.name);
}
if (camera.cooldown > 0) {
if (this.cameras[camera.name].timer) {
this.log.debug('Cancelling existing cooldown timer: ' + camera.name);
clearTimeout(this.cameras[camera.name].timer);
}
this.log.debug('Cooldown enabled, starting timer: ' + camera.name);
this.cameras[camera.name].timer = setTimeout(function() {
this.log.debug('Cooldown finished, motion detected = ' + this.cameras[camera.name].motion + ': ' + camera.name);
if (!this.cameras[camera.name].motion) {
this.log.debug('Publishing MQTT Message - ' + camera.homebridge_topic + '/reset: ' + camera.name);
client.publish(camera.homebridge_topic + '/reset', camera.name);
}
this.cameras[camera.name].timer = null;
}.bind(this), camera.cooldown * 1000);
}
} else if (msg == 'OFF') {
this.log.debug('Publishing MQTT Message - ' + camera.homebridge_topic + '/reset: ' + camera.name);
client.publish(camera.homebridge_topic + '/reset', camera.name);
this.cameras[camera.name].motion = false;
if (!this.cameras[camera.name].timer) {
this.log.debug('Publishing MQTT Message - ' + camera.homebridge_topic + '/reset: ' + camera.name);
client.publish(camera.homebridge_topic + '/reset', camera.name);
} else {
this.log.debug('Motion clear received, but cooldown running: ' + camera.name);
}
}

@@ -41,0 +73,0 @@ }

2

package.json
{
"displayName": "Homebridge Dafang MQTT Republish",
"name": "homebridge-dafang-mqtt-republish",
"version": "0.1.1",
"version": "0.2.0",
"description": "Republishes MQTT Motion Messages from Dafang Hacks into a Format homebridge-camera-ffmpeg Understands",

@@ -6,0 +6,0 @@ "repository": {

@@ -42,1 +42,2 @@ # homebridge-dafang-mqtt-republish

| \|- homebridge_topic | MQTT topic that homebridge-camera-ffmpeg is subscribed to. | Yes |
| \|- cooldown | Cooldown in seconds. Set to 0 to disable. | No |
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc