server.js
function getTopicFor (device, property, type) {
    var tree = [config.mqtt.preface, device, property],
        suffix;

    if (type === TOPIC_COMMAND) {
        suffix = config.mqtt[SUFFIX_COMMAND];
    } else if (type === TOPIC_READ_STATE) {
        suffix = config.mqtt[SUFFIX_READ_STATE];
    } else if (type === TOPIC_WRITE_STATE) {
        suffix = config.mqtt[SUFFIX_WRITE_STATE];
    }

    if (suffix) {
        tree.push(suffix);
    }

    return tree.join('/');
}
function getTopicFor (device, property, type) {
    var tree = [config.mqtt.preface, device, property],
        suffix;

    if (type === TOPIC_COMMAND) {
        suffix = config.mqtt[SUFFIX_COMMAND];
    } else if (type === TOPIC_READ_STATE) {
        suffix = config.mqtt[SUFFIX_READ_STATE];
    } else if (type === TOPIC_WRITE_STATE) {
        suffix = config.mqtt[SUFFIX_WRITE_STATE];
    }

    if (suffix) {
        tree.push(suffix);
    }

    return tree.join('/');
}
function getTopicFor ( device , property , type ) { var tree = [ config . mqtt . preface , device , property ] , suffix ; if ( type === TOPIC_COMMAND ) { suffix = config . mqtt [ SUFFIX_COMMAND ] ; } else if ( type === TOPIC_READ_STATE ) { suffix = config . mqtt [ SUFFIX_READ_STATE ] ; } else if ( type === TOPIC_WRITE_STATE ) { suffix = config . mqtt [ SUFFIX_WRITE_STATE ] ; } if ( suffix ) { tree . push ( suffix ) ; } return tree . join ( '/' ) ; }
Get the topic name for a given item
@method getTopicFor
@param  {String}    device   Device Name
@param  {String}    property Property
@param  {String}    type     Type of topic (command or state)
@return {String}             MQTT Topic name
Get the topic name for a given item