grenton-ts 1.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.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -0
  3. package/dist/analog-din/fv02_01/analog-in.ts +271 -0
  4. package/dist/clu/calendar/v1/calendar.ts +308 -0
  5. package/dist/clu/clu-zwave-2/fv515_03/clu-zwave-2.ts +1302 -0
  6. package/dist/clu/event-scheduler/v1/event-scheduler.ts +537 -0
  7. package/dist/clu/multi-fan-ac-thermostat/v1/multi-fan-ac-thermostat.ts +1163 -0
  8. package/dist/clu/pid-controller/v1/pid-controller.ts +536 -0
  9. package/dist/clu/presence-sensor/v1/presence-sensor.ts +313 -0
  10. package/dist/clu/presence-sensor/v2/presence-sensor.ts +470 -0
  11. package/dist/clu/push/v1/push.ts +261 -0
  12. package/dist/clu/scheduler/v1/scheduler.ts +304 -0
  13. package/dist/clu/statistics/v1/statistics.ts +413 -0
  14. package/dist/clu/statistics-pulse/v1/statistics-pulse.ts +218 -0
  15. package/dist/clu/sunrise-sunset-calendar/v1/sunrise-sunset-calendar.ts +389 -0
  16. package/dist/clu/sunrise-sunset-calendar/v2/sunrise-sunset-calendar.ts +659 -0
  17. package/dist/clu/sunrise-sunset-calendar/v3/sunrise-sunset-calendar.ts +659 -0
  18. package/dist/clu/thermostat/v1/thermostat.ts +768 -0
  19. package/dist/clu/thermostat/v2/thermostat.ts +861 -0
  20. package/dist/clu/timer/v1/timer.ts +369 -0
  21. package/dist/core/execution-builder.ts +55 -0
  22. package/dist/core/remote-gate.ts +17 -0
  23. package/dist/digital-in-din/fv02_01/din.ts +310 -0
  24. package/dist/examples/light_turned_on_by_calendar/Clu_OnInit.ts +26 -0
  25. package/dist/examples/light_turned_on_by_presence_sensor/Clu_OnInit.ts +35 -0
  26. package/dist/examples/light_turned_on_by_switch/Clu_OnInit.ts +16 -0
  27. package/dist/gate/cool-master/v1/cool-master.ts +782 -0
  28. package/dist/gate/cool-master-net/v1/cool-master-net.ts +334 -0
  29. package/dist/gate/denon-marantz-avr/v1/denon-marantz-avr.ts +724 -0
  30. package/dist/gate/heos/v1/heos.ts +1224 -0
  31. package/dist/gate/http/fv1000_03/clu-gate-http.ts +405 -0
  32. package/dist/gate/http/fv1000_03_hv1/clu-gate-http.ts +352 -0
  33. package/dist/gate/http/fv1100_03/clu-gate-http.ts +589 -0
  34. package/dist/gate/http/fv1110_03/clu-gate-http.ts +589 -0
  35. package/dist/gate/http/fv1300_03/clu-gate-http.ts +589 -0
  36. package/dist/gate/http/fv1400_03/clu-gate-http.ts +677 -0
  37. package/dist/gate/http-listener/v1/http-listener.ts +299 -0
  38. package/dist/gate/http-listener/v2/http-listener.ts +325 -0
  39. package/dist/gate/http-request/v1/http-request.ts +645 -0
  40. package/dist/gate/http-request/v2/http-request.ts +709 -0
  41. package/dist/gate/input/v1/input.ts +171 -0
  42. package/dist/gate/jablotron/v1/jablotron.ts +100 -0
  43. package/dist/gate/jablotron-device/v1/jablotron-device.ts +171 -0
  44. package/dist/gate/jablotron-output/v1/jablotron-output.ts +240 -0
  45. package/dist/gate/jablotron-section/v1/jablotron-section.ts +260 -0
  46. package/dist/gate/modbus/v1/modbus.ts +609 -0
  47. package/dist/gate/modbus/v2/modbus.ts +690 -0
  48. package/dist/gate/modbus-client/v1/modbus-client.ts +827 -0
  49. package/dist/gate/modbus-rtu/v1/modbus-rtu.ts +911 -0
  50. package/dist/gate/modbus-server/v1/modbus-server.ts +405 -0
  51. package/dist/gate/modbus-slave-config-rtu/v1/modbus-slave-config-rtu.ts +160 -0
  52. package/dist/gate/modbus-slave-rtu/v1/modbus-slave-rtu.ts +371 -0
  53. package/dist/gate/modbus-value/v1/modbus-value.ts +856 -0
  54. package/dist/gate/music-cast/v1/music-cast.ts +1298 -0
  55. package/dist/gate/output/v1/output.ts +240 -0
  56. package/dist/gate/satel/v1/satel.ts +359 -0
  57. package/dist/gate/satel-input/v1/satel-input.ts +171 -0
  58. package/dist/gate/satel-output/v1/satel-output.ts +240 -0
  59. package/dist/gate/satel-zone/v1/satel-zone.ts +235 -0
  60. package/dist/gate/sonos/v1/sonos.ts +934 -0
  61. package/dist/gate/timer/v2/timer.ts +253 -0
  62. package/dist/gate/zone/v1/zone.ts +235 -0
  63. package/dist/io-module-din-8/fv02_02/din.ts +354 -0
  64. package/dist/io-module-din-8/fv02_02/dout.ts +360 -0
  65. package/dist/one-wire/fv01_10/onew-sensor.ts +269 -0
  66. package/dist/one-wire/fv01_28/onew-sensor.ts +269 -0
  67. package/dist/one-wire/fv02_28/onew-sensor.ts +350 -0
  68. package/dist/one-wire/fv03_28/onew-sensor.ts +435 -0
  69. package/dist/relay-din-2/fv02_02/dout.ts +544 -0
  70. package/dist/relay-din-4/fv01_02/dout.ts +340 -0
  71. package/dist/relay-din-4/fv02_02/dout.ts +368 -0
  72. package/dist/roller-shutter-din-3/fv03_02/roller-shutter.ts +1078 -0
  73. package/dist/smart-panel-fm-4/fv03_03/panel-button.ts +550 -0
  74. package/dist/smart-panel-fm-4/fv03_03/panel-sens-light.ts +238 -0
  75. package/dist/smart-panel-fm-4/fv03_03/panel-sens-temp.ts +239 -0
  76. package/dist/smart-panel-fm-4/fv03_03/panel.ts +700 -0
  77. package/dist/smart-panel-fm-4/fv04_03/panel-button.ts +567 -0
  78. package/dist/smart-panel-fm-4/fv04_03/panel-page.ts +516 -0
  79. package/dist/smart-panel-fm-4/fv04_03/panel-sens-light.ts +238 -0
  80. package/dist/smart-panel-fm-4/fv04_03/panel-sens-temp.ts +239 -0
  81. package/dist/smart-panel-fm-4/fv04_03/panel.ts +1026 -0
  82. package/dist/smart-panel-fm-4/fv05_03/panel-button.ts +567 -0
  83. package/dist/smart-panel-fm-4/fv05_03/panel-page.ts +620 -0
  84. package/dist/smart-panel-fm-4/fv05_03/panel-sens-light.ts +238 -0
  85. package/dist/smart-panel-fm-4/fv05_03/panel-sens-temp.ts +266 -0
  86. package/dist/smart-panel-fm-4/fv05_03/panel.ts +1109 -0
  87. package/dist/smart-panel-fm-4/fv06_03/panel-button.ts +567 -0
  88. package/dist/smart-panel-fm-4/fv06_03/panel-page.ts +877 -0
  89. package/dist/smart-panel-fm-4/fv06_03/panel-sens-light.ts +238 -0
  90. package/dist/smart-panel-fm-4/fv06_03/panel-sens-temp.ts +297 -0
  91. package/dist/smart-panel-fm-4/fv06_03/panel.ts +1138 -0
  92. package/dist/smart-panel-fm-4/fv07_03/panel-button.ts +567 -0
  93. package/dist/smart-panel-fm-4/fv07_03/panel-page.ts +864 -0
  94. package/dist/smart-panel-fm-4/fv07_03/panel-sens-light.ts +238 -0
  95. package/dist/smart-panel-fm-4/fv07_03/panel-sens-temp.ts +297 -0
  96. package/dist/smart-panel-fm-4/fv07_03/panel.ts +1135 -0
  97. package/dist/touch-panel-fm-4/fv01_02/panel-button.ts +418 -0
  98. package/dist/touch-panel-fm-4/fv01_02/panel-sens-light.ts +238 -0
  99. package/dist/touch-panel-fm-4/fv01_02/panel-sens-temp.ts +257 -0
  100. package/dist/touch-panel-fm-4/fv01_02/panel.ts +75 -0
  101. package/dist/touch-panel-fm-4/fv01_02/power-supply-voltage.ts +322 -0
  102. package/dist/touch-panel-fm-8/fv01_02/panel-button.ts +418 -0
  103. package/dist/touch-panel-fm-8/fv01_02/panel-sens-light.ts +238 -0
  104. package/dist/touch-panel-fm-8/fv01_02/panel-sens-temp.ts +270 -0
  105. package/dist/touch-panel-fm-8/fv01_02/panel.ts +75 -0
  106. package/dist/touch-panel-fm-8/fv01_02/power-supply-voltage.ts +322 -0
  107. package/package.json +16 -0
