@haydendonald/node-red-contrib-hass-stuff 1.2.5 → 1.2.7
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.
|
@@ -109,6 +109,11 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
109
109
|
};
|
|
110
110
|
RED.nodes.createNode(this, config);
|
|
111
111
|
(0, baseConfigNode_1.assignBaseConfigNode)(this);
|
|
112
|
+
//When NodeRED redeploys
|
|
113
|
+
self.on("close", function (done) {
|
|
114
|
+
clearTimeout(adaptiveInterval);
|
|
115
|
+
done();
|
|
116
|
+
});
|
|
112
117
|
const connectionsConfigNode = RED.nodes.getNode(config.connectionsConfigNode);
|
|
113
118
|
//When HASS is ready
|
|
114
119
|
connectionsConfigNode.hassEventReadyCallbacks[this.id] = function (msg) {
|
|
@@ -116,8 +121,8 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
116
121
|
connectionsConfigNode.getHASSEntityState(config.groupEntityId, (payload, data) => {
|
|
117
122
|
groupEntities = data.data.attributes.entity_id;
|
|
118
123
|
currentState = data.data;
|
|
119
|
-
entitiesOffDuringNight = config.entitiesOffAtNight.split(",");
|
|
120
|
-
entitiesOnDuringNight = groupEntities.filter((entity) => !entitiesOffDuringNight.includes(entity));
|
|
124
|
+
entitiesOffDuringNight = config.entitiesOffAtNight.split(",").filter((entity) => entity != "");
|
|
125
|
+
entitiesOnDuringNight = entitiesOffDuringNight.length > 0 ? groupEntities.filter((entity) => !entitiesOffDuringNight.includes(entity)) : [config.groupEntityId];
|
|
121
126
|
});
|
|
122
127
|
//Get the state of the night mode switch and store it
|
|
123
128
|
if (config.nightModeEntityId && config.nightModeEntityId != "") {
|
|
@@ -287,13 +292,13 @@ module.exports = function LightControlConfigNode(RED) {
|
|
|
287
292
|
shuffle: true,
|
|
288
293
|
smart_shuffle: true,
|
|
289
294
|
targets: {
|
|
290
|
-
entity_id: entitiesOn ? entitiesOn : [config.groupEntityId]
|
|
295
|
+
entity_id: (entitiesOn || []).length > 0 ? entitiesOn : [config.groupEntityId]
|
|
291
296
|
}
|
|
292
297
|
};
|
|
293
298
|
//Run via adaptive lights
|
|
294
299
|
connectionsConfigNode.sendHASSAction("scene_presets.apply_preset", undefined, msg, undefined);
|
|
295
300
|
//Run any lights off that need to be off
|
|
296
|
-
if (entitiesOff
|
|
301
|
+
if ((entitiesOff || []).length > 0) {
|
|
297
302
|
connectionsConfigNode.sendHASSAction("light.turn_off", {
|
|
298
303
|
entity_id: entitiesOff
|
|
299
304
|
}, {
|
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.7",
|
|
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",
|