From ab7ea0413c464500c5e51d802b3b9030cad14245 Mon Sep 17 00:00:00 2001
From: Harald Rietman Only passes the string values for temperature on output 1 and humidity on output 2. Use your own template to pass the values on. The template can contain mustache-style tags.
- Any property from the data section of the full object can be used.Template
+ {
+ "name":"Temperatuur woonkamer",
+ "characteristic":"CurrentTemperature",
+ "value":{{temperature}}
+ }
Sample message:
diff --git a/node-red-contrib-xiaomi-ht/xiaomi-ht.js b/node-red-contrib-xiaomi-ht/xiaomi-ht.js
index 54ee954..7431e7c 100644
--- a/node-red-contrib-xiaomi-ht/xiaomi-ht.js
+++ b/node-red-contrib-xiaomi-ht/xiaomi-ht.js
@@ -1,7 +1,6 @@
module.exports = function(RED) {
"use strict";
var mustache = require("mustache");
- var udpInputPortsInUse = {};
var dgram = require('dgram');
function XiaomiHtNode(config) {
@@ -11,6 +10,7 @@ module.exports = function(RED) {
this.output = config.output;
this.temperature = config.temperature;
this.humidity = config.humidity;
+ this.divide = config.divide;
var node = this;
@@ -55,10 +55,16 @@ module.exports = function(RED) {
var humidity = null;
if (data.temperature) {
+ if (this.divide) {
+ data.temperature = String(data.temperature / 100);
+ }
temp = {"payload": mustache.render(node.temperature, data)}
}
if (data.humidity) {
+ if (this.divide) {
+ data.humidity = String(data.humidity / 100);
+ }
humidity = {"payload": mustache.render(node.humidity, data)}
}
node.send([temp, humidity]);
diff --git a/package.json b/package.json
index afc088e..3496ed6 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-xiaomi-devices",
- "version": "1.0.12",
+ "version": "1.0.13",
"description": "A set of nodes to control some of the popular Xiaomi sensors which are connected to the Xiaomi Gateway.",
"repository": {
"type": "git",