smartthings-mqtt-bridge
smartthings-mqtt-bridge copied to clipboard
Duplicate subscriptions being made
The config values for SUFFIX_COMMAND and SUFFIX_WRITE_STATE are empty string by default, this causes handleSubscribeEvent to add duplicate subscriptions. I think we can just can just make one subscription if getTopicFor value is the same?
function handleSubscribeEvent (req, res) {
// Subscribe to all events
subscriptions = [];
Object.keys(req.body.devices).forEach(function (property) {
req.body.devices[property].forEach(function (device) {
subscriptions.push(getTopicFor(device, property, TOPIC_COMMAND));
subscriptions.push(getTopicFor(device, property, TOPIC_WRITE_STATE));
});
});