node-red-contrib-huemagic 4.0.2 → 4.1.0

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.
Files changed (36) hide show
  1. package/README.md +31 -14
  2. package/examples/Hue Bridge.json +1 -1
  3. package/huemagic/hue-bridge-config.html +11 -4
  4. package/huemagic/hue-bridge-config.js +180 -154
  5. package/huemagic/hue-bridge.js +5 -5
  6. package/huemagic/hue-brightness.html +22 -8
  7. package/huemagic/hue-brightness.js +16 -5
  8. package/huemagic/hue-buttons.html +21 -7
  9. package/huemagic/hue-buttons.js +16 -5
  10. package/huemagic/hue-group.html +26 -12
  11. package/huemagic/hue-group.js +8 -3
  12. package/huemagic/hue-light.html +22 -8
  13. package/huemagic/hue-light.js +8 -3
  14. package/huemagic/hue-motion.html +22 -8
  15. package/huemagic/hue-motion.js +16 -5
  16. package/huemagic/hue-rules.html +20 -6
  17. package/huemagic/hue-rules.js +15 -4
  18. package/huemagic/hue-scene.html +20 -6
  19. package/huemagic/hue-scene.js +1 -1
  20. package/huemagic/hue-temperature.html +22 -8
  21. package/huemagic/hue-temperature.js +16 -5
  22. package/huemagic/locales/de/hue-bridge-config.html +8 -0
  23. package/huemagic/locales/de/hue-bridge.json +1 -1
  24. package/huemagic/locales/de/hue-group.html +1 -0
  25. package/huemagic/locales/en-US/hue-bridge-config.html +8 -0
  26. package/huemagic/locales/en-US/hue-bridge.html +1 -1
  27. package/huemagic/locales/en-US/hue-bridge.json +1 -1
  28. package/huemagic/locales/en-US/hue-buttons.html +1 -1
  29. package/huemagic/locales/en-US/hue-group.html +1 -0
  30. package/huemagic/locales/en-US/hue-light.html +1 -1
  31. package/huemagic/locales/en-US/hue-magic.html +3 -3
  32. package/huemagic/locales/en-US/hue-motion.html +1 -1
  33. package/huemagic/locales/en-US/hue-temperature.html +1 -1
  34. package/huemagic/utils/api.js +88 -94
  35. package/huemagic/utils/messages.js +134 -126
  36. package/package.json +2 -1
@@ -67,6 +67,19 @@
67
67
  buttonIcon.removeClass("fa-pencil");
68
68
  buttonIcon.addClass("fa-search");
69
69
  }
70
+
71
+ function sortResourcesBy(prop, resources)
72
+ {
73
+ return resources.sort((a, b) => {
74
+ if ( a[prop] < b[prop] ){
75
+ return -1;
76
+ }
77
+ if ( a[prop] > b[prop] ){
78
+ return 1;
79
+ }
80
+ return 0;
81
+ });
82
+ }
70
83
 
71
84
  function searchAndSelectScenes()
72
85
  {
@@ -81,10 +94,11 @@
81
94
  var notification = RED.notify(scope._("hue-rules.config.searching"), { type: "compact", modal: true, fixed: true });
82
95
 
83
96
  // GET THE SCENES
84
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "scene" })
97
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "scene" })
85
98
  .done( function(data) {
86
- var allRessources = JSON.parse(data);
87
- if(allRessources.length <= 0)
99
+ var allResources = JSON.parse(data);
100
+ allResources = sortResourcesBy('name', allResources);
101
+ if(allResources.length <= 0)
88
102
  {
89
103
  notification.close();
90
104
  RED.notify(scope._("hue-scene.config.none-found"), { type: "error" });
@@ -92,9 +106,9 @@
92
106
  }
93
107
 
94
108
  // SET OPTIONS
95
- allRessources.forEach(function(ressource)
109
+ allResources.forEach(function(resource)
96
110
  {
97
- sceneOptions[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.group+")" };
111
+ sceneOptions[resource.id] = { value: resource.id, label: resource.name + " ("+resource.group+")" };
98
112
  });
99
113
 
100
114
  // SELECT CURRENT VALUE
@@ -167,4 +181,4 @@
167
181
  }
168
182
  }
169
183
  });
170
- </script>
184
+ </script>
@@ -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"})
@@ -81,6 +81,19 @@
81
81
  buttonIcon.removeClass("fa-pencil");
82
82
  buttonIcon.addClass("fa-search");
83
83
  }
84
+
85
+ function sortResourcesBy(prop, resources)
86
+ {
87
+ return resources.sort((a, b) => {
88
+ if ( a[prop] < b[prop] ){
89
+ return -1;
90
+ }
91
+ if ( a[prop] > b[prop] ){
92
+ return 1;
93
+ }
94
+ return 0;
95
+ });
96
+ }
84
97
 
