homebridge-dafang-mqtt-republish
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -20,3 +20,4 @@ { | ||
"type": "string", | ||
"placeholder": "127.0.0.1" | ||
"placeholder": "127.0.0.1", | ||
"description": "The address of your MQTT server." | ||
}, | ||
@@ -26,3 +27,4 @@ "port": { | ||
"type": "integer", | ||
"placeholder": "1883" | ||
"placeholder": "1883", | ||
"description": "The port of your MQTT server." | ||
}, | ||
@@ -41,13 +43,18 @@ "cameras": { | ||
"type": "string", | ||
"placeholder": "Camera Name" | ||
}, | ||
"required": true, | ||
"description": "Name of your camera. (Needs to be the same as in homebridge-camera-ffmpeg config)" | ||
}, | ||
"dafang_topic": { | ||
"title": "Dafang MQTT Topic", | ||
"type": "string", | ||
"placeholder": "myhome/dafang" | ||
}, | ||
"required": true, | ||
"placeholder": "myhome/dafang", | ||
"description": "MQTT topic that your camera publishes to." | ||
}, | ||
"homebridge_topic": { | ||
"title": "Homebridge MQTT Topic", | ||
"type": "string", | ||
"placeholder": "homebridge/motion" | ||
"required": true, | ||
"placeholder": "homebridge/motion", | ||
"description": "MQTT topic that homebridge-camera-ffmpeg is subscribed to." | ||
} | ||
@@ -54,0 +61,0 @@ } |
25
index.js
@@ -23,5 +23,5 @@ const mqtt = require('mqtt'); | ||
this.log('MQTT Connection Opened'); | ||
this.config.cameras.forEach(camera => { | ||
client.subscribe(camera.dafang_topic + '/motion'); | ||
}); | ||
this.config.cameras.forEach(camera => { | ||
client.subscribe(camera.dafang_topic + '/motion'); | ||
}); | ||
}); | ||
@@ -31,11 +31,14 @@ client.on('message', (topic, message) => { | ||
this.log.debug('Received MQTT Message - ' + topic + ': ' + msg); | ||
this.config.cameras.forEach(camera => { | ||
if (camera.dafang_topic + '/motion' == topic) { | ||
if (msg == 'ON') { | ||
this.log.debug('Publishing MQTT Message - ' + camera.homebridge_topic + ': ' + camera.name); | ||
client.publish(camera.homebridge_topic, camera.name); | ||
} | ||
} | ||
}); | ||
this.config.cameras.forEach(camera => { | ||
if (camera.dafang_topic + '/motion' == topic) { | ||
if (msg == 'ON') { | ||
this.log.debug('Publishing MQTT Message - ' + camera.homebridge_topic + ': ' + camera.name); | ||
client.publish(camera.homebridge_topic, camera.name); | ||
} else if (msg == 'OFF') { | ||
this.log.debug('Publishing MQTT Message - ' + camera.homebridge_topic + '/reset: ' + camera.name); | ||
client.publish(camera.homebridge_topic + '/reset', camera.name); | ||
} | ||
} | ||
}); | ||
}); | ||
} |
{ | ||
"displayName": "Homebridge Dafang MQTT Republish", | ||
"name": "homebridge-dafang-mqtt-republish", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Republishes MQTT Motion Messages from Dafang Hacks into a Format homebridge-camera-ffmpeg Understands", | ||
@@ -6,0 +6,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7543
101