Skip to content

Commit

Permalink
Add suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
Otto Paulsen committed Feb 28, 2018
1 parent 50060c9 commit 20cc4c3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions MMM-MQTT.js
Expand Up @@ -21,11 +21,13 @@ Module.register("MMM-MQTT",{

for(i = 0; i < this.config.subscriptions.length; i++){
console.log(this.name + ': Adding config ' + this.config.subscriptions[i].label + ' = ' + this.config.subscriptions[i].topic);

this.subscriptions[i] = {
label: this.config.subscriptions[i].label,
topic: this.config.subscriptions[i].topic,
decimals: this.config.subscriptions[i].decimals,
jsonpointer: this.config.subscriptions[i].jsonpointer,
suffix: typeof(this.config.subscriptions[i].suffix) == 'undefined' ? '' : this.config.subscriptions[i].suffix,
value: ''
}
}
Expand Down Expand Up @@ -101,6 +103,12 @@ Module.register("MMM-MQTT",{
valueWrapper.className = "align-right bright medium";
subWrapper.appendChild(valueWrapper);

// Suffix
var suffixWrapper = document.createElement("td");
suffixWrapper.innerHTML = sub.suffix;
suffixWrapper.className = "align-left";
subWrapper.appendChild(suffixWrapper);

wrapper.appendChild(subWrapper);
});

Expand Down
4 changes: 4 additions & 0 deletions MQTT.css
Expand Up @@ -4,4 +4,8 @@

.border_top td{
border-top: 1pt solid #444444;
}

td {
padding-right: 5px;
}
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -30,7 +30,8 @@ This is the default configuration with description. Put it in the `MagicMirror/c
{
topic: 'sensor/1/temperature',
label: 'Temperature',
decimals: 1
decimals: 1,
suffix: '°C'
},
{
topic: 'sensor/1/humidity',
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -4,7 +4,6 @@
"description": "Show payload from subscribed MQTT message",
"author": "Otto Paulsen",
"dependencies": {
"json-pointer": "^0.6.0",
"jsonpointer": "^4.0.1",
"mqtt": "^2.15.1"
}
Expand Down

0 comments on commit 20cc4c3

Please sign in to comment.