@avantics/node-red-home-automation 0.0.0-stage → 2.3.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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +292 -2
  3. package/contract-examples/README.md +28 -0
  4. package/contract-examples/_shared.mjs +11 -0
  5. package/contract-examples/motion-lighting.mjs +42 -0
  6. package/contract-examples/occupancy-fusion.mjs +35 -0
  7. package/contract-examples/room-lighting.mjs +58 -0
  8. package/contract-examples/run.mjs +16 -0
  9. package/contract-examples/source-readiness.mjs +64 -0
  10. package/contract-examples/switch-gestures.mjs +34 -0
  11. package/contract-examples/theatre-activity.mjs +62 -0
  12. package/contract-examples/volume-ownership.mjs +59 -0
  13. package/dist/lib/activity-lighting-controller.d.ts +129 -0
  14. package/dist/lib/activity-lighting-controller.js +372 -0
  15. package/dist/lib/avr-controller.d.ts +169 -0
  16. package/dist/lib/avr-controller.js +948 -0
  17. package/dist/lib/backlighting-controller.d.ts +108 -0
  18. package/dist/lib/backlighting-controller.js +269 -0
  19. package/dist/lib/bounded-trace.d.ts +30 -0
  20. package/dist/lib/bounded-trace.js +36 -0
  21. package/dist/lib/circadian-refresh.d.ts +7 -0
  22. package/dist/lib/circadian-refresh.js +11 -0
  23. package/dist/lib/circadian-schedule.d.ts +11 -0
  24. package/dist/lib/circadian-schedule.js +63 -0
  25. package/dist/lib/circadian.d.ts +6 -0
  26. package/dist/lib/circadian.js +15 -0
  27. package/dist/lib/cover-controller.d.ts +130 -0
  28. package/dist/lib/cover-controller.js +336 -0
  29. package/dist/lib/display-mode-controller.d.ts +148 -0
  30. package/dist/lib/display-mode-controller.js +587 -0
  31. package/dist/lib/display-transport.d.ts +41 -0
  32. package/dist/lib/display-transport.js +177 -0
  33. package/dist/lib/light-styling.d.ts +11 -0
  34. package/dist/lib/light-styling.js +15 -0
  35. package/dist/lib/motion-policy.d.ts +72 -0
  36. package/dist/lib/motion-policy.js +251 -0
  37. package/dist/lib/observation-time.d.ts +10 -0
  38. package/dist/lib/observation-time.js +40 -0
  39. package/dist/lib/occupancy-fusion.d.ts +53 -0
  40. package/dist/lib/occupancy-fusion.js +131 -0
  41. package/dist/lib/room-controller.d.ts +113 -0
  42. package/dist/lib/room-controller.js +431 -0
  43. package/dist/lib/source-capability-controller.d.ts +144 -0
  44. package/dist/lib/source-capability-controller.js +494 -0
  45. package/dist/lib/switch-policy.d.ts +53 -0
  46. package/dist/lib/switch-policy.js +110 -0
  47. package/dist/lib/theatre-activity-controller.d.ts +165 -0
  48. package/dist/lib/theatre-activity-controller.js +846 -0
  49. package/dist/lib/theatre-slo.d.ts +49 -0
  50. package/dist/lib/theatre-slo.js +156 -0
  51. package/dist/lib/theatre-state-contract.d.ts +77 -0
  52. package/dist/lib/theatre-state-contract.js +391 -0
  53. package/dist/lib/wall-input.d.ts +62 -0
  54. package/dist/lib/wall-input.js +198 -0
  55. package/dist/nodes/activity-lighting-controller.d.ts +3 -0
  56. package/dist/nodes/activity-lighting-controller.html +38 -0
  57. package/dist/nodes/activity-lighting-controller.js +116 -0
  58. package/dist/nodes/avr-controller.d.ts +3 -0
  59. package/dist/nodes/avr-controller.html +47 -0
  60. package/dist/nodes/avr-controller.js +130 -0
  61. package/dist/nodes/backlighting-controller.d.ts +3 -0
  62. package/dist/nodes/backlighting-controller.html +31 -0
  63. package/dist/nodes/backlighting-controller.js +103 -0
  64. package/dist/nodes/display-mode-controller.d.ts +3 -0
  65. package/dist/nodes/display-mode-controller.html +66 -0
  66. package/dist/nodes/display-mode-controller.js +132 -0
  67. package/dist/nodes/motion-policy.d.ts +3 -0
  68. package/dist/nodes/motion-policy.html +35 -0
  69. package/dist/nodes/motion-policy.js +194 -0
  70. package/dist/nodes/occupancy-fusion.d.ts +3 -0
  71. package/dist/nodes/occupancy-fusion.html +32 -0
  72. package/dist/nodes/occupancy-fusion.js +53 -0
  73. package/dist/nodes/room-controller.d.ts +3 -0
  74. package/dist/nodes/room-controller.html +82 -0
  75. package/dist/nodes/room-controller.js +123 -0
  76. package/dist/nodes/source-capability-controller.d.ts +3 -0
  77. package/dist/nodes/source-capability-controller.html +46 -0
  78. package/dist/nodes/source-capability-controller.js +114 -0
  79. package/dist/nodes/switch-policy.d.ts +3 -0
  80. package/dist/nodes/switch-policy.html +29 -0
  81. package/dist/nodes/switch-policy.js +129 -0
  82. package/dist/nodes/theatre-activity-controller.d.ts +3 -0
  83. package/dist/nodes/theatre-activity-controller.html +32 -0
  84. package/dist/nodes/theatre-activity-controller.js +105 -0
  85. package/dist/nodes/theatre-state-contract.d.ts +3 -0
  86. package/dist/nodes/theatre-state-contract.html +41 -0
  87. package/dist/nodes/theatre-state-contract.js +83 -0
  88. package/examples/Home theatre activity.json +477 -0
  89. package/examples/Home theatre equipment.json +329 -0
  90. package/examples/Room lighting.json +212 -0
  91. package/package.json +62 -4