@@ -0,0 +1,313 @@
1
+ // Created from: packages/grenton-api/interfaces/object_presence_sensor_v1.xml, object name="PresenceSensor" version="1"
2
+
3
+ import { rawExecutionBuilderFactory } from "../../../core/execution-builder"
4
+ import { RemoteGate } from "../../../core/remote-gate"
5
+
6
+ enum EventType {
7
+ OnStart = 0,
8
+ OnStop = 1,
9
+ OnPresenceDetected = 2,
10
+ OnTimeout = 3
11
+ }
12
+
13
+ enum PropertyType {
14
+ Timeout = 0,
15
+ State = 1,
16
+ PresenceDetected = 2,
17
+ TimeFromLastPresence = 3
18
+ }
19
+
20
+ enum MethodType {
21
+ Start = 0,
22
+ Stop = 1,
23
+ DetectPresence = 2
24
+ }
25
+
26
+ enum StateType {
27
+ Off = 0,
28
+ On = 1
29
+ }
30
+
31
+ declare class PresenceSensorRaw {
32
+ add_event(event: EventType, callback: () => void): void;
33
+ get(property: PropertyType): any;
34
+ set(property: PropertyType, value: any): void;
35
+ execute(method: MethodType, ...args: any[]): any;
36
+ }
37
+
38
+ interface IPresenceSensor {
39
+ /**
40
+ * Zdarzenie wywoływane przy uruchomieniu czujnika
41
+ * @param callback
42
+ */
43
+ addOnStart: (callback: () => void) => void
44
+ /**
45
+ * Zdarzenie wywoływane przy dezaktywacji czujnika
46
+ * @param callback
47
+ */
48
+ addOnStop: (callback: () => void) => void
49
+ /**
50
+ * Zdarzenie wywoływane podczas wykrycia obecności
51
+ * @param callback
52
+ */
53
+ addOnPresenceDetected: (callback: () => void) => void
54
+ /**
55
+ * Zdarzenie wywoływane na timeout licznika
56
+ * @param callback
57
+ */
58
+ addOnTimeout: (callback: () => void) => void
59
+ /** Uruchamia czujnik obecności */
60
+ start: () => void
61
+ /** Zatrzymuje czujnik obecności */
62
+ stop: () => void
63
+ /** Metoda wywoływana podczas wykrycia obecności. Ustawia wartość cechy PresenceDetected na 1 oraz resetuje licznik TimeFromLastPresence czujnika obecności */
64
+ detectPresence: () => void
65
+ /** Czas (w sekundach) od ostatniej aktywności, po którym wartość cechy PresenceDetected zostaje ustawione na 0 */
66
+ timeout: number
67
+ /** Ustawia Aktualny stan czujnika obecności, 1 - włączony, 0 - wyłączony */
68
+ state: StateType
69
+ /** Wartość mówiąca o wykryciu ruchu przez czujnik */
70
+ readonly presenceDetected: boolean
71
+ /** Czas od ostatniego wykrycia ruchu (z czujnika lub włączenia swiatła z przycisku). Resetowany po wywołaniu: - DetectPresence() - bez względu na Locked, DetectionDelay - SwitchLocked() przy zmianie Locked na 1 - SetLocked(On) W trybie stanowym po wywołaniu DetectPresence(), TimeFromLastPresence = 0, aż do wywołania UndetectPresence() */
72
+ readonly timeFromLastPresence: number
73
+ }
74
+
75
+ class PresenceSensor implements IPresenceSensor {
76
+ private onStartCallbacks: Array<() => void> = [];
77
+ private onStopCallbacks: Array<() => void> = [];
78
+ private onPresenceDetectedCallbacks: Array<() => void> = [];
79
+ private onTimeoutCallbacks: Array<() => void> = [];
80
+
81
+ constructor(private raw: PresenceSensorRaw) {
82
+ this.raw.add_event(EventType.OnStart, () => {
83
+ this.onStartCallbacks.forEach(callback => {
84
+ callback();
85
+ });
86
+ });
87
+
88
+ this.raw.add_event(EventType.OnStop, () => {
89
+ this.onStopCallbacks.forEach(callback => {
90
+ callback();
91
+ });
92
+ });
93
+
94
+ this.raw.add_event(EventType.OnPresenceDetected, () => {
95
+ this.onPresenceDetectedCallbacks.forEach(callback => {
96
+ callback();
97
+ });
98
+ });
99
+
100
+ this.raw.add_event(EventType.OnTimeout, () => {
101
+ this.onTimeoutCallbacks.forEach(callback => {
102
+ callback();
103
+ });
104
+ });
105
+ }
106
+
107
+ /**
108
+ * Zdarzenie wywoływane przy uruchomieniu czujnika
109
+ * @param callback
110
+ */
111
+ addOnStart(callback: () => void): void {
112
+ this.onStartCallbacks.push(callback);
113
+ }
114
+ /**
115
+ * Zdarzenie wywoływane przy dezaktywacji czujnika
116
+ * @param callback
117
+ */
118
+ addOnStop(callback: () => void): void {
119
+ this.onStopCallbacks.push(callback);
120
+ }
121
+ /**
122
+ * Zdarzenie wywoływane podczas wykrycia obecności
123
+ * @param callback
124
+ */
125
+ addOnPresenceDetected(callback: () => void): void {
126
+ this.onPresenceDetectedCallbacks.push(callback);
127
+ }
128
+ /**
129
+ * Zdarzenie wywoływane na timeout licznika
130
+ * @param callback
131
+ */
132
+ addOnTimeout(callback: () => void): void {
133
+ this.onTimeoutCallbacks.push(callback);
134
+ }
135
+ /** Uruchamia czujnik obecności */
136
+ start(): void {
137
+ this.raw.execute(MethodType.Start);
138
+ }
139
+ /** Zatrzymuje czujnik obecności */
140
+ stop(): void {
141
+ this.raw.execute(MethodType.Stop);
142
+ }
143
+ /** Metoda wywoływana podczas wykrycia obecności. Ustawia wartość cechy PresenceDetected na 1 oraz resetuje licznik TimeFromLastPresence czujnika obecności */
144
+ detectPresence(): void {
145
+ this.raw.execute(MethodType.DetectPresence);
146
+ }
147
+ /**
148
+ * Czas (w sekundach) od ostatniej aktywności, po którym wartość cechy PresenceDetected zostaje ustawione na 0
149
+ * @returns {number}
150
+ */
151
+ get timeout(): number {
152
+ return this.raw.get(PropertyType.Timeout);
153
+ }
154
+ set timeout(value: number) {
155
+ this.raw.set(PropertyType.Timeout, value);
156
+ }
157
+ /**
158
+ * Ustawia Aktualny stan czujnika obecności, 1 - włączony, 0 - wyłączony
159
+ * @returns {StateType}
160
+ */
161
+ get state(): StateType {
162
+ return this.raw.get(PropertyType.State);
163
+ }
164
+ set state(value: StateType) {
165
+ this.raw.set(PropertyType.State, value);
166
+ }
167
+ /**
168
+ * Wartość mówiąca o wykryciu ruchu przez czujnik
169
+ * @returns {boolean}
170
+ */
171
+ get presenceDetected(): boolean {
172
+ return this.raw.get(PropertyType.PresenceDetected) === 1;
173
+ }
174
+ /**
175
+ * Czas od ostatniego wykrycia ruchu (z czujnika lub włączenia swiatła z przycisku). Resetowany po wywołaniu: - DetectPresence() - bez względu na Locked, DetectionDelay - SwitchLocked() przy zmianie Locked na 1 - SetLocked(On) W trybie stanowym po wywołaniu DetectPresence(), TimeFromLastPresence = 0, aż do wywołania UndetectPresence()
176
+ * @returns {number}
177
+ */
178
+ get timeFromLastPresence(): number {
179
+ return this.raw.get(PropertyType.TimeFromLastPresence);
180
+ }
181
+ }
182
+
183
+ class PresenceSensorRemote implements IPresenceSensor {
184
+ constructor(private objectName: string, private gate: RemoteGate) {
185
+
186
+ }
187
+
188
+ /**
189
+ * Zdarzenie wywoływane przy uruchomieniu czujnika
190
+ * @param callback
191
+ */
192
+ addOnStart(_callback: () => void): void {
193
+ // Remote events are not supported
194
+ }
195
+ /**
196
+ * Zdarzenie wywoływane przy dezaktywacji czujnika
197
+ * @param callback
198
+ */
199
+ addOnStop(_callback: () => void): void {
200
+ // Remote events are not supported
201
+ }
202
+ /**
203
+ * Zdarzenie wywoływane podczas wykrycia obecności
204
+ * @param callback
205
+ */
206
+ addOnPresenceDetected(_callback: () => void): void {
207
+ // Remote events are not supported
208
+ }
209
+ /**
210
+ * Zdarzenie wywoływane na timeout licznika
211
+ * @param callback
212
+ */
213
+ addOnTimeout(_callback: () => void): void {
214
+ // Remote events are not supported
215
+ }
216
+
217
+ /** Uruchamia czujnik obecności */
218
+ start(): void {
219
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
220
+ .execute()
221
+ .addParameter(MethodType.Start)
222
+ .build();
223
+ this.gate.runScript(cmd!);
224
+ }
225
+
226
+ /** Zatrzymuje czujnik obecności */
227
+ stop(): void {
228
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
229
+ .execute()
230
+ .addParameter(MethodType.Stop)
231
+ .build();
232
+ this.gate.runScript(cmd!);
233
+ }
234
+
235
+ /** Metoda wywoływana podczas wykrycia obecności. Ustawia wartość cechy PresenceDetected na 1 oraz resetuje licznik TimeFromLastPresence czujnika obecności */
236
+ detectPresence(): void {
237
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
238
+ .execute()
239
+ .addParameter(MethodType.DetectPresence)
240
+ .build();
241
+ this.gate.runScript(cmd!);
242
+ }
243
+
244
+ /**
245
+ * Czas (w sekundach) od ostatniej aktywności, po którym wartość cechy PresenceDetected zostaje ustawione na 0
246
+ * @returns {number}
247
+ */
248
+ get timeout(): number {
249
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
250
+ .get()
251
+ .addParameter(PropertyType.Timeout)
252
+ .build();
253
+ return this.gate.runScript(cmd!);
254
+ }
255
+
256
+ set timeout(value: number) {
257
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
258
+ .set()
259
+ .addParameter(PropertyType.Timeout)
260
+ .addParameter(value)
261
+ .build();
262
+ this.gate.runScript(cmd!);
263
+ }
264
+
265
+ /**
266
+ * Ustawia Aktualny stan czujnika obecności, 1 - włączony, 0 - wyłączony
267
+ * @returns {StateType}
268
+ */
269
+ get state(): StateType {
270
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
271
+ .get()
272
+ .addParameter(PropertyType.State)
273
+ .build();
274
+ return this.gate.runScript(cmd!);
275
+ }
276
+
277
+ set state(value: StateType) {
278
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
279
+ .set()
280
+ .addParameter(PropertyType.State)
281
+ .addParameter(value)
282
+ .build();
283
+ this.gate.runScript(cmd!);
284
+ }
285
+
286
+ /**
287
+ * Wartość mówiąca o wykryciu ruchu przez czujnik
288
+ * @returns {boolean}
289
+ */
290
+ get presenceDetected(): boolean {
291
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
292
+ .get()
293
+ .addParameter(PropertyType.PresenceDetected)
294
+ .build();
295
+ return this.gate.runScript(cmd!) === 1;
296
+ }
297
+
298
+ /**
299
+ * Czas od ostatniego wykrycia ruchu (z czujnika lub włączenia swiatła z przycisku). Resetowany po wywołaniu: - DetectPresence() - bez względu na Locked, DetectionDelay - SwitchLocked() przy zmianie Locked na 1 - SetLocked(On) W trybie stanowym po wywołaniu DetectPresence(), TimeFromLastPresence = 0, aż do wywołania UndetectPresence()
300
+ * @returns {number}
301
+ */
302
+ get timeFromLastPresence(): number {
303
+ const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
304
+ .get()
305
+ .addParameter(PropertyType.TimeFromLastPresence)
306
+ .build();
307
+ return this.gate.runScript(cmd!);
308
+ }
309
+ }
310
+
311
+ export {
312
+ PresenceSensor, PresenceSensorRaw, PresenceSensorRemote, StateType
313
+ }