server.js
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));
        });
    });

    // Store callback
    callback = req.body.callback;

    // Store current state on disk
    saveState();

    // Subscribe to events
    winston.info('Subscribing to ' + subscriptions.join(', '));
    client.subscribe(subscriptions, function () {
        res.send({
            status: 'OK'
        });
    });
}
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));
        });
    });

    // Store callback
    callback = req.body.callback;

    // Store current state on disk
    saveState();

    // Subscribe to events
    winston.info('Subscribing to ' + subscriptions.join(', '));
    client.subscribe(subscriptions, function () {
        res.send({
            status: 'OK'
        });
    });
}
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 ) ) ; } ) ; } ) ; // Store callback callback = req . body . callback ; // Store current state on disk saveState ( ) ; // Subscribe to events winston . info ( 'Subscribing to ' + subscriptions . join ( ', ' ) ) ; client . subscribe ( subscriptions , function ( ) { res . send ( { status : 'OK' } ) ; } ) ; }
Handle Subscribe event from SmartThings

@method handleSubscribeEvent
@param  {Request} req
@param  {Object}  req.body
@param  {Object}  req.body.devices  List of properties => device names
@param  {String}  req.body.callback Host and port for SmartThings Hub
@param  {Result}  res               Result Object
Handle Subscribe event from SmartThings