85
98
  function searchAndSelect()
86
99
  {
@@ -95,10 +108,11 @@
95
108
  var notification = RED.notify(scope._("hue-temperature.config.searching"), { type: "compact", modal: true, fixed: true });
96
109
 
97
110
  // GET THE SENSORS
98
- $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "temperature" })
111
+ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "temperature" })
99
112
  .done( function(data) {
100
- var allRessources = JSON.parse(data);
101
- if(allRessources.length <= 0)
113
+ var allResources = JSON.parse(data);
114
+ allResources = sortResourcesBy('name', allResources);
115
+ if(allResources.length <= 0)
102
116
  {
103
117
  notification.close();
104
118
  RED.notify(scope._("hue-temperature.config.none-found"), { type: "error" });
@@ -106,15 +120,15 @@
106
120
  }
107
121
 
108
122
  // SET OPTIONS
109
- allRessources.forEach(function(ressource)
123
+ allResources.forEach(function(resource)
110
124
  {
111
- if(ressource.model)
125
+ if(resource.model)
112
126
  {
113
- options[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.model+")" };
127
+ options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
114
128
  }
115
129
  else
116
130
  {
117
- options[ressource.id] = { value: ressource.id, label: ressource.name };
131
+ options[resource.id] = { value: resource.id, label: resource.name };
118
132
  }
119
133
  });
120
134
 
@@ -194,4 +208,4 @@
194
208
  }
195
209
  }
196
210
  });
197
- </script>
211
+ </script>
@@ -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,14 +102,25 @@ 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.length > 0) ? 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);
119
+ if(!currentState)
120
+ {
121
+ scope.error("The sensor in not yet available. Please wait until HueMagic has established a connection with the bridge or check whether the resource ID in the configuration is valid..");
122
+ return false;
123
+ }
113
124
 
114
125
  // GET CURRENT STATE
115
126
  if( (typeof msg.payload != 'undefined' && typeof msg.payload.status != 'undefined') || (typeof msg.__user_inject_props__ != 'undefined' && msg.__user_inject_props__ == "status") )
@@ -131,10 +142,10 @@ module.exports = function(RED)
131
142
  }
132
143
 
133
144
  // TURN ON / OFF
134
- if((msg.payload === true || msg.payload === false) && (msg.payload !== currentState.payload.active))
145
+ if((msg.payload === true || msg.payload === false) && (msg.payload != currentState.payload.active))
135
146
  {
136
147
  // PREPARE PATCH
137
- patchObject.enabled = msg.payload;
148
+ patchObject["enabled"] = (msg.payload == true);
138
149
  }
139
150
 
140
151
  //
@@ -13,6 +13,14 @@ Geben Sie die Hue Bridge-IP-Adresse manuell ein oder drücken Sie den Button, um
13
13
 
14
14
  Geben Sie den Hue Bridge API-Schlüssel manuell ein oder drücken Sie den Button, um einen neuen Schlüssel zu erstellen. Wenn Sie einen neuen Schlüssel erstellen möchten, müssen Sie innerhalb des Zeitfensters von 20 Sekunden den physischen Button der Bridge betätigen, um den Prozess abzuschließen.
15
15
 
16
+ ### Worker
17
+
18
+ Der "Worker"-Wert bestimmt die Anzahl der parallelen Befehle, die HueMagic an die Bridge gleichzeitig schicken darf. Laut offizieller Dokumentation der Philips Hue Bridge, sollten nicht mehr als 10 Befehle pro Sekunde abgeschickt werden, da sonst die Gefahr besteht, dass die Bridge die Anfragen nicht so schnell verarbeiten kann und Fehler auswirft.
19
+
20
+ Wenn mehr Befehle gleichzeitig abgeschickt werden als der hier gesetzte Wert, wird HueMagic die Befehle nacheinander ausführen, sobald der Durchsatz wieder möglich ist.
21
+
22
+ Setzen Sie hier einen Wert unter 10 (z. B. 4 bis 7), wenn Sie auch außerhalb von HueMagic Befehle an die Bridge senden, um den von Philips Hue empfohlenen Durchsatz an Befehlen / Sekunde einzuhalten.
23
+
16
24
  ### Automatische Firmware-Updates
17
25
 
18
26
  HueMagic prüft periodisch nach verfügbaren Philips Hue Firmware Updates und installiert sie automatisch, wenn sie verfügbar sind. Sie können dieses Verhalten deaktivieren, indem Sie die entsprechende Checkbox anklicken.