@@ -0,0 +1,477 @@
1
+ [
2
+ {
3
+ "id": "example-home-theatre-activity-home-theatre-activity-example",
4
+ "type": "comment",
5
+ "name": "Home theatre activity example",
6
+ "info": "The state contract turns a request on home/room/theatre/request into an activity intent. The activity controller plans each target and sends msg.theatreCommand; the switch routes each command by its target, and a change node moves it onto that controller's input. Every controller reports msg.theatre target state on output 2, wired straight back to the activity controller, which publishes a complete snapshot through the contract.\n\nSet the display controller's device hosts and TV pre-shared key before deploying; until then it shows \"invalid configuration\" and the activity waits for it. Wire the controllers' output 1 to your device transports and activity lighting to your room lighting controller.",
7
+ "x": 190,
8
+ "y": 40,
9
+ "wires": []
10
+ },
11
+ {
12
+ "id": "example-home-theatre-activity-request-tv-activity",
13
+ "type": "inject",
14
+ "name": "request tv activity",
15
+ "props": [
16
+ {
17
+ "p": "topic",
18
+ "v": "home/room/theatre/request",
19
+ "vt": "str"
20
+ },
21
+ {
22
+ "p": "payload",
23
+ "v": "{\"requestId\":\"example-request-1\",\"activity\":\"tv\"}",
24
+ "vt": "json"
25
+ }
26
+ ],
27
+ "repeat": "",
28
+ "crontab": "",
29
+ "once": false,
30
+ "onceDelay": 0.1,
31
+ "topic": "",
32
+ "x": 170,
33
+ "y": 100,
34
+ "wires": [
35
+ [
36
+ "example-home-theatre-activity-theatre-state-contract"
37
+ ]
38
+ ]
39
+ },
40
+ {
41
+ "id": "example-home-theatre-activity-contract-startup",
42
+ "type": "inject",
43
+ "name": "contract startup",
44
+ "props": [
45
+ {
46
+ "p": "theatreStateContract",
47
+ "v": "{\"kind\":\"startup\"}",
48
+ "vt": "json"
49
+ }
50
+ ],
51
+ "repeat": "",
52
+ "crontab": "",
53
+ "once": false,
54
+ "onceDelay": 0.1,
55
+ "topic": "",
56
+ "x": 170,
57
+ "y": 140,
58
+ "wires": [
59
+ [
60
+ "example-home-theatre-activity-theatre-state-contract"
61
+ ]
62
+ ]
63
+ },
64
+ {
65
+ "id": "example-home-theatre-activity-theatre-state-contract",
66
+ "type": "home-theatre-state-contract",
67
+ "name": "",
68
+ "area": "room",
69
+ "displayName": "Room",
70
+ "baseTopic": "home/room/theatre",
71
+ "discoveryPrefix": "homeassistant",
72
+ "activities": "[\"off\",\"tv\"]",
73
+ "sloWindowSize": 20,
74
+ "sloMinimumSamples": 5,
75
+ "sloLatencyBudgetMs": 60000,
76
+ "sloSuccessObjectivePct": 95,
77
+ "x": 430,
78
+ "y": 120,
79
+ "wires": [
80
+ [
81
+ "example-home-theatre-activity-theatre-activity-controller"
82
+ ],
83
+ [
84
+ "example-home-theatre-activity-retained-state"
85
+ ]
86
+ ]
87
+ },
88
+ {
89
+ "id": "example-home-theatre-activity-retained-state",
90
+ "type": "debug",
91
+ "name": "retained state",
92
+ "active": true,
93
+ "tosidebar": true,
94
+ "console": false,
95
+ "tostatus": false,
96
+ "complete": "true",
97
+ "targetType": "full",
98
+ "statusVal": "",
99
+ "statusType": "auto",
100
+ "x": 680,
101
+ "y": 60,
102
+ "wires": []
103
+ },
104
+ {
105
+ "id": "example-home-theatre-activity-theatre-activity-controller",
106
+ "type": "home-theatre-activity-controller",
107
+ "name": "",
108
+ "area": "room",
109
+ "freshnessMs": 30000,
110
+ "recoveryOffActivity": "off",
111
+ "activityProfiles": "{\"off\":{\"display\":{\"mode\":\"off\"},\"avr\":{\"power\":\"standby\"},\"source\":{\"action\":\"deactivate\",\"readiness\":\"optional\"},\"lighting\":{\"profile\":\"off\"},\"backlighting\":{\"power\":\"off\"}},\"tv\":{\"display\":{\"mode\":\"tv\"},\"avr\":{\"power\":\"on\",\"source\":\"shield\"},\"source\":{\"action\":\"activate\",\"sourceId\":\"streamer\",\"readiness\":\"required\"},\"lighting\":{\"profile\":\"tv\"},\"backlighting\":{\"power\":\"on\"}}}",
112
+ "x": 680,
113
+ "y": 140,
114
+ "wires": [
115
+ [
116
+ "example-home-theatre-activity-route-by-target"
117
+ ],
118
+ [
119
+ "example-home-theatre-activity-theatre-state-contract"
120
+ ]
121
+ ]
122
+ },
123
+ {
124
+ "id": "example-home-theatre-activity-activity-lighting-controller",
125
+ "type": "home-activity-lighting-controller",
126
+ "name": "",
127
+ "area": "room",
128
+ "profiles": "{\"off\":{\"targets\":[],\"values\":{}},\"tv\":{\"targets\":[\"main\"],\"values\":{\"brightness\":64,\"color_temp\":400}}}",
129
+ "confirmationTimeoutMs": 15000,
130
+ "maxAttempts": 2,
131
+ "x": 1380,
132
+ "y": 440,
133
+ "wires": [
134
+ [
135
+ "example-home-theatre-activity-room-lighting-intents"
136
+ ],
137
+ [
138
+ "example-home-theatre-activity-theatre-activity-controller"
139
+ ]
140
+ ]
141
+ },
142
+ {
143
+ "id": "example-home-theatre-activity-room-lighting-intents",
144
+ "type": "debug",
145
+ "name": "room lighting intents",
146
+ "active": true,
147
+ "tosidebar": true,
148
+ "console": false,
149
+ "tostatus": false,
150
+ "complete": "true",
151
+ "targetType": "full",
152
+ "statusVal": "",
153
+ "statusType": "auto",
154
+ "x": 1630,
155
+ "y": 440,
156
+ "wires": []
157
+ },
158
+ {
159
+ "id": "example-home-theatre-activity-route-by-target",
160
+ "type": "switch",
161
+ "name": "route by target",
162
+ "property": "theatreCommand.target",
163
+ "propertyType": "msg",
164
+ "rules": [
165
+ {
166
+ "t": "eq",
167
+ "v": "display",
168
+ "vt": "str"
169
+ },
170
+ {
171
+ "t": "eq",
172
+ "v": "avr",
173
+ "vt": "str"
174
+ },
175
+ {
176
+ "t": "eq",
177
+ "v": "source",
178
+ "vt": "str"
179
+ },
180
+ {
181
+ "t": "eq",
182
+ "v": "lighting",
183
+ "vt": "str"
184
+ },
185
+ {
186
+ "t": "eq",
187
+ "v": "backlighting",
188
+ "vt": "str"
189
+ }
190
+ ],
191
+ "checkall": "true",
192
+ "repair": false,
193
+ "outputs": 5,
194
+ "x": 930,
195
+ "y": 300,
196
+ "wires": [
197
+ [
198
+ "example-home-theatre-activity-to-display"
199
+ ],
200
+ [
201
+ "example-home-theatre-activity-to-avr"
202
+ ],
203
+ [
204
+ "example-home-theatre-activity-to-source"
205
+ ],
206
+ [
207
+ "example-home-theatre-activity-to-lighting"
208
+ ],
209
+ [
210
+ "example-home-theatre-activity-to-backlighting"
211
+ ]
212
+ ]
213
+ },
214
+ {
215
+ "id": "example-home-theatre-activity-to-display",
216
+ "type": "change",
217
+ "name": "to display",
218
+ "rules": [
219
+ {
220
+ "t": "move",
221
+ "p": "theatreCommand",
222
+ "pt": "msg",
223
+ "to": "display",
224
+ "tot": "msg"
225
+ }
226
+ ],
227
+ "x": 1140,
228
+ "y": 200,
229
+ "wires": [
230
+ [
231
+ "example-home-theatre-activity-display-controller"
232
+ ]
233
+ ]
234
+ },
235
+ {
236
+ "id": "example-home-theatre-activity-display-controller",
237
+ "type": "home-display-mode-controller",
238
+ "name": "",
239
+ "area": "room",
240
+ "tvHost": "",
241
+ "screenHost": "",
242
+ "projectorMeterHost": "",
243
+ "screenOpenPosition": 82,
244
+ "screenTolerance": 2,
245
+ "pollMs": 2000,
246
+ "queryTimeoutMs": 5000,
247
+ "tvTimeoutMs": 30000,
248
+ "screenTimeoutMs": 65000,
249
+ "projectorWarmupMs": 60000,
250
+ "projectorMinimumWarmupMs": 15000,
251
+ "projectorShutdownConfirmMs": 5000,
252
+ "projectorCooldownMs": 120000,
253
+ "maxAttempts": 2,
254
+ "projectorOnWatts": 20,
255
+ "projectorOffWatts": 10,
256
+ "projectorPowerFallback": false,
257
+ "transportTimeoutMs": 5000,
258
+ "x": 1380,
259
+ "y": 200,
260
+ "wires": [
261
+ [
262
+ "example-home-theatre-activity-display-commands"
263
+ ],
264
+ [
265
+ "example-home-theatre-activity-theatre-activity-controller"
266
+ ]
267
+ ]
268
+ },
269
+ {
270
+ "id": "example-home-theatre-activity-display-commands",
271
+ "type": "debug",
272
+ "name": "display commands",
273
+ "active": true,
274
+ "tosidebar": true,
275
+ "console": false,
276
+ "tostatus": false,
277
+ "complete": "true",
278
+ "targetType": "full",
279
+ "statusVal": "",
280
+ "statusType": "auto",
281
+ "x": 1630,
282
+ "y": 200,
283
+ "wires": []
284
+ },
285
+ {
286
+ "id": "example-home-theatre-activity-to-avr",
287
+ "type": "change",
288
+ "name": "to avr",
289
+ "rules": [
290
+ {
291
+ "t": "move",
292
+ "p": "theatreCommand",
293
+ "pt": "msg",
294
+ "to": "avr",
295
+ "tot": "msg"
296
+ }
297
+ ],
298
+ "x": 1140,
299
+ "y": 280,
300
+ "wires": [
301
+ [
302
+ "example-home-theatre-activity-avr-controller"
303
+ ]
304
+ ]
305
+ },
306
+ {
307
+ "id": "example-home-theatre-activity-avr-controller",
308
+ "type": "home-avr-controller",
309
+ "name": "",
310
+ "area": "room",
311
+ "sources": "{\"shield\":\"SAT/CBL\",\"playstation\":\"GAME\"}",
312
+ "retryMs": 2000,
313
+ "maxAttempts": 3,
314
+ "minVolume": 0,
315
+ "maxVolume": 60,
316
+ "x": 1380,
317
+ "y": 280,
318
+ "wires": [
319
+ [
320
+ "example-home-theatre-activity-avr-commands"
321
+ ],
322
+ [
323
+ "example-home-theatre-activity-theatre-activity-controller"
324
+ ]
325
+ ]
326
+ },
327
+ {
328
+ "id": "example-home-theatre-activity-avr-commands",
329
+ "type": "debug",
330
+ "name": "avr commands",
331
+ "active": true,
332
+ "tosidebar": true,
333
+ "console": false,
334
+ "tostatus": false,
335
+ "complete": "true",
336
+ "targetType": "full",
337
+ "statusVal": "",
338
+ "statusType": "auto",
339
+ "x": 1630,
340
+ "y": 280,
341
+ "wires": []
342
+ },
343
+ {
344
+ "id": "example-home-theatre-activity-to-source",
345
+ "type": "change",
346
+ "name": "to sourceCapability",
347
+ "rules": [
348
+ {
349
+ "t": "move",
350
+ "p": "theatreCommand",
351
+ "pt": "msg",
352
+ "to": "sourceCapability",
353
+ "tot": "msg"
354
+ }
355
+ ],
356
+ "x": 1140,
357
+ "y": 360,
358
+ "wires": [
359
+ [
360
+ "example-home-theatre-activity-source-controller"
361
+ ]
362
+ ]
363
+ },
364
+ {
365
+ "id": "example-home-theatre-activity-source-controller",
366
+ "type": "home-source-capability-controller",
367
+ "name": "",
368
+ "area": "room",
369
+ "sources": "{\"streamer\":{\"activation\":\"command\",\"deactivation\":\"command\",\"confirmation\":\"active\"}}",
370
+ "pollMs": 2000,
371
+ "confirmationTimeoutMs": 15000,
372
+ "maxAttempts": 2,
373
+ "x": 1380,
374
+ "y": 360,
375
+ "wires": [
376
+ [
377
+ "example-home-theatre-activity-source-commands"
378
+ ],
379
+ [
380
+ "example-home-theatre-activity-theatre-activity-controller"
381
+ ]
382
+ ]
383
+ },
384
+ {
385
+ "id": "example-home-theatre-activity-source-commands",
386
+ "type": "debug",
387
+ "name": "source commands",
388
+ "active": true,
389
+ "tosidebar": true,
390
+ "console": false,
391
+ "tostatus": false,
392
+ "complete": "true",
393
+ "targetType": "full",
394
+ "statusVal": "",
395
+ "statusType": "auto",
396
+ "x": 1630,
397
+ "y": 360,
398
+ "wires": []
399
+ },
400
+ {
401
+ "id": "example-home-theatre-activity-to-lighting",
402
+ "type": "change",
403
+ "name": "to activityLighting",
404
+ "rules": [
405
+ {
406
+ "t": "move",
407
+ "p": "theatreCommand",
408
+ "pt": "msg",
409
+ "to": "activityLighting",
410
+ "tot": "msg"
411
+ }
412
+ ],
413
+ "x": 1140,
414
+ "y": 440,
415
+ "wires": [
416
+ [
417
+ "example-home-theatre-activity-activity-lighting-controller"
418
+ ]
419
+ ]
420
+ },
421
+ {
422
+ "id": "example-home-theatre-activity-to-backlighting",
423
+ "type": "change",
424
+ "name": "to backlighting",
425
+ "rules": [
426
+ {
427
+ "t": "move",
428
+ "p": "theatreCommand",
429
+ "pt": "msg",
430
+ "to": "backlighting",
431
+ "tot": "msg"
432
+ }
433
+ ],
434
+ "x": 1140,
435
+ "y": 520,
436
+ "wires": [
437
+ [
438
+ "example-home-theatre-activity-backlighting-controller"
439
+ ]
440
+ ]
441
+ },
442
+ {
443
+ "id": "example-home-theatre-activity-backlighting-controller",
444
+ "type": "home-backlighting-controller",
445
+ "name": "",
446
+ "area": "room",
447
+ "pollMs": 2000,
448
+ "confirmationTimeoutMs": 15000,
449
+ "maxAttempts": 2,
450
+ "x": 1380,
451
+ "y": 520,
452
+ "wires": [
453
+ [
454
+ "example-home-theatre-activity-backlighting-commands"
455
+ ],
456
+ [
457
+ "example-home-theatre-activity-theatre-activity-controller"
458
+ ]
459
+ ]
460
+ },
461
+ {
462
+ "id": "example-home-theatre-activity-backlighting-commands",
463
+ "type": "debug",
464
+ "name": "backlighting commands",
465
+ "active": true,
466
+ "tosidebar": true,
467
+ "console": false,
468
+ "tostatus": false,
469
+ "complete": "true",
470
+ "targetType": "full",
471
+ "statusVal": "",
472
+ "statusType": "auto",
473
+ "x": 1630,
474
+ "y": 520,
475
+ "wires": []
476
+ }
477
+ ]