smartthings-mqtt-bridge icon indicating copy to clipboard operation
smartthings-mqtt-bridge copied to clipboard

Duplicate subscriptions being made

Open iprak opened this issue 7 years ago • 0 comments

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));
        });
    });

iprak avatar Jan 17 '19 11:01 iprak