@@ -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",
@@ -53,6 +53,7 @@ Anders als beim „Hue Licht“-Node, stehen Ihnen hier viel weniger Statusinfor
53
53
  : id (string) : Gibt die neue ID der Gruppe an
54
54
  : idV1 (string | boolean) : Gibt die alte ID der Gruppe an
55
55
  : name (string) : Der aktuell eingestellte Name des Gruppe
56
+ : resources (object) : Enthält alle Geräte/Ressourcen hinter der Gruppe
56
57
  : type (string) : Der Typ des Gruppe (immer `group`)
57
58
 
58
59
  #### Zustandsänderungen unter `msg.updated`
@@ -13,6 +13,14 @@ Enter the Hue Bridge IP address manually or press the button to call up all loca
13
13
 
14
14
  Enter the Hue Bridge API key manually or press the button to create a new key. If you want to create a new key, you have to press the physical button of the bridge within the time window of 20 seconds to complete the process.
15
15
 
16
+ ### Worker
17
+
18
+ The "Worker" value determines the number of parallel commands that HueMagic is allowed to send to the bridge at the same time. According to the official documentation of the Philips Hue bridge, no more than 10 commands should be sent per second, otherwise there is a risk that the bridge will not be able to process the requests as quickly and will throw errors.
19
+
20
+ If more commands are sent at the same time than the value set here, HueMagic will execute the commands in sequence as soon as throughput is possible again.
21
+
22
+ Set this to a value below 10 (e.g. 4 to 7) if you also send commands to the bridge outside of HueMagic in order to comply with the Philips Hue recommended throughput of commands/second.
23
+
16
24
  ### Automatic firmware updates
17
25
 
18
26
  HueMagic periodically checks for available Philips Hue firmware updates and automatically installs them when they are available. You can deactivate this behavior by clicking the corresponding checkbox.
@@ -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 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.
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
 
@@ -16,7 +16,7 @@
16
16
  "connected": "connected",
17
17
  "starting-tl": "starting TouchLink…",
18
18
  "started-tl": "TouchLink started…",
19
- "f-ressources": "fetching ressources…",
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 switch, you can also enter it here manually. You can either assign a new name for the switch 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 switch after each deployment.
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
 
@@ -53,6 +53,7 @@ In contrast to the "Hue Light" node, you have much less status information avail
53
53
  : id (string): Indicates the new ID of the group
54
54
  : idV1 (string | boolean): Indicates the old ID of the group
55
55
  : name (string): The currently set name of the group
56
+ : resources (object) : Contains all devices/resources behind the group
56
57
  : type (string): The type of the group (always `group`)
57
58
 
58
59
  #### Status changes under `msg.updated`
@@ -38,7 +38,7 @@ In addition to simply switching it on and off, there are also many other options
38
38
  : gradient (object {hex […]}): An object with a supported color object (e.g. `hex`,` rgb`, ...) and several colors to set a gradient to supported lights
39
39
  : mixColor (object): A color to be mixed with the current light color. Can accept `color`, `hex`, `rgb` or `xyColor` objects and optionally `amount` (int) to indicate the mixing ratio in percent
40
40
  : image (string): Path of an image (local or on the web) to set the current color of the light to the average color of the image
41
- : saturation (int): percentage of the saturation of the current color (beta)
41
+ : saturation (int): Percentage of the saturation of the current color (beta)
42
42
  : colorTemp (int | string): Value between 153 and 500 to set the color temperature of the light or the values `cold`, `normal`, `warm`, `hot` and `auto` - where `auto` is the color temperature based on the current time
43
43
  : incrementColorTemp (int | boolean): Value by how much the color temperature should be warmer or `true` to make the color temperature warmer in steps of 50
44
44
  : decrementColorTemp (int | boolean): Value by how much the color temperature should be colder or `true` to make the color temperature colder in steps of 50
@@ -13,7 +13,7 @@ To play or stop an animation, pass an object with the following content to the n
13
13
 
14
14
  : payload (boolean): `true`, starts the animation, `false`, stops the animation
15
15
 
16
- ### Own animations
16
+ ### Custom animations
17
17
 
18
18
  If you pass your own animation to the node, the preselected, pre-defined animation (if set) will be temporarily replaced by yours. Own HueMagic animations are a sequence of commands that have been combined in an array. Each array element forms a step - whereby a step can also consist of several frames (transition effects).
19
19
 
@@ -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 your own animation
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 play indefinitely, this process is repeated indefinitely until you manually stop the animation or redeploy the node.
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,` false` turns it off
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 ´very cold´, ´cold´, ´slightly cold´, ´comfortable´, ´slightly warm´, ´warm´, ´hot´ or ´very hot´
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