node-red-contrib-huemagic 4.0.0 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,11 +79,11 @@ module.exports = function(RED)
79
79
 
80
80
  //
81
81
  // SUBSCRIBE TO UPDATES FROM THE BRIDGE
82
- bridge.subscribe("bridge", "globalRessourceUpdates", async function(info)
82
+ bridge.subscribe("bridge", "globalResourceUpdates", async function(info)
83
83
  {
84
84
  let currentState = bridge.get(info.updatedType, info.id);
85
85
 
86
- // RESSOURCE FOUND?
86
+ // RESOURCE FOUND?
87
87
  if(currentState !== false)
88
88
  {
89
89
  // UPDATE COUNTER
@@ -138,7 +138,7 @@ module.exports = function(RED)
138
138
  done = done || function() { scope.done.apply(scope,arguments); }
139
139
 
140
140
  // SET LAST COMMAND
141
- scope.lastCommand = msg;
141
+ scope.lastCommand = RED.util.cloneMessage(msg);
142
142
 
143
143
  // GET BRIDGE INFORMATION
144
144
  scope.getBridgeInformation()
@@ -171,7 +171,7 @@ module.exports = function(RED)
171
171
  if(done) { done(error); }
172
172
  });
173
173
  }
174
- // FETCH RESSOURCES
174
+ // FETCH RESOURCES
175
175
  else if(typeof msg.payload != 'undefined' && typeof msg.payload.fetch != 'undefined')
176
176
  {
177
177
  let fetchTypes = [];
@@ -179,7 +179,7 @@ module.exports = function(RED)
179
179
  else if(typeof msg.payload.fetch == 'object') { fetchTypes = msg.payload.fetch; }
180
180
  else { return false; }
181
181
 
182
- scope.status({fill: "blue", shape: "dot", text: "hue-bridge.node.f-ressources" });
182
+ scope.status({fill: "blue", shape: "dot", text: "hue-bridge.node.f-resources" });
183
183
 
184
184
  // FETCH
185
185
  bridgeInformation.results = {};
@@ -95,10 +95,10 @@
95
95
  var notification = RED.notify(scope._("hue-brightness.config.searching"), { type: "compact", modal: true, fixed: true });
96
96
 
97
97
  // GET THE SENSORS
98
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "motion" })
98
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "motion" })
99
99
  .done( function(data) {
100
- var allRessources = JSON.parse(data);
101
- if(allRessources.length <= 0)
100
+ var allResources = JSON.parse(data);
101
+ if(allResources.length <= 0)
102
102
  {
103
103
  notification.close();
104
104
  RED.notify(scope._("hue-brightness.config.none-found"), { type: "light_level" });
@@ -106,15 +106,15 @@
106
106
  }
107
107
 
108
108
  // SET OPTIONS
109
- allRessources.forEach(function(ressource)
109
+ allResources.forEach(function(resource)
110
110
  {
111
- if(ressource.model)
111
+ if(resource.model)
112
112
  {
113
- options[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.model+")" };
113
+ options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
114
114
  }
115
115
  else
116
116
  {
117
- options[ressource.id] = { value: ressource.id, label: ressource.name };
117
+ options[resource.id] = { value: resource.id, label: resource.name };
118
118
  }
119
119
  });
120
120
 
@@ -40,7 +40,7 @@ module.exports = function(RED)
40
40
  {
41
41
  let currentState = bridge.get("light_level", info.id);
42
42
 
43
- // RESSOURCE FOUND?
43
+ // RESOURCE FOUND?
44
44
  if(currentState !== false)
45
45
  {
46
46
  // SEND MESSAGE
@@ -100,13 +100,19 @@ module.exports = function(RED)
100
100
  done = done || function() { scope.done.apply(scope,arguments); }
101
101
 
102
102
  // SET LAST COMMAND
103
- scope.lastCommand = msg;
103
+ scope.lastCommand = RED.util.cloneMessage(msg);
104
104
 
105
105
  // CREATE PATCH
106
106
  let patchObject = {};
107
107
 
108
108
  // DEFINE SENSOR ID & CURRENT STATE
109
- const tempSensorID = (msg.topic != null) ? msg.topic : config.sensorid;
109
+ const tempSensorID = (!config.sensorid && typeof msg.topic != 'undefined' && bridge.validResourceID.test(msg.topic) === true) ? msg.topic : config.sensorid;
110
+ if(!tempSensorID)
111
+ {
112
+ scope.error("Please submit a valid sensor ID.");
113
+ return false;
114
+ }
115
+
110
116
  let currentState = bridge.get("light_level", tempSensorID);
111
117
 
112
118
  // GET CURRENT STATE
@@ -129,10 +135,10 @@ module.exports = function(RED)
129
135
  }
130
136
 
131
137
  // TURN ON / OFF
132
- if((msg.payload === true || msg.payload === false) && (msg.payload !== currentState.payload.active))
138
+ if((msg.payload === true || msg.payload === false) && (msg.payload != currentState.payload.active))
133
139
  {
134
140
  // PREPARE PATCH
135
- patchObject.enabled = msg.payload;
141
+ patchObject["enabled"] = (msg.payload == true);
136
142
  }
137
143
 
138
144
  //
@@ -95,10 +95,10 @@
95
95
  var notification = RED.notify(scope._("hue-buttons.config.searching"), { type: "compact", modal: true, fixed: true });
96
96
 
97
97
  // GET THE SENSORS
98
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "button" })
98
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "button" })
99
99
  .done( function(data) {
100
- var allRessources = JSON.parse(data);
101
- if(allRessources.length <= 0)
100
+ var allResources = JSON.parse(data);
101
+ if(allResources.length <= 0)
102
102
  {
103
103
  notification.close();
104
104
  RED.notify(scope._("hue-buttons.config.none-found"), { type: "error" });
@@ -106,15 +106,15 @@
106
106
  }
107
107
 
108
108
  // SET OPTIONS
109
- allRessources.forEach(function(ressource)
109
+ allResources.forEach(function(resource)
110
110
  {
111
- if(ressource.model)
111
+ if(resource.model)
112
112
  {
113
- options[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.model+")" };
113
+ options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
114
114
  }
115
115
  else
116
116
  {
117
- options[ressource.id] = { value: ressource.id, label: ressource.name };
117
+ options[resource.id] = { value: resource.id, label: resource.name };
118
118
  }
119
119
  });
120
120
 
@@ -43,7 +43,7 @@ module.exports = function(RED)
43
43
  {
44
44
  let currentState = bridge.get("button", info.id);
45
45
 
46
- // RESSOURCE FOUND?
46
+ // RESOURCE FOUND?
47
47
  if(currentState !== false)
48
48
  {
49
49
  // SEND MESSAGE
@@ -102,9 +102,9 @@ module.exports = function(RED)
102
102
  scope.status({fill: "grey", shape: "dot", text: "hue-buttons.node.waiting"});
103
103
 
104
104
  // REMOVE OLD BUTTON STATES
105
- for (const [oneButtonID, oneButton] of Object.entries(bridge.ressources[config.sensorid]["services"]["button"]))
105
+ for (const [oneButtonID, oneButton] of Object.entries(bridge.resources[config.sensorid]["services"]["button"]))
106
106
  {
107
- delete bridge.ressources[config.sensorid]["services"]["button"][oneButtonID]["button"];
107
+ delete bridge.resources[config.sensorid]["services"]["button"][oneButtonID]["button"];
108
108
  }
109
109
  }, 3000);
110
110
  }
@@ -121,10 +121,16 @@ module.exports = function(RED)
121
121
  done = done || function() { scope.done.apply(scope,arguments); }
122
122
 
123
123
  // SAVE LAST COMMAND
124
- scope.lastCommand = msg;
124
+ scope.lastCommand = RED.util.cloneMessage(msg);
125
125
 
126
126
  // DEFINE SENSOR ID
127
- const tempSensorID = (msg.topic != null) ? msg.topic : config.sensorid;
127
+ const tempSensorID = (!config.sensorid && typeof msg.topic != 'undefined' && bridge.validResourceID.test(msg.topic) === true) ? msg.topic : config.sensorid;
128
+ if(!tempSensorID)
129
+ {
130
+ scope.error("Please submit a valid button ID.");
131
+ return false;
132
+ }
133
+
128
134
  let currentState = bridge.get("button", tempSensorID);
129
135
 
130
136
  // GET CURRENT STATE
@@ -95,10 +95,10 @@
95
95
  var notification = RED.notify(scope._("hue-group.config.searching"), { type: "compact", modal: true, fixed: true });
96
96
 
97
97
  // GET THE GROUPS
98
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "group" })
98
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "group" })
99
99
  .done( function(data) {
100
- var allRessources = JSON.parse(data);
101
- if(allRessources.length <= 0)
100
+ var allResources = JSON.parse(data);
101
+ if(allResources.length <= 0)
102
102
  {
103
103
  notification.close();
104
104
  RED.notify(scope._("hue-group.config.none-found"), { type: "error" });
@@ -106,25 +106,25 @@
106
106
  }
107
107
 
108
108
  // SET GROUPS AS OPTIONS
109
- allRessources.forEach(function(ressource)
109
+ allResources.forEach(function(resource)
110
110
  {
111
- if(!ressource.name) // ALL SPECIAL
111
+ if(!resource.name) // ALL SPECIAL
112
112
  {
113
- options[ressource.id] = { value: ressource.id, label: "● "+scope._("hue-group.config.all") };
113
+ options[resource.id] = { value: resource.id, label: "● "+scope._("hue-group.config.all") };
114
114
  }
115
115
  });
116
116
 
117
- allRessources.forEach(function(ressource)
117
+ allResources.forEach(function(resource)
118
118
  {
119
- if(ressource.name) // REGULAR GROUPS
119
+ if(resource.name) // REGULAR GROUPS
120
120
  {
121
- if(ressource.model)
121
+ if(resource.model)
122
122
  {
123
- options[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.model+")" };
123
+ options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
124
124
  }
125
125
  else
126
126
  {
127
- options[ressource.id] = { value: ressource.id, label: ressource.name };
127
+ options[resource.id] = { value: resource.id, label: resource.name };
128
128
  }
129
129
  }
130
130
  });
@@ -50,7 +50,7 @@ module.exports = function(RED)
50
50
  {
51
51
  let currentState = bridge.get("group", info.id, { colornames: config.colornamer ? true : false });
52
52
 
53
- // RESSOURCE FOUND?
53
+ // RESOURCE FOUND?
54
54
  if(currentState !== false)
55
55
  {
56
56
  // NOT IN UNIVERAL MODE? -> CHANGE UI STATES
@@ -102,13 +102,13 @@ module.exports = function(RED)
102
102
  send = send || function() { scope.send.apply(scope,arguments); }
103
103
 
104
104
  // SAVE LAST COMMAND
105
- scope.lastCommand = msg;
105
+ scope.lastCommand = RED.util.cloneMessage(msg);
106
106
 
107
107
  // CREATE PATCH
108
108
  let patchObject = {};
109
109
 
110
110
  // DEFINE SENSOR ID & CURRENT STATE
111
- const tempGroupID = (msg.topic != null) ? msg.topic : config.groupid;
111
+ const tempGroupID = (!config.groupid && typeof msg.topic != 'undefined' && bridge.validResourceID.test(msg.topic) === true) ? msg.topic : config.groupid;
112
112
  let currentState = bridge.get("group", tempGroupID, { colornames: config.colornamer ? true : false });
113
113
 
114
114
  // CHECK IF LIGHT ID IS SET
@@ -102,10 +102,10 @@
102
102
  var notification = RED.notify(scope._("hue-light.config.searching"), { type: "compact", modal: true, fixed: true });
103
103
 
104
104
  // GET THE LIGHTS
105
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "light" })
105
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "light" })
106
106
  .done( function(data) {
107
- var allRessources = JSON.parse(data);
108
- if(allRessources.length <= 0)
107
+ var allResources = JSON.parse(data);
108
+ if(allResources.length <= 0)
109
109
  {
110
110
  notification.close();
111
111
  RED.notify(scope._("hue-light.config.none-found"), { type: "error" });
@@ -113,15 +113,15 @@
113
113
  }
114
114
 
115
115
  // SET OPTIONS
116
- allRessources.forEach(function(ressource)
116
+ allResources.forEach(function(resource)
117
117
  {
118
- if(ressource.model)
118
+ if(resource.model)
119
119
  {
120
- options[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.model+")" };
120
+ options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
121
121
  }
122
122
  else
123
123
  {
124
- options[ressource.id] = { value: ressource.id, label: ressource.name };
124
+ options[resource.id] = { value: resource.id, label: resource.name };
125
125
  }
126
126
  });
127
127
 
@@ -47,7 +47,7 @@ module.exports = function(RED)
47
47
  {
48
48
  let currentState = bridge.get("light", info.id, { colornames: config.colornamer ? true : false });
49
49
 
50
- // RESSOURCE FOUND?
50
+ // RESOURCE FOUND?
51
51
  if(currentState !== false)
52
52
  {
53
53
  // SEND MESSAGE
@@ -115,13 +115,13 @@ module.exports = function(RED)
115
115
  done = done || function() { scope.done.apply(scope,arguments); }
116
116
 
117
117
  // SAVE LAST COMMAND
118
- scope.lastCommand = msg;
118
+ scope.lastCommand = RED.util.cloneMessage(msg);
119
119
 
120
120
  // CREATE PATCH
121
121
  let patchObject = {};
122
122
 
123
123
  // DEFINE SENSOR ID & CURRENT STATE
124
- const tempLightID = (msg.topic != null) ? msg.topic : config.lightid;
124
+ const tempLightID = (!config.lightid && typeof msg.topic != 'undefined' && bridge.validResourceID.test(msg.topic) === true) ? msg.topic : config.lightid;
125
125
  let currentState = bridge.get("light", tempLightID, { colornames: config.colornamer ? true : false });
126
126
 
127
127
  // CHECK IF LIGHT ID IS SET
@@ -95,10 +95,10 @@
95
95
  var notification = RED.notify(scope._("hue-motion.config.searching"), { type: "compact", modal: true, fixed: true });
96
96
 
97
97
  // GET THE SENSORS
98
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "motion" })
98
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "motion" })
99
99
  .done( function(data) {
100
- var allRessources = JSON.parse(data);
101
- if(allRessources.length <= 0)
100
+ var allResources = JSON.parse(data);
101
+ if(allResources.length <= 0)
102
102
  {
103
103
  notification.close();
104
104
  RED.notify(scope._("hue-motion.config.none-found"), { type: "error" });
@@ -106,15 +106,15 @@
106
106
  }
107
107
 
108
108
  // SET OPTIONS
109
- allRessources.forEach(function(ressource)
109
+ allResources.forEach(function(resource)
110
110
  {
111
- if(ressource.model)
111
+ if(resource.model)
112
112
  {
113
- options[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.model+")" };
113
+ options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
114
114
  }
115
115
  else
116
116
  {
117
- options[ressource.id] = { value: ressource.id, label: ressource.name };
117
+ options[resource.id] = { value: resource.id, label: resource.name };
118
118
  }
119
119
  });
120
120
 
@@ -40,7 +40,7 @@ module.exports = function(RED)
40
40
  {
41
41
  let currentState = bridge.get("motion", info.id);
42
42
 
43
- // RESSOURCE FOUND?
43
+ // RESOURCE FOUND?
44
44
  if(currentState !== false)
45
45
  {
46
46
  // SEND MESSAGE
@@ -94,13 +94,19 @@ module.exports = function(RED)
94
94
  done = done || function() { scope.done.apply(scope,arguments); }
95
95
 
96
96
  // SAVE LAST COMMAND
97
- scope.lastCommand = msg;
97
+ scope.lastCommand = RED.util.cloneMessage(msg);
98
98
 
99
99
  // CREATE PATCH
100
100
  let patchObject = {};
101
101
 
102
102
  // DEFINE SENSOR ID & CURRENT STATE
103
- const tempSensorID = (msg.topic != null) ? msg.topic : config.sensorid;
103
+ const tempSensorID = (!config.sensorid && typeof msg.topic != 'undefined' && bridge.validResourceID.test(msg.topic) === true) ? msg.topic : config.sensorid;
104
+ if(!tempSensorID)
105
+ {
106
+ scope.error("Please submit a valid sensor ID.");
107
+ return false;
108
+ }
109
+
104
110
  let currentState = bridge.get("motion", tempSensorID);
105
111
 
106
112
  // GET CURRENT STATE
@@ -123,10 +129,10 @@ module.exports = function(RED)
123
129
  }
124
130
 
125
131
  // TURN ON / OFF
126
- if((msg.payload === true || msg.payload === false) && (msg.payload !== currentState.payload.active))
132
+ if((msg.payload === true || msg.payload === false) && (msg.payload != currentState.payload.active))
127
133
  {
128
134
  // PREPARE PATCH
129
- patchObject.enabled = msg.payload;
135
+ patchObject["enabled"] = (msg.payload == true);
130
136
  }
131
137
 
132
138
  //
@@ -95,10 +95,10 @@
95
95
  var notification = RED.notify(scope._("hue-rules.config.searching"), { type: "compact", modal: true, fixed: true });
96
96
 
97
97
  // GET THE SENSORS
98
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "rule" })
98
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "rule" })
99
99
  .done( function(data) {
100
- var allRessources = JSON.parse(data);
101
- if(allRessources.length <= 0)
100
+ var allResources = JSON.parse(data);
101
+ if(allResources.length <= 0)
102
102
  {
103
103
  notification.close();
104
104
  RED.notify(scope._("hue-rules.config.none-found"), { type: "error" });
@@ -106,9 +106,9 @@
106
106
  }
107
107
 
108
108
  // SET OPTIONS
109
- allRessources.forEach(function(ressource)
109
+ allResources.forEach(function(resource)
110
110
  {
111
- options[ressource.id] = { value: ressource.id, label: ressource.name };
111
+ options[resource.id] = { value: resource.id, label: resource.name };
112
112
  });
113
113
 
114
114
  // SELECT CURRENT VALUE
@@ -40,7 +40,7 @@ module.exports = function(RED)
40
40
  {
41
41
  let currentState = bridge.get("rule", info.id);
42
42
 
43
- // RESSOURCE FOUND?
43
+ // RESOURCE FOUND?
44
44
  if(currentState !== false)
45
45
  {
46
46
  // NOT IN UNIVERAL MODE? -> CHANGE UI STATES
@@ -84,13 +84,19 @@ module.exports = function(RED)
84
84
  done = done || function() { scope.done.apply(scope,arguments); }
85
85
 
86
86
  // SAVE LAST COMMAND
87
- scope.lastCommand = msg;
87
+ scope.lastCommand = RED.util.cloneMessage(msg);
88
88
 
89
89
  // CREATE PATCH
90
90
  let patchObject = {};
91
91
 
92
92
  // DEFINE SENSOR ID & CURRENT STATE
93
- const tempRuleID = (msg.topic != null) ? msg.topic : config.ruleid;
93
+ const tempRuleID = (!config.ruleid && typeof msg.topic != 'undefined' && isNaN(msg.topic) == false) ? msg.topic : config.ruleid;
94
+ if(!tempRuleID)
95
+ {
96
+ scope.error("Please submit a valid rule ID.");
97
+ return false;
98
+ }
99
+
94
100
  let currentState = bridge.get("rule", "rule_" + tempRuleID);
95
101
 
96
102
  // CONTROL RULE
@@ -100,7 +106,7 @@ module.exports = function(RED)
100
106
  patchObject["status"] = (msg.payload == true) ? 'enabled' : 'disabled';
101
107
 
102
108
  // PATCH!
103
- bridge.patch("rules", "/rules/"+config.ruleid, patchObject, 1)
109
+ bridge.patch("rules", "/rules/"+tempRuleID, patchObject, 1)
104
110
  .then(function(response) { bridge.refetchRule(tempRuleID); })
105
111
  .catch(function(errors) { scope.error(errors); });
106
112
 
@@ -81,10 +81,10 @@
81
81
  var notification = RED.notify(scope._("hue-rules.config.searching"), { type: "compact", modal: true, fixed: true });
82
82
 
83
83
  // GET THE SCENES
84
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "scene" })
84
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "scene" })
85
85
  .done( function(data) {
86
- var allRessources = JSON.parse(data);
87
- if(allRessources.length <= 0)
86
+ var allResources = JSON.parse(data);
87
+ if(allResources.length <= 0)
88
88
  {
89
89
  notification.close();
90
90
  RED.notify(scope._("hue-scene.config.none-found"), { type: "error" });
@@ -92,9 +92,9 @@
92
92
  }
93
93
 
94
94
  // SET OPTIONS
95
- allRessources.forEach(function(ressource)
95
+ allResources.forEach(function(resource)
96
96
  {
97
- sceneOptions[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.group+")" };
97
+ sceneOptions[resource.id] = { value: resource.id, label: resource.name + " ("+resource.group+")" };
98
98
  });
99
99
 
100
100
  // SELECT CURRENT VALUE
@@ -60,7 +60,7 @@ module.exports = function(RED)
60
60
  // RECALL ON GROUP? -> USE API v1
61
61
  if(copyOfTargetGroups.length > 0)
62
62
  {
63
- let targetSceneID = bridge.ressources[sceneDef].id_v1.replace("/scenes/", "");
63
+ let targetSceneID = bridge.resources[sceneDef].id_v1.replace("/scenes/", "");
64
64
 
65
65
  // SEND STATUS
66
66
  scope.status({fill: "blue", shape: "dot", text: "hue-scene.node.recalled-on-group"})
@@ -95,10 +95,10 @@
95
95
  var notification = RED.notify(scope._("hue-temperature.config.searching"), { type: "compact", modal: true, fixed: true });
96
96
 
97
97
  // GET THE SENSORS
98
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "temperature" })
98
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "temperature" })
99
99
  .done( function(data) {
100
- var allRessources = JSON.parse(data);
101
- if(allRessources.length <= 0)
100
+ var allResources = JSON.parse(data);
101
+ if(allResources.length <= 0)
102
102
  {
103
103
  notification.close();
104
104
  RED.notify(scope._("hue-temperature.config.none-found"), { type: "error" });
@@ -106,15 +106,15 @@
106
106
  }
107
107
 
108
108
  // SET OPTIONS
109
- allRessources.forEach(function(ressource)
109
+ allResources.forEach(function(resource)
110
110
  {
111
- if(ressource.model)
111
+ if(resource.model)
112
112
  {
113
- options[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.model+")" };
113
+ options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
114
114
  }
115
115
  else
116
116
  {
117
- options[ressource.id] = { value: ressource.id, label: ressource.name };
117
+ options[resource.id] = { value: resource.id, label: resource.name };
118
118
  }
119
119
  });
120
120
 
@@ -40,7 +40,7 @@ module.exports = function(RED)
40
40
  {
41
41
  let currentState = bridge.get("temperature", info.id);
42
42
 
43
- // RESSOURCE FOUND?
43
+ // RESOURCE FOUND?
44
44
  if(currentState !== false)
45
45
  {
46
46
  // SEND MESSAGE
@@ -102,13 +102,19 @@ module.exports = function(RED)
102
102
  done = done || function() { scope.done.apply(scope,arguments); }
103
103
 
104
104
  // SAVE LAST COMMAND
105
- scope.lastCommand = msg;
105
+ scope.lastCommand = RED.util.cloneMessage(msg);
106
106
 
107
107
  // CREATE PATCH
108
108
  let patchObject = {};
109
109
 
110
110
  // DEFINE SENSOR ID & CURRENT STATE
111
- const tempSensorID = (msg.topic != null) ? msg.topic : config.sensorid;
111
+ const tempSensorID = (!config.sensorid && typeof msg.topic != 'undefined' && bridge.validResourceID.test(msg.topic) === true) ? msg.topic : config.sensorid;
112
+ if(!tempSensorID)
113
+ {
114
+ scope.error("Please submit a valid sensor ID.");
115
+ return false;
116
+ }
117
+
112
118
  let currentState = bridge.get("temperature", tempSensorID);
113
119
 
114
120
  // GET CURRENT STATE
@@ -131,10 +137,10 @@ module.exports = function(RED)
131
137
  }
132
138
 
133
139
  // TURN ON / OFF
134
- if((msg.payload === true || msg.payload === false) && (msg.payload !== currentState.payload.active))
140
+ if((msg.payload === true || msg.payload === false) && (msg.payload != currentState.payload.active))
135
141
  {
136
142
  // PREPARE PATCH
137
- patchObject.enabled = msg.payload;
143
+ patchObject["enabled"] = (msg.payload == true);
138
144
  }
139
145
 
140
146
  //
@@ -59,7 +59,7 @@ Die Statusmittilungen des „Hue Bridge“-Nodes sind dynamisch. Sie folgen zwar
59
59
  : dhcpEnabled (boolean) : Gibt an, ob DHCP aktiviert ist
60
60
  : netmask (string) : Netzmaske der Bridge
61
61
  : gateway (string) : Gateway der Bridge
62
- : proxyAddress (string | false) : Aktuell verwendete Proxy-Adresse oder `false`
62
+ : proxyAddress (string | boolean) : Aktuell verwendete Proxy-Adresse oder `false`
63
63
  : proxyPort (string) : Aktuell verwender Proxy-Port
64
64
  : utcTime (string) : UTC-Zeit auf der Bridge
65
65
  : timeZone (string) : Aktuell eingestellte Zeitzone auf der Bridge
@@ -16,7 +16,7 @@
16
16
  "connected": "verbunden",
17
17
  "starting-tl": "starte TouchLink…",
18
18
  "started-tl": "TouchLink gestartet",
19
- "f-ressources": "hole Ressouren…",
19
+ "f-resources": "hole Ressouren…",
20
20
  "updating-settings": "aktualisiere Einstellungen…",
21
21
  "settings-updated": "Einstellungen aktualisiert",
22
22
  "input": "Einstellungen / Abrufen",
@@ -34,8 +34,8 @@ Sobald eine Taste gedrückt wurde, wird folgende Statusnachricht vom Node zurüc
34
34
  : name (string) : Der aktuell eingestellte Name des Schalters
35
35
  : type (string) : Der Typ des Schalters (immer `button`)
36
36
  : softwareVersion (string) : Die aktuelle Firmware des Schalters
37
- : battery (float) : Der aktuelle Batteriestand des Schalters
38
- : batteryState (string) : Der aktuelle Status des Batteriestands. Kann `normal`, `low` oder `critical` als Wert beinhalten
37
+ : battery (float | boolean) : Der aktuelle Batteriestand des Schalters, `false`, wenn keine Batterie vorhanden
38
+ : batteryState (string | boolean) : Der aktuelle Status des Batteriestands. Kann `normal`, `low` oder `critical` als Wert beinhalten, `false`, wenn keine Batterie vorhanden
39
39
  : model (object) : Beinhaltet die Modellinformationen des Schalters unter `id`, `manufacturer`, `name`, `type` und `certified`
40
40
 
41
41
  #### Zustandsänderungen unter `msg.updated`
@@ -59,7 +59,7 @@ The status reports of the "Hue Bridge" node are dynamic. Although they follow a
59
59
  : dhcpEnabled (boolean): Indicates whether DHCP is enabled
60
60
  : netmask (string): Netmask of the bridge
61
61
  : gateway (string): Gateway of the bridge
62
- : proxyAddress (string | false): Currently used proxy address or `false`
62
+ : proxyAddress (string | boolean): Currently used proxy address or `false`
63
63
  : proxyPort (string): Currently used proxy port
64
64
  : utcTime (string): UTC time on the bridge
65
65
  : timeZone (string): Currently set time zone on the bridge
@@ -79,7 +79,7 @@ If the "fetch" command has been used on the node, the bridge outputs the corresp
79
79
 
80
80
  #### Global status messages under `msg.updated` (optional)
81
81
 
82
- Unless deactivated, the node issues an updated status message for each resource on the bridge. The status message under * msg.updated * follows the pattern of the respective resource and varies depending on the type of device that was last updated.
82
+ Unless deactivated, the node outputs an updated status message for each resource on the bridge. The status message under * msg.updated * follows the pattern of the respective resource and varies depending on the type of device that was last updated.
83
83
 
84
84
  #### Last command under `msg.command` (optional)
85
85