@avantics/node-red-home-automation 5.0.0 → 6.0.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.
- package/README.md +340 -70
- package/contract-examples/room-lighting.mjs +39 -27
- package/dist/lib/activity-lighting-controller.d.ts +7 -2
- package/dist/lib/activity-lighting-controller.js +75 -16
- package/dist/lib/avr-controller.d.ts +2 -2
- package/dist/lib/avr-controller.js +21 -26
- package/dist/lib/circadian-policy.d.ts +47 -0
- package/dist/lib/circadian-policy.js +111 -0
- package/dist/lib/circadian-publishing.d.ts +33 -0
- package/dist/lib/circadian-publishing.js +154 -0
- package/dist/lib/circadian-schedule.d.ts +4 -0
- package/dist/lib/circadian-schedule.js +12 -0
- package/dist/lib/command-echo.d.ts +8 -1
- package/dist/lib/command-echo.js +37 -6
- package/dist/lib/cover-controller.js +4 -0
- package/dist/lib/denon-protocol.js +3 -2
- package/dist/lib/enable-input.d.ts +3 -0
- package/dist/lib/enable-input.js +18 -0
- package/dist/lib/house-schedule.js +2 -2
- package/dist/lib/light-contract.d.ts +53 -0
- package/dist/lib/light-contract.js +11 -0
- package/dist/lib/motion-policy.d.ts +0 -1
- package/dist/lib/motion-policy.js +9 -8
- package/dist/lib/motion-publishing.js +2 -1
- package/dist/lib/mqtt-message.d.ts +6 -0
- package/dist/lib/mqtt-message.js +21 -0
- package/dist/lib/room-controller.d.ts +38 -27
- package/dist/lib/room-controller.js +310 -204
- package/dist/lib/room-lighting-discovery.d.ts +0 -14
- package/dist/lib/room-lighting-discovery.js +19 -125
- package/dist/lib/room-publishing.d.ts +7 -12
- package/dist/lib/room-publishing.js +65 -125
- package/dist/lib/shelly-cover.d.ts +2 -4
- package/dist/lib/shelly-cover.js +30 -70
- package/dist/lib/shelly-gen2.d.ts +25 -0
- package/dist/lib/shelly-gen2.js +58 -0
- package/dist/lib/shelly-switch.d.ts +95 -0
- package/dist/lib/shelly-switch.js +237 -0
- package/dist/lib/theatre-state-contract.js +12 -4
- package/dist/lib/z2m-cover.d.ts +49 -0
- package/dist/lib/z2m-cover.js +120 -0
- package/dist/lib/z2m-light-adapter.d.ts +62 -0
- package/dist/lib/z2m-light-adapter.js +195 -0
- package/dist/lib/z2m-light.d.ts +2 -2
- package/dist/lib/z2m-light.js +11 -14
- package/dist/nodes/activity-lighting-controller.html +14 -5
- package/dist/nodes/activity-lighting-controller.js +21 -0
- package/dist/nodes/avr-controller.html +15 -18
- package/dist/nodes/avr-controller.js +4 -4
- package/dist/nodes/circadian-policy.d.ts +3 -0
- package/dist/nodes/circadian-policy.html +140 -0
- package/dist/nodes/circadian-policy.js +162 -0
- package/dist/nodes/cover-controller.html +4 -3
- package/dist/nodes/display-mode-controller.html +14 -17
- package/dist/nodes/display-mode-controller.js +4 -1
- package/dist/nodes/house-schedule.html +3 -3
- package/dist/nodes/motion-policy.html +5 -2
- package/dist/nodes/motion-policy.js +3 -0
- package/dist/nodes/refused-enable.d.ts +7 -0
- package/dist/nodes/refused-enable.js +24 -0
- package/dist/nodes/room-controller.html +215 -82
- package/dist/nodes/room-controller.js +70 -96
- package/dist/nodes/shelly-switch.d.ts +3 -0
- package/dist/nodes/shelly-switch.html +82 -0
- package/dist/nodes/shelly-switch.js +48 -0
- package/dist/nodes/theatre-state-contract.html +4 -3
- package/dist/nodes/z2m-cover.d.ts +3 -0
- package/dist/nodes/z2m-cover.html +68 -0
- package/dist/nodes/z2m-cover.js +41 -0
- package/dist/nodes/z2m-light.d.ts +3 -0
- package/dist/nodes/z2m-light.html +72 -0
- package/dist/nodes/z2m-light.js +50 -0
- package/examples/Cover control.json +24 -56
- package/examples/Home theatre activity.json +49 -4
- package/examples/House schedule.json +106 -24
- package/examples/Room lighting.json +54 -11
- package/examples/Shelly switch.json +197 -0
- package/package.json +12 -4
- package/dist/lib/room-schedule.d.ts +0 -8
- package/dist/lib/room-schedule.js +0 -41
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "example-shelly-switch-comment",
|
|
4
|
+
"type": "comment",
|
|
5
|
+
"name": "Shelly switch example",
|
|
6
|
+
"info": "A wall switch wired to a Shelly Gen2 relay in detached mode: the relay stays on to power smart bulbs, and the switch's presses drive the room's lights through the switch policy, with no function nodes. The adapter reads the device's own configuration (its mode and input type) and shows it in its status. In your flow, replace the injects marked 'from the device' with an MQTT in node subscribed to <prefix>/# (output: auto-detect), and the debug node 'to the MQTT out node' with an MQTT out node, both on your broker; wire the switch policy to your room controller. Set the adapter's MQTT topic prefix to your device's (its device ID unless you set one).",
|
|
7
|
+
"x": 150,
|
|
8
|
+
"y": 40,
|
|
9
|
+
"wires": []
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "example-shelly-switch-adapter",
|
|
13
|
+
"type": "home-shelly-switch",
|
|
14
|
+
"name": "",
|
|
15
|
+
"topicPrefix": "shellyplus1-a8032ab12345",
|
|
16
|
+
"channel": 0,
|
|
17
|
+
"mode": "auto",
|
|
18
|
+
"x": 460,
|
|
19
|
+
"y": 200,
|
|
20
|
+
"wires": [
|
|
21
|
+
[
|
|
22
|
+
"example-shelly-switch-to-device"
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
"example-shelly-switch-policy"
|
|
26
|
+
]
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "example-shelly-switch-policy",
|
|
31
|
+
"type": "home-switch-lighting-policy",
|
|
32
|
+
"name": "",
|
|
33
|
+
"area": "",
|
|
34
|
+
"targets": "[\"main\"]",
|
|
35
|
+
"switchWindowMs": 500,
|
|
36
|
+
"switchFreshnessSeconds": 3600,
|
|
37
|
+
"x": 700,
|
|
38
|
+
"y": 240,
|
|
39
|
+
"wires": [
|
|
40
|
+
[
|
|
41
|
+
"example-shelly-switch-intents"
|
|
42
|
+
]
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "example-shelly-switch-to-device",
|
|
47
|
+
"type": "debug",
|
|
48
|
+
"name": "to the MQTT out node",
|
|
49
|
+
"active": true,
|
|
50
|
+
"tosidebar": true,
|
|
51
|
+
"console": false,
|
|
52
|
+
"tostatus": false,
|
|
53
|
+
"complete": "true",
|
|
54
|
+
"targetType": "full",
|
|
55
|
+
"statusVal": "",
|
|
56
|
+
"statusType": "auto",
|
|
57
|
+
"x": 700,
|
|
58
|
+
"y": 160,
|
|
59
|
+
"wires": []
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"id": "example-shelly-switch-intents",
|
|
63
|
+
"type": "debug",
|
|
64
|
+
"name": "lighting intents (to the room controller)",
|
|
65
|
+
"active": true,
|
|
66
|
+
"tosidebar": true,
|
|
67
|
+
"console": false,
|
|
68
|
+
"tostatus": false,
|
|
69
|
+
"complete": "true",
|
|
70
|
+
"targetType": "full",
|
|
71
|
+
"statusVal": "",
|
|
72
|
+
"statusType": "auto",
|
|
73
|
+
"x": 960,
|
|
74
|
+
"y": 240,
|
|
75
|
+
"wires": []
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "example-shelly-switch-config",
|
|
79
|
+
"type": "inject",
|
|
80
|
+
"name": "configuration reply, from the device",
|
|
81
|
+
"props": [
|
|
82
|
+
{
|
|
83
|
+
"p": "payload",
|
|
84
|
+
"v": "{\"id\": 1, \"src\": \"shellyplus1-a8032ab12345\", \"dst\": \"shellyplus1-a8032ab12345/home-automation-switch-0\", \"result\": {\"switch:0\": {\"id\": 0, \"in_mode\": \"detached\"}, \"input:0\": {\"id\": 0, \"type\": \"switch\"}}}",
|
|
85
|
+
"vt": "json"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"repeat": "",
|
|
89
|
+
"crontab": "",
|
|
90
|
+
"once": false,
|
|
91
|
+
"onceDelay": 0.1,
|
|
92
|
+
"topic": "shellyplus1-a8032ab12345/home-automation-switch-0/rpc",
|
|
93
|
+
"x": 210,
|
|
94
|
+
"y": 120,
|
|
95
|
+
"wires": [
|
|
96
|
+
[
|
|
97
|
+
"example-shelly-switch-adapter"
|
|
98
|
+
]
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "example-shelly-switch-status",
|
|
103
|
+
"type": "inject",
|
|
104
|
+
"name": "device status, from the device",
|
|
105
|
+
"props": [
|
|
106
|
+
{
|
|
107
|
+
"p": "payload",
|
|
108
|
+
"v": "{\"switch:0\":{\"id\":0,\"output\":true},\"input:0\":{\"id\":0,\"state\":false}}",
|
|
109
|
+
"vt": "json"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"repeat": "",
|
|
113
|
+
"crontab": "",
|
|
114
|
+
"once": false,
|
|
115
|
+
"onceDelay": 0.1,
|
|
116
|
+
"topic": "shellyplus1-a8032ab12345/status",
|
|
117
|
+
"x": 200,
|
|
118
|
+
"y": 160,
|
|
119
|
+
"wires": [
|
|
120
|
+
[
|
|
121
|
+
"example-shelly-switch-adapter"
|
|
122
|
+
]
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"id": "example-shelly-switch-flip-on",
|
|
127
|
+
"type": "inject",
|
|
128
|
+
"name": "switch flipped on, from the device",
|
|
129
|
+
"props": [
|
|
130
|
+
{
|
|
131
|
+
"p": "payload",
|
|
132
|
+
"v": "{\"method\":\"NotifyStatus\",\"params\":{\"ts\":1764151200,\"input:0\":{\"id\":0,\"state\":true}}}",
|
|
133
|
+
"vt": "json"
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"repeat": "",
|
|
137
|
+
"crontab": "",
|
|
138
|
+
"once": false,
|
|
139
|
+
"onceDelay": 0.1,
|
|
140
|
+
"topic": "shellyplus1-a8032ab12345/events/rpc",
|
|
141
|
+
"x": 210,
|
|
142
|
+
"y": 200,
|
|
143
|
+
"wires": [
|
|
144
|
+
[
|
|
145
|
+
"example-shelly-switch-adapter"
|
|
146
|
+
]
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "example-shelly-switch-flip-off",
|
|
151
|
+
"type": "inject",
|
|
152
|
+
"name": "switch flipped off, from the device",
|
|
153
|
+
"props": [
|
|
154
|
+
{
|
|
155
|
+
"p": "payload",
|
|
156
|
+
"v": "{\"method\":\"NotifyStatus\",\"params\":{\"ts\":1764151201,\"input:0\":{\"id\":0,\"state\":false}}}",
|
|
157
|
+
"vt": "json"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"repeat": "",
|
|
161
|
+
"crontab": "",
|
|
162
|
+
"once": false,
|
|
163
|
+
"onceDelay": 0.1,
|
|
164
|
+
"topic": "shellyplus1-a8032ab12345/events/rpc",
|
|
165
|
+
"x": 210,
|
|
166
|
+
"y": 240,
|
|
167
|
+
"wires": [
|
|
168
|
+
[
|
|
169
|
+
"example-shelly-switch-adapter"
|
|
170
|
+
]
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "example-shelly-switch-online",
|
|
175
|
+
"type": "inject",
|
|
176
|
+
"name": "online, from the device",
|
|
177
|
+
"props": [
|
|
178
|
+
{
|
|
179
|
+
"p": "payload",
|
|
180
|
+
"v": "true",
|
|
181
|
+
"vt": "str"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"repeat": "",
|
|
185
|
+
"crontab": "",
|
|
186
|
+
"once": false,
|
|
187
|
+
"onceDelay": 0.1,
|
|
188
|
+
"topic": "shellyplus1-a8032ab12345/online",
|
|
189
|
+
"x": 180,
|
|
190
|
+
"y": 280,
|
|
191
|
+
"wires": [
|
|
192
|
+
[
|
|
193
|
+
"example-shelly-switch-adapter"
|
|
194
|
+
]
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avantics/node-red-home-automation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Deterministic home automation components for Node-RED",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
"contract-examples",
|
|
28
28
|
"!dist/**/*.js.map"
|
|
29
29
|
],
|
|
30
|
+
"exports": {
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
30
33
|
"scripts": {
|
|
31
34
|
"clean": "node scripts/clean.mjs",
|
|
32
35
|
"build": "npm run clean && tsc && node scripts/copy-node-html.mjs",
|
|
@@ -35,10 +38,11 @@
|
|
|
35
38
|
"scan:public": "node scripts/check-public.mjs",
|
|
36
39
|
"hooks:install": "git config core.hooksPath .githooks",
|
|
37
40
|
"prepack": "npm run build",
|
|
38
|
-
"diagrams": "node scripts/render-diagrams.mjs"
|
|
41
|
+
"diagrams": "node scripts/render-diagrams.mjs",
|
|
42
|
+
"docs": "node scripts/build-docs.mjs"
|
|
39
43
|
},
|
|
40
44
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
45
|
+
"node": ">=24"
|
|
42
46
|
},
|
|
43
47
|
"node-red": {
|
|
44
48
|
"version": ">=5.0.0",
|
|
@@ -47,6 +51,8 @@
|
|
|
47
51
|
"home-motion-lighting-policy": "dist/nodes/motion-policy.js",
|
|
48
52
|
"home-switch-lighting-policy": "dist/nodes/switch-policy.js",
|
|
49
53
|
"home-room-lighting-controller": "dist/nodes/room-controller.js",
|
|
54
|
+
"home-z2m-light": "dist/nodes/z2m-light.js",
|
|
55
|
+
"home-circadian-lighting-policy": "dist/nodes/circadian-policy.js",
|
|
50
56
|
"home-avr-controller": "dist/nodes/avr-controller.js",
|
|
51
57
|
"home-display-mode-controller": "dist/nodes/display-mode-controller.js",
|
|
52
58
|
"home-source-capability-controller": "dist/nodes/source-capability-controller.js",
|
|
@@ -58,7 +64,9 @@
|
|
|
58
64
|
"home-cover-controller": "dist/nodes/cover-controller.js",
|
|
59
65
|
"home-cover-group": "dist/nodes/cover-group.js",
|
|
60
66
|
"home-house-schedule-mqtt": "dist/nodes/house-schedule-mqtt.js",
|
|
61
|
-
"home-shelly-cover": "dist/nodes/shelly-cover.js"
|
|
67
|
+
"home-shelly-cover": "dist/nodes/shelly-cover.js",
|
|
68
|
+
"home-shelly-switch": "dist/nodes/shelly-switch.js",
|
|
69
|
+
"home-z2m-cover": "dist/nodes/z2m-cover.js"
|
|
62
70
|
}
|
|
63
71
|
},
|
|
64
72
|
"devDependencies": {
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type DaySchedule } from "./circadian-schedule";
|
|
2
|
-
import type { RoomConfig, RoomState } from "./room-controller";
|
|
3
|
-
export declare function savedSchedule(config: RoomConfig, saved: Partial<RoomState>): Pick<RoomState, "schedule" | "scheduleSetting">;
|
|
4
|
-
export declare function withActiveSchedule(config: RoomConfig, state: RoomState): RoomConfig;
|
|
5
|
-
export declare function requestedSchedule(current: DaySchedule, event: {
|
|
6
|
-
wakeTime?: unknown;
|
|
7
|
-
bedTime?: unknown;
|
|
8
|
-
}): DaySchedule | null;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.savedSchedule = savedSchedule;
|
|
4
|
-
exports.withActiveSchedule = withActiveSchedule;
|
|
5
|
-
exports.requestedSchedule = requestedSchedule;
|
|
6
|
-
// The room's wake and bed times while it runs: the configured times, or times
|
|
7
|
-
// set at runtime (from Home Assistant, say), which last until the node is
|
|
8
|
-
// deployed with a different setting for them. And the room's lighting on
|
|
9
|
-
// whichever times are in use.
|
|
10
|
-
const circadian_schedule_1 = require("./circadian-schedule");
|
|
11
|
-
const settings_1 = require("./settings");
|
|
12
|
-
function configuredSchedule(config) {
|
|
13
|
-
return config.schedule ?? { wakeTime: circadian_schedule_1.DEFAULT_WAKE_TIME, bedTime: circadian_schedule_1.DEFAULT_BED_TIME };
|
|
14
|
-
}
|
|
15
|
-
// Each saved time stands only while the setting it was based on is
|
|
16
|
-
// unchanged; state saved before times could change takes the settings.
|
|
17
|
-
function savedSchedule(config, saved) {
|
|
18
|
-
const setting = configuredSchedule(config);
|
|
19
|
-
const kept = (key) => (0, settings_1.keptOverride)(saved.schedule?.[key], saved.scheduleSetting?.[key], setting[key]);
|
|
20
|
-
return { schedule: { wakeTime: kept("wakeTime"), bedTime: kept("bedTime") }, scheduleSetting: { ...setting } };
|
|
21
|
-
}
|
|
22
|
-
// The room's settings with lighting that follows the times in use.
|
|
23
|
-
function withActiveSchedule(config, state) {
|
|
24
|
-
const setting = configuredSchedule(config);
|
|
25
|
-
const same = state.schedule.wakeTime === setting.wakeTime && state.schedule.bedTime === setting.bedTime;
|
|
26
|
-
if (same)
|
|
27
|
-
return config;
|
|
28
|
-
return { ...config, lighting: config.lighting.withSchedule(state.schedule) };
|
|
29
|
-
}
|
|
30
|
-
// New times from a "schedule" message, each "HH:MM", with a time left out
|
|
31
|
-
// staying as it is; null if they aren't valid, different times.
|
|
32
|
-
function requestedSchedule(current, event) {
|
|
33
|
-
const next = {
|
|
34
|
-
wakeTime: typeof event.wakeTime === "string" ? event.wakeTime.trim() : current.wakeTime,
|
|
35
|
-
bedTime: typeof event.bedTime === "string" ? event.bedTime.trim() : current.bedTime
|
|
36
|
-
};
|
|
37
|
-
const wake = (0, circadian_schedule_1.clockMinutes)(next.wakeTime);
|
|
38
|
-
const bed = (0, circadian_schedule_1.clockMinutes)(next.bedTime);
|
|
39
|
-
return wake === null || bed === null || wake === bed ? null : next;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=room-schedule.js.map
|