@haydendonald/node-red-contrib-hass-stuff 1.2.0 → 1.2.2
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
CHANGED
|
@@ -502,12 +502,12 @@ A node that controls lights with general scenes that adjust throughout the day w
|
|
|
502
502
|
|
|
503
503
|
### Features
|
|
504
504
|
* Adaptive scenes depending on what time of the day it is
|
|
505
|
-
* Adaptive scenes depending on luminance sensor
|
|
505
|
+
* Adaptive scenes depending on luminance sensor
|
|
506
506
|
* Night mode entity to force the adaptive scene to be in "night mode"
|
|
507
507
|
* Ability to turn off entities in night mode
|
|
508
508
|
|
|
509
509
|
### Dependencies
|
|
510
|
-
1. [
|
|
510
|
+
1. [Hue Scene Presets](https://github.com/Hypfer/hass-scene_presets)
|
|
511
511
|
2. [HASS Sun](https://www.home-assistant.io/integrations/sun/)
|
|
512
512
|
|
|
513
513
|
## PIR
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
<p>
|
|
54
54
|
The following settings define what the scenes should do. They follow the syntax of [scene] [brightnessPercent]
|
|
55
55
|
where scene is the scene name, if the same as below values will use the
|
|
56
|
-
<a style="font-weight: bold;" href="https://github.com/
|
|
56
|
+
<a style="font-weight: bold;" href="https://github.com/Hypfer/hass-scene_presets">Hue Scene Presets HACS plugin</a>
|
|
57
57
|
otherwise will send to scene.apply. The brightnessPercent is the brightness percentage to set
|
|
58
58
|
</p>
|
|
59
59
|
<ul>
|
|
@@ -106,4 +106,19 @@
|
|
|
106
106
|
</script>
|
|
107
107
|
|
|
108
108
|
<script type="text/html" data-help-name="light-control-config-node">
|
|
109
|
+
<p>A node that controls lights with general scenes that adjust throughout the day with sleep mode and other features.</p>
|
|
110
|
+
|
|
111
|
+
<h2>Features</h2>
|
|
112
|
+
<ul>
|
|
113
|
+
<li>Adaptive scenes depending on what time of the day it is</li>
|
|
114
|
+
<li>Adaptive scenes depending on luminance sensor</li>
|
|
115
|
+
<li>Night mode entity to force the adaptive scene to be in "night mode"</li>
|
|
116
|
+
<li>Ability to turn off entities in night mode</li>
|
|
117
|
+
</ul>
|
|
118
|
+
|
|
119
|
+
<h2>Dependencies</h2>
|
|
120
|
+
<ul>
|
|
121
|
+
<li><a href="https://github.com/Hypfer/hass-scene_presets" target="_blank">Hue Scene Presets</a></li>
|
|
122
|
+
<li><a href="https://www.home-assistant.io/integrations/sun/" target="_blank">Sun Integration</a></li>
|
|
123
|
+
</ul>
|
|
109
124
|
</script>
|
|
@@ -10,6 +10,7 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
10
10
|
let nightModeState;
|
|
11
11
|
let currentSceneState;
|
|
12
12
|
let sunState;
|
|
13
|
+
let lastSentScene;
|
|
13
14
|
let entitiesOnDuringNight = [];
|
|
14
15
|
let entitiesOffDuringNight = [];
|
|
15
16
|
let adaptiveInterval;
|
|
@@ -174,6 +175,7 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
174
175
|
connectionsConfigNode.sendHASSAction("light.turn_off", { entity_id: [config.groupEntityId] }, {
|
|
175
176
|
transition: serviceData.transition || 1
|
|
176
177
|
});
|
|
178
|
+
lastSentScene = "off";
|
|
177
179
|
}
|
|
178
180
|
});
|
|
179
181
|
//Add our toggle scene
|
|
@@ -229,11 +231,16 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
229
231
|
};
|
|
230
232
|
//When we get a message from a node on the NodeRED flows
|
|
231
233
|
this.msgReceived = function (msg, senderIds) { };
|
|
232
|
-
const activateScene = (scene, transitionSec, turnLightsOn, entitiesOn, entitiesOff) => {
|
|
234
|
+
const activateScene = (scene, transitionSec, turnLightsOn, entitiesOn, entitiesOff, forceSend) => {
|
|
233
235
|
//If the lights are off and we are not to turn the lights on don't do anything
|
|
234
236
|
if (turnLightsOn == false && currentState.state == "off") {
|
|
235
237
|
return;
|
|
236
238
|
}
|
|
239
|
+
//Don't send the same scene again
|
|
240
|
+
if (forceSend != true && scene.sceneName == lastSentScene) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
lastSentScene = scene.sceneName;
|
|
237
244
|
//Is not a scene preset scene if we have a entity id
|
|
238
245
|
if (scene.sceneName.includes(".")) {
|
|
239
246
|
//Run via hass scene.turn_on
|
|
@@ -242,6 +249,14 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
242
249
|
}, {
|
|
243
250
|
transition: transitionSec
|
|
244
251
|
});
|
|
252
|
+
//Send to the node output
|
|
253
|
+
self.sendMsg({
|
|
254
|
+
topic: "sceneSent",
|
|
255
|
+
payload: {
|
|
256
|
+
scene,
|
|
257
|
+
transitionSec
|
|
258
|
+
}
|
|
259
|
+
});
|
|
245
260
|
}
|
|
246
261
|
//Is a scene preset
|
|
247
262
|
else {
|
|
@@ -250,8 +265,7 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
250
265
|
self.error(`Scene preset not found for ${scene.sceneName}. Please use scene.<presetname> if this is not a scene i know about`);
|
|
251
266
|
return;
|
|
252
267
|
}
|
|
253
|
-
|
|
254
|
-
connectionsConfigNode.sendHASSAction("scene_presets.apply_preset", undefined, {
|
|
268
|
+
const msg = {
|
|
255
269
|
brightness: (scene.brightnessPct / 100.0) * 255,
|
|
256
270
|
transition: transitionSec,
|
|
257
271
|
preset_id: sceneId,
|
|
@@ -260,7 +274,9 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
260
274
|
targets: {
|
|
261
275
|
entity_id: entitiesOn ? entitiesOn : [config.groupEntityId]
|
|
262
276
|
}
|
|
263
|
-
}
|
|
277
|
+
};
|
|
278
|
+
//Run via adaptive lights
|
|
279
|
+
connectionsConfigNode.sendHASSAction("scene_presets.apply_preset", undefined, msg, undefined);
|
|
264
280
|
//Run any lights off that need to be off
|
|
265
281
|
if (entitiesOff && entitiesOff.length > 0) {
|
|
266
282
|
connectionsConfigNode.sendHASSAction("light.turn_off", {
|
|
@@ -269,6 +285,14 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
269
285
|
transition: transitionSec
|
|
270
286
|
});
|
|
271
287
|
}
|
|
288
|
+
//Send to the node output
|
|
289
|
+
self.sendMsg({
|
|
290
|
+
topic: "sceneSent",
|
|
291
|
+
payload: {
|
|
292
|
+
scene,
|
|
293
|
+
transitionSec
|
|
294
|
+
}
|
|
295
|
+
});
|
|
272
296
|
}
|
|
273
297
|
};
|
|
274
298
|
const runLights = (transitionSec, turnLightsOn) => {
|
|
@@ -284,7 +308,7 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
284
308
|
activateScene(scene, transitionSec, turnLightsOn);
|
|
285
309
|
}
|
|
286
310
|
};
|
|
287
|
-
const runAdaptive = (transitionSec, turnLightsOn) => {
|
|
311
|
+
const runAdaptive = (transitionSec, turnLightsOn, forceSend) => {
|
|
288
312
|
let entitiesOn;
|
|
289
313
|
let entitiesOff;
|
|
290
314
|
//Decide what scene to send
|
|
@@ -327,12 +351,12 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
327
351
|
}
|
|
328
352
|
}
|
|
329
353
|
//Send it
|
|
330
|
-
activateScene(scene, transitionSec, turnLightsOn, entitiesOn, entitiesOff);
|
|
354
|
+
activateScene(scene, transitionSec, turnLightsOn, entitiesOn, entitiesOff, forceSend);
|
|
331
355
|
//Start our interval to update the adaptive scene every minute
|
|
332
356
|
clearTimeout(adaptiveInterval);
|
|
333
357
|
adaptiveInterval = setTimeout(() => {
|
|
334
|
-
runAdaptive(300, false);
|
|
335
|
-
},
|
|
358
|
+
runAdaptive(300, false, true);
|
|
359
|
+
}, 300000);
|
|
336
360
|
};
|
|
337
361
|
};
|
|
338
362
|
RED.nodes.registerType("light-control-config-node", register);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
RED.nodes.registerType("light-control-node", {
|
|
3
3
|
category: "HASS Stuff",
|
|
4
4
|
color: "#ffcc00",
|
|
5
|
-
inputs:
|
|
5
|
+
inputs: 0,
|
|
6
6
|
outputs: 1,
|
|
7
7
|
icon: "bulb.svg",
|
|
8
8
|
paletteLabel: "Light Control",
|
|
@@ -28,4 +28,36 @@
|
|
|
28
28
|
</div>
|
|
29
29
|
</script>
|
|
30
30
|
<script type="text/html" data-help-name="light-control-node">
|
|
31
|
+
<p>A node that controls lights with general scenes that adjust throughout the day with sleep mode and other features.</p>
|
|
32
|
+
|
|
33
|
+
<h2>Features</h2>
|
|
34
|
+
<ul>
|
|
35
|
+
<li>Adaptive scenes depending on what time of the day it is</li>
|
|
36
|
+
<li>Adaptive scenes depending on luminance sensor</li>
|
|
37
|
+
<li>Night mode entity to force the adaptive scene to be in "night mode"</li>
|
|
38
|
+
<li>Ability to turn off entities in night mode</li>
|
|
39
|
+
</ul>
|
|
40
|
+
|
|
41
|
+
<h2>Dependencies</h2>
|
|
42
|
+
<ul>
|
|
43
|
+
<li><a href="https://github.com/Hypfer/hass-scene_presets" target="_blank">Hue Scene Presets</a></li>
|
|
44
|
+
<li><a href="https://www.home-assistant.io/integrations/sun/" target="_blank">Sun Integration</a></li>
|
|
45
|
+
</ul>
|
|
46
|
+
|
|
47
|
+
<h2>Output</h2>
|
|
48
|
+
<p>This node can output the following messages</p>
|
|
49
|
+
<ul>
|
|
50
|
+
<li>Scene Sent - A scene has been sent to the lights</li>
|
|
51
|
+
<pre><code>
|
|
52
|
+
{
|
|
53
|
+
topic: "sceneSent",
|
|
54
|
+
payload: {
|
|
55
|
+
friendlyName: "Concentrate",
|
|
56
|
+
sceneName: "sunFlare",
|
|
57
|
+
brightnessPct: 100
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</code></pre>
|
|
61
|
+
</ul>
|
|
62
|
+
|
|
31
63
|
</script>
|
|
@@ -9,10 +9,6 @@ module.exports = function LightControlNode(RED) {
|
|
|
9
9
|
lightControlConfigNode.addMsgCallback(this.id, (msg) => {
|
|
10
10
|
this.send(msg);
|
|
11
11
|
});
|
|
12
|
-
//When an input message is received
|
|
13
|
-
this.on("input", (msg, send, done) => {
|
|
14
|
-
lightControlConfigNode.msgReceived(msg, [this.id]);
|
|
15
|
-
});
|
|
16
12
|
}
|
|
17
13
|
RED.nodes.registerType("light-control-node", register);
|
|
18
14
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haydendonald/node-red-contrib-hass-stuff",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "A collection of stuff I use on my Node Red + Home Assistant server. This could be of use for others, i don't know..",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@types/node": "^18.14.0",
|