@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,169 @@
1
+ export declare const QUERY_COMMAND = "PW?\rZM?\rSI?\rMV?\r";
2
+ export type AvrPower = "on" | "standby";
3
+ export type MainZone = "on" | "off";
4
+ export type AvrField = "power" | "mainZone" | "source" | "volume";
5
+ export interface AvrConfig {
6
+ area: string;
7
+ sources: Record<string, string>;
8
+ retryMs: number;
9
+ maxAttempts: number;
10
+ minVolume: number;
11
+ maxVolume: number;
12
+ }
13
+ export interface AvrObserved {
14
+ power: AvrPower | null;
15
+ mainZone: MainZone | null;
16
+ source: string | null;
17
+ sourceCode: string | null;
18
+ volume: number | null;
19
+ at: string | null;
20
+ }
21
+ export interface AvrDesired {
22
+ requestId: string;
23
+ generation: number;
24
+ power: AvrPower;
25
+ source: string | null;
26
+ }
27
+ export type AvrVolumeMode = "absolute" | "relative";
28
+ export interface AvrVolumeRequest {
29
+ requestId: string;
30
+ mode: AvrVolumeMode;
31
+ requested: number;
32
+ target: number | null;
33
+ bounded: boolean;
34
+ }
35
+ export interface AvrVolumeMetrics {
36
+ intents: number;
37
+ commands: number;
38
+ bounded: number;
39
+ confirmations: number;
40
+ externalChanges: number;
41
+ failures: number;
42
+ }
43
+ export interface AvrPending {
44
+ operation: string;
45
+ payload: string;
46
+ attempt: number;
47
+ deadlineAt: number;
48
+ }
49
+ export interface AvrFailure {
50
+ operation: string;
51
+ attempts: number;
52
+ at: string;
53
+ }
54
+ export interface AvrState {
55
+ observed: AvrObserved;
56
+ seen: Record<AvrField, boolean>;
57
+ fieldObservedAt: Record<AvrField, string | null>;
58
+ desired: AvrDesired | null;
59
+ generation: number;
60
+ pending: AvrPending | null;
61
+ phase: string;
62
+ failure: AvrFailure | null;
63
+ blockedGeneration: number | null;
64
+ querySentAt: number | null;
65
+ classification: "manual_override" | null;
66
+ volumeRequest: AvrVolumeRequest | null;
67
+ recentVolumeRequestIds: string[];
68
+ volumeMetrics: AvrVolumeMetrics;
69
+ lastAttempt: number;
70
+ }
71
+ export type AvrInputEvent = {
72
+ kind: "startup" | "refresh";
73
+ } | {
74
+ kind: "observed";
75
+ line?: unknown;
76
+ } | {
77
+ kind: "intent";
78
+ requestId: string;
79
+ generation: number;
80
+ power: AvrPower;
81
+ source?: string | null;
82
+ } | {
83
+ kind: "volume";
84
+ requestId: string;
85
+ mode: AvrVolumeMode;
86
+ value: number;
87
+ } | {
88
+ kind: "tick";
89
+ };
90
+ export interface AvrMessage {
91
+ avr?: AvrInputEvent;
92
+ payload?: unknown;
93
+ }
94
+ export interface AvrCommand {
95
+ payload: string;
96
+ avrCommand: {
97
+ area: string;
98
+ operation: string;
99
+ requestId: string | null;
100
+ generation: number;
101
+ attempt: number;
102
+ };
103
+ }
104
+ export interface AvrTargetState {
105
+ kind: "target_state";
106
+ target: "avr";
107
+ requestId: string;
108
+ generation: number;
109
+ status: string;
110
+ observedAt: string;
111
+ details: Record<string, unknown>;
112
+ classification?: "manual_override";
113
+ failure?: {
114
+ operation: string;
115
+ reason: string;
116
+ attempts: number;
117
+ occurredAt: string;
118
+ };
119
+ }
120
+ export interface AvrOutputEvent {
121
+ payload?: unknown;
122
+ avr: {
123
+ kind: string;
124
+ reason?: string;
125
+ [key: string]: unknown;
126
+ };
127
+ }
128
+ export type ParsedAvrLine = {
129
+ field: "power";
130
+ value: AvrPower;
131
+ line: string;
132
+ } | {
133
+ field: "mainZone";
134
+ value: MainZone;
135
+ line: string;
136
+ } | {
137
+ field: "source";
138
+ value: string | null;
139
+ sourceCode: string;
140
+ line: string;
141
+ } | {
142
+ field: "volume";
143
+ value: number | null;
144
+ line: string;
145
+ };
146
+ export declare function createAvrState(_config: AvrConfig, saved?: Partial<AvrState>): AvrState;
147
+ export declare function formatVolumeCommand(value: number): string;
148
+ export declare function parseAvrLine(value: unknown, sources: Record<string, string>): ParsedAvrLine | null;
149
+ export declare function normaliseAvrConfig(rawConfig: Omit<Partial<AvrConfig>, "sources"> & {
150
+ sources?: unknown;
151
+ }): AvrConfig;
152
+ export declare function transitionAvr(saved: Partial<AvrState> | undefined, msg: AvrMessage, rawConfig: Partial<AvrConfig>, nowValue?: Date | string | number): {
153
+ state: AvrState;
154
+ commands: AvrCommand[];
155
+ events: AvrOutputEvent[];
156
+ targetStates: {
157
+ theatre: AvrTargetState;
158
+ }[];
159
+ traces: {
160
+ event: string;
161
+ outcome: string;
162
+ reason: string | null;
163
+ details: Record<string, unknown>;
164
+ }[];
165
+ status: {
166
+ phase: string;
167
+ text: string;
168
+ };
169
+ };