Skip to content

Commit

Permalink
fix: publish meta withoud id
Browse files Browse the repository at this point in the history
  • Loading branch information
krambox committed Nov 18, 2017
1 parent bba5aec commit c880b47
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions km200mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,20 @@ function mnemonizeMeta (result) {
}

function publishMeta (result) {
if (typeof (result.id) === 'string' && endsWith(result.id, 'flameCurrent')) {
result.unitOfMeasure = 'µA';
if (typeof (result.id) === 'string') {
if (endsWith(result.id, 'flameCurrent')) {
result.unitOfMeasure = 'µA';
}
var topic = 'km200/meta' + result.id;
var metaData = {
native: result
};
metaData.native.value = undefined;
metaData.native.id = undefined;
mqtt.publish(topic, JSON.stringify(metaData), { retain: true }, function () {
log.debug('meta', topic, metaData);
});
}
var topic = 'km200/meta' + result.id;
var metaData = {
native: result
};
metaData.native.value = undefined;
metaData.native.id = undefined;
mqtt.publish(topic, JSON.stringify(metaData), { retain: true }, function () {
log.debug('meta', topic, metaData);
});
}

function endsWith (str, suffix) {
Expand Down

0 comments on commit c880b47

Please sign in to comment.