node-red-contrib-huemagic 4.0.2 → 4.0.3
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.
- package/README.md +10 -10
- package/examples/Hue Bridge.json +1 -1
- package/huemagic/hue-bridge-config.html +4 -4
- package/huemagic/hue-bridge-config.js +130 -127
- package/huemagic/hue-bridge.js +5 -5
- package/huemagic/hue-brightness.html +7 -7
- package/huemagic/hue-brightness.js +11 -5
- package/huemagic/hue-buttons.html +7 -7
- package/huemagic/hue-buttons.js +11 -5
- package/huemagic/hue-group.html +11 -11
- package/huemagic/hue-group.js +3 -3
- package/huemagic/hue-light.html +7 -7
- package/huemagic/hue-light.js +3 -3
- package/huemagic/hue-motion.html +7 -7
- package/huemagic/hue-motion.js +11 -5
- package/huemagic/hue-rules.html +5 -5
- package/huemagic/hue-rules.js +10 -4
- package/huemagic/hue-scene.html +5 -5
- package/huemagic/hue-scene.js +1 -1
- package/huemagic/hue-temperature.html +7 -7
- package/huemagic/hue-temperature.js +11 -5
- package/huemagic/locales/de/hue-bridge.json +1 -1
- package/huemagic/locales/en-US/hue-bridge.json +1 -1
- package/huemagic/locales/en-US/hue-buttons.html +1 -1
- package/huemagic/locales/en-US/hue-magic.html +2 -2
- package/huemagic/locales/en-US/hue-motion.html +1 -1
- package/huemagic/locales/en-US/hue-temperature.html +1 -1
- package/huemagic/utils/api.js +45 -45
- package/huemagic/utils/messages.js +124 -124
- package/package.json +1 -1
|
@@ -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/
|
|
98
|
+
$.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "motion" })
|
|
99
99
|
.done( function(data) {
|
|
100
|
-
var
|
|
101
|
-
if(
|
|
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
|
-
|
|
109
|
+
allResources.forEach(function(resource)
|
|
110
110
|
{
|
|
111
|
-
if(
|
|
111
|
+
if(resource.model)
|
|
112
112
|
{
|
|
113
|
-
options[
|
|
113
|
+
options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
|
|
114
114
|
}
|
|
115
115
|
else
|
|
116
116
|
{
|
|
117
|
-
options[
|
|
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
|
-
//
|
|
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 = (typeof msg.topic != 'undefined' && msg.topic
|
|
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
|
|
138
|
+
if((msg.payload === true || msg.payload === false) && (msg.payload != currentState.payload.active))
|
|
133
139
|
{
|
|
134
140
|
// PREPARE PATCH
|
|
135
|
-
patchObject
|
|
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/
|
|
98
|
+
$.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "button" })
|
|
99
99
|
.done( function(data) {
|
|
100
|
-
var
|
|
101
|
-
if(
|
|
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
|
-
|
|
109
|
+
allResources.forEach(function(resource)
|
|
110
110
|
{
|
|
111
|
-
if(
|
|
111
|
+
if(resource.model)
|
|
112
112
|
{
|
|
113
|
-
options[
|
|
113
|
+
options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
|
|
114
114
|
}
|
|
115
115
|
else
|
|
116
116
|
{
|
|
117
|
-
options[
|
|
117
|
+
options[resource.id] = { value: resource.id, label: resource.name };
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
|
package/huemagic/hue-buttons.js
CHANGED
|
@@ -43,7 +43,7 @@ module.exports = function(RED)
|
|
|
43
43
|
{
|
|
44
44
|
let currentState = bridge.get("button", info.id);
|
|
45
45
|
|
|
46
|
-
//
|
|
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.
|
|
105
|
+
for (const [oneButtonID, oneButton] of Object.entries(bridge.resources[config.sensorid]["services"]["button"]))
|
|
106
106
|
{
|
|
107
|
-
delete bridge.
|
|
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 = (typeof msg.topic != 'undefined' && msg.topic
|
|
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
|
package/huemagic/hue-group.html
CHANGED
|
@@ -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/
|
|
98
|
+
$.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "group" })
|
|
99
99
|
.done( function(data) {
|
|
100
|
-
var
|
|
101
|
-
if(
|
|
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
|
-
|
|
109
|
+
allResources.forEach(function(resource)
|
|
110
110
|
{
|
|
111
|
-
if(!
|
|
111
|
+
if(!resource.name) // ALL SPECIAL
|
|
112
112
|
{
|
|
113
|
-
options[
|
|
113
|
+
options[resource.id] = { value: resource.id, label: "● "+scope._("hue-group.config.all") };
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
allResources.forEach(function(resource)
|
|
118
118
|
{
|
|
119
|
-
if(
|
|
119
|
+
if(resource.name) // REGULAR GROUPS
|
|
120
120
|
{
|
|
121
|
-
if(
|
|
121
|
+
if(resource.model)
|
|
122
122
|
{
|
|
123
|
-
options[
|
|
123
|
+
options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
|
|
124
124
|
}
|
|
125
125
|
else
|
|
126
126
|
{
|
|
127
|
-
options[
|
|
127
|
+
options[resource.id] = { value: resource.id, label: resource.name };
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
});
|
package/huemagic/hue-group.js
CHANGED
|
@@ -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
|
-
//
|
|
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 = (typeof msg.topic != 'undefined' && msg.topic
|
|
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
|
package/huemagic/hue-light.html
CHANGED
|
@@ -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/
|
|
105
|
+
$.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "light" })
|
|
106
106
|
.done( function(data) {
|
|
107
|
-
var
|
|
108
|
-
if(
|
|
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
|
-
|
|
116
|
+
allResources.forEach(function(resource)
|
|
117
117
|
{
|
|
118
|
-
if(
|
|
118
|
+
if(resource.model)
|
|
119
119
|
{
|
|
120
|
-
options[
|
|
120
|
+
options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
|
|
121
121
|
}
|
|
122
122
|
else
|
|
123
123
|
{
|
|
124
|
-
options[
|
|
124
|
+
options[resource.id] = { value: resource.id, label: resource.name };
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
|
package/huemagic/hue-light.js
CHANGED
|
@@ -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
|
-
//
|
|
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 = (typeof msg.topic != 'undefined' && msg.topic
|
|
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
|
package/huemagic/hue-motion.html
CHANGED
|
@@ -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/
|
|
98
|
+
$.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "motion" })
|
|
99
99
|
.done( function(data) {
|
|
100
|
-
var
|
|
101
|
-
if(
|
|
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
|
-
|
|
109
|
+
allResources.forEach(function(resource)
|
|
110
110
|
{
|
|
111
|
-
if(
|
|
111
|
+
if(resource.model)
|
|
112
112
|
{
|
|
113
|
-
options[
|
|
113
|
+
options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
|
|
114
114
|
}
|
|
115
115
|
else
|
|
116
116
|
{
|
|
117
|
-
options[
|
|
117
|
+
options[resource.id] = { value: resource.id, label: resource.name };
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
|
package/huemagic/hue-motion.js
CHANGED
|
@@ -40,7 +40,7 @@ module.exports = function(RED)
|
|
|
40
40
|
{
|
|
41
41
|
let currentState = bridge.get("motion", info.id);
|
|
42
42
|
|
|
43
|
-
//
|
|
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 = (typeof msg.topic != 'undefined' && msg.topic
|
|
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
|
|
132
|
+
if((msg.payload === true || msg.payload === false) && (msg.payload != currentState.payload.active))
|
|
127
133
|
{
|
|
128
134
|
// PREPARE PATCH
|
|
129
|
-
patchObject
|
|
135
|
+
patchObject["enabled"] = (msg.payload == true);
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
//
|
package/huemagic/hue-rules.html
CHANGED
|
@@ -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/
|
|
98
|
+
$.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "rule" })
|
|
99
99
|
.done( function(data) {
|
|
100
|
-
var
|
|
101
|
-
if(
|
|
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
|
-
|
|
109
|
+
allResources.forEach(function(resource)
|
|
110
110
|
{
|
|
111
|
-
options[
|
|
111
|
+
options[resource.id] = { value: resource.id, label: resource.name };
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
// SELECT CURRENT VALUE
|
package/huemagic/hue-rules.js
CHANGED
|
@@ -40,7 +40,7 @@ module.exports = function(RED)
|
|
|
40
40
|
{
|
|
41
41
|
let currentState = bridge.get("rule", info.id);
|
|
42
42
|
|
|
43
|
-
//
|
|
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 = (typeof msg.topic != 'undefined' && msg.topic
|
|
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/"+
|
|
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
|
|
package/huemagic/hue-scene.html
CHANGED
|
@@ -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/
|
|
84
|
+
$.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "scene" })
|
|
85
85
|
.done( function(data) {
|
|
86
|
-
var
|
|
87
|
-
if(
|
|
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
|
-
|
|
95
|
+
allResources.forEach(function(resource)
|
|
96
96
|
{
|
|
97
|
-
sceneOptions[
|
|
97
|
+
sceneOptions[resource.id] = { value: resource.id, label: resource.name + " ("+resource.group+")" };
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
// SELECT CURRENT VALUE
|
package/huemagic/hue-scene.js
CHANGED
|
@@ -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.
|
|
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/
|
|
98
|
+
$.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "temperature" })
|
|
99
99
|
.done( function(data) {
|
|
100
|
-
var
|
|
101
|
-
if(
|
|
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
|
-
|
|
109
|
+
allResources.forEach(function(resource)
|
|
110
110
|
{
|
|
111
|
-
if(
|
|
111
|
+
if(resource.model)
|
|
112
112
|
{
|
|
113
|
-
options[
|
|
113
|
+
options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
|
|
114
114
|
}
|
|
115
115
|
else
|
|
116
116
|
{
|
|
117
|
-
options[
|
|
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
|
-
//
|
|
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 = (typeof msg.topic != 'undefined' && msg.topic
|
|
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
|
|
140
|
+
if((msg.payload === true || msg.payload === false) && (msg.payload != currentState.payload.active))
|
|
135
141
|
{
|
|
136
142
|
// PREPARE PATCH
|
|
137
|
-
patchObject
|
|
143
|
+
patchObject["enabled"] = (msg.payload == true);
|
|
138
144
|
}
|
|
139
145
|
|
|
140
146
|
//
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"connected": "verbunden",
|
|
17
17
|
"starting-tl": "starte TouchLink…",
|
|
18
18
|
"started-tl": "TouchLink gestartet",
|
|
19
|
-
"f-
|
|
19
|
+
"f-resources": "hole Ressouren…",
|
|
20
20
|
"updating-settings": "aktualisiere Einstellungen…",
|
|
21
21
|
"settings-updated": "Einstellungen aktualisiert",
|
|
22
22
|
"input": "Einstellungen / Abrufen",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"connected": "connected",
|
|
17
17
|
"starting-tl": "starting TouchLink…",
|
|
18
18
|
"started-tl": "TouchLink started…",
|
|
19
|
-
"f-
|
|
19
|
+
"f-resources": "fetching resources…",
|
|
20
20
|
"updating-settings": "updating settings…",
|
|
21
21
|
"settings-updated": "settings updated",
|
|
22
22
|
"input": "settings / fetch",
|
|
@@ -3,7 +3,7 @@ The "Hue Buttons" node receives switching events from input devices connected to
|
|
|
3
3
|
|
|
4
4
|
### Setup
|
|
5
5
|
|
|
6
|
-
Select the pre-configured Hue Bridge and hit the search button to find all the available switches/buttons. If you already know the ID of the
|
|
6
|
+
Select the pre-configured Hue Bridge and hit the search button to find all the available switches/buttons. If you already know the ID of the switches/buttons, you can also enter it here manually. You can either assign a new name for the switches/buttons internally or keep the predefined name of the device. Optionally, you can also deactivate all automatic status messages for this node by clicking the setting "Skip events from node". The node will then no longer output any switching events. Alternatively, you can also choose whether the node's initialization message should not be suppressed when Node-RED is started. If you activate this setting, you will receive a status message for the currently selected switches/buttons after each deployment.
|
|
7
7
|
|
|
8
8
|
If you do not select a switch/button and use the node configuration in this way, the node works in the so-called "universal mode". In this mode, the node receives and outputs all status messages of the same type.
|
|
9
9
|
|
|
@@ -22,11 +22,11 @@ Create an `array` with the respective animation steps in the form of an object a
|
|
|
22
22
|
: delay (int): Number of milliseconds to wait until this step is carried out
|
|
23
23
|
: animation (object): The object contains the action(s) to be carried out in this step. Identical parameters as for the "Hue Light" & "Hue Group" nodes
|
|
24
24
|
|
|
25
|
-
### Example of
|
|
25
|
+
### Example of a custom animation
|
|
26
26
|
|
|
27
27
|
This example shows what a simple animation could look like. In the first step, the delay of 500 milliseconds is waited for. The color of the light is then slowly changed to red over a period of one second. As soon as the light has completely changed to red, the second step is carried out, which also has a delay of 500 milliseconds. Finally the color changes to blue.
|
|
28
28
|
|
|
29
|
-
If you have set the animation to
|
|
29
|
+
If you have set the animation to loop, this process is repeated indefinitely until you manually stop the animation or redeploy the node.
|
|
30
30
|
|
|
31
31
|
Pass the following object in `msg.payload` to play the example animation.
|
|
32
32
|
|
|
@@ -17,7 +17,7 @@ Outputs the current status of the sensor as soon as a `msg.payload` object with
|
|
|
17
17
|
|
|
18
18
|
If necessary, the sensor can be turned on and off remotely. If the sensor has been turned off, it no longer registers any movements and accordingly no longer outputs them. To do this, pass an object with the following content:
|
|
19
19
|
|
|
20
|
-
: payload (boolean): `true` turns the sensor on
|
|
20
|
+
: payload (boolean): `true` turns the sensor on, `false` turns it off
|
|
21
21
|
|
|
22
22
|
### Status messages from the node
|
|
23
23
|
|
|
@@ -30,7 +30,7 @@ As soon as the sensor has registered a temperature change, the following status
|
|
|
30
30
|
: connectionStatus (string): The current connection status with the bridge in the form of a string. Can contain `connected`, `disconnected`, `connectivity_issue` or `unidirectional_incoming` as a value
|
|
31
31
|
: celsius (float): Indicates the current ambient temperature in °C (degrees Celsius)
|
|
32
32
|
: fahrenheit (float): Indicates the current ambient temperature in °F (degrees Fahrenheit)
|
|
33
|
-
: temperatureIs (string): Describes the current temperature with the values
|
|
33
|
+
: temperatureIs (string): Describes the current temperature with the values `very cold`, `cold`, `slightly cold`, `comfortable`, `slightly warm`, `warm`, `hot` or `very hot`
|
|
34
34
|
: deviceValue (float): The original value of the temperature from the sensor
|
|
35
35
|
: updated (string): Time of the last update of the resource by HueMagic (ISO 8601)
|
|
36
36
|
|