iobroker.loxone 3.0.0 → 4.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 (183) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +425 -402
  3. package/admin/i18n/de.json +15 -0
  4. package/admin/i18n/en.json +15 -0
  5. package/admin/i18n/es.json +18 -0
  6. package/admin/i18n/fr.json +18 -0
  7. package/admin/i18n/it.json +18 -0
  8. package/admin/i18n/nl.json +18 -0
  9. package/admin/i18n/pl.json +18 -0
  10. package/admin/i18n/pt.json +18 -0
  11. package/admin/i18n/ru.json +18 -0
  12. package/admin/i18n/uk.json +18 -0
  13. package/admin/i18n/zh-cn.json +18 -0
  14. package/admin/jsonConfig.json +96 -0
  15. package/io-package.json +309 -349
  16. package/package.json +42 -46
  17. package/src/controls/AalEmergency.ts +90 -0
  18. package/src/controls/AalSmartAlarm.ts +99 -0
  19. package/src/controls/Alarm.ts +146 -0
  20. package/src/controls/AlarmClock.ts +137 -0
  21. package/src/controls/Application.ts +13 -0
  22. package/src/controls/AudioZone.ts +227 -0
  23. package/src/controls/AudioZoneV2.ts +135 -0
  24. package/src/controls/CentralAlarm.ts +59 -0
  25. package/src/controls/CentralAudioZone.ts +41 -0
  26. package/src/controls/CentralGate.ts +53 -0
  27. package/src/controls/CentralJalousie.ts +67 -0
  28. package/src/controls/CentralLightController.ts +45 -0
  29. package/src/controls/ColorPickerV2.ts +34 -0
  30. package/src/controls/Colorpicker.ts +30 -0
  31. package/src/controls/ColorpickerBase.ts +326 -0
  32. package/src/controls/Daytimer.ts +201 -0
  33. package/src/controls/Dimmer.ts +64 -0
  34. package/src/controls/EIBDimmer.ts +61 -0
  35. package/src/controls/Fronius.ts +217 -0
  36. package/src/controls/Gate.ts +150 -0
  37. package/src/controls/Hourcounter.ts +115 -0
  38. package/src/controls/IRCDaytimer.ts +4 -0
  39. package/src/controls/IRCV2Daytimer.ts +4 -0
  40. package/src/controls/IRoomControllerV2.ts +595 -0
  41. package/src/controls/InfoOnlyAnalog.ts +56 -0
  42. package/src/controls/InfoOnlyDigital.ts +95 -0
  43. package/src/controls/InfoOnlyText.ts +52 -0
  44. package/{build/controls/Intercom.js → src/controls/Intercom.ts} +27 -11
  45. package/src/controls/Jalousie.ts +219 -0
  46. package/src/controls/LightController.ts +112 -0
  47. package/src/controls/LightControllerV2.ts +246 -0
  48. package/src/controls/MailBox.ts +92 -0
  49. package/src/controls/Meter.ts +94 -0
  50. package/src/controls/None.ts +29 -0
  51. package/src/controls/PresenceDetector.ts +47 -0
  52. package/src/controls/Pushbutton.ts +55 -0
  53. package/src/controls/Radio.ts +61 -0
  54. package/src/controls/Remote.ts +44 -0
  55. package/src/controls/Slider.ts +78 -0
  56. package/src/controls/SmokeAlarm.ts +163 -0
  57. package/src/controls/Switch.ts +46 -0
  58. package/src/controls/SystemScheme.ts +13 -0
  59. package/src/controls/TextInput.ts +96 -0
  60. package/src/controls/TextState.ts +37 -0
  61. package/src/controls/TimedSwitch.ts +75 -0
  62. package/src/controls/Tracker.ts +30 -0
  63. package/{build/controls/Unknown.js → src/controls/Unknown.ts} +19 -13
  64. package/src/controls/UpDownAnalog.ts +78 -0
  65. package/{build/controls/ValueSelector.js → src/controls/ValueSelector.ts} +21 -9
  66. package/src/controls/WindowMonitor.ts +139 -0
  67. package/src/controls/all-controls.ts +99 -0
  68. package/src/controls/control-base.ts +28 -0
  69. package/src/lib/adapter-config.d.ts +22 -0
  70. package/src/loxone-handler-base.ts +285 -0
  71. package/src/lxcommunicator.d.ts +1 -0
  72. package/src/main.test.ts +24 -0
  73. package/src/main.ts +1178 -0
  74. package/src/structure-file.d.ts +154 -0
  75. package/src/weather-server-handler.ts +266 -0
  76. package/admin/admin.d.ts +0 -58
  77. package/admin/index_m.html +0 -126
  78. package/admin/style.css +0 -32
  79. package/admin/words.js +0 -25
  80. package/build/controls/AalEmergency.js +0 -45
  81. package/build/controls/AalEmergency.js.map +0 -1
  82. package/build/controls/AalSmartAlarm.js +0 -48
  83. package/build/controls/AalSmartAlarm.js.map +0 -1
  84. package/build/controls/Alarm.js +0 -81
  85. package/build/controls/Alarm.js.map +0 -1
  86. package/build/controls/AlarmClock.js +0 -59
  87. package/build/controls/AlarmClock.js.map +0 -1
  88. package/build/controls/Application.js +0 -11
  89. package/build/controls/Application.js.map +0 -1
  90. package/build/controls/AudioZone.js +0 -116
  91. package/build/controls/AudioZone.js.map +0 -1
  92. package/build/controls/CentralAlarm.js +0 -30
  93. package/build/controls/CentralAlarm.js.map +0 -1
  94. package/build/controls/CentralAudioZone.js +0 -22
  95. package/build/controls/CentralAudioZone.js.map +0 -1
  96. package/build/controls/CentralGate.js +0 -30
  97. package/build/controls/CentralGate.js.map +0 -1
  98. package/build/controls/CentralJalousie.js +0 -39
  99. package/build/controls/CentralJalousie.js.map +0 -1
  100. package/build/controls/CentralLightController.js +0 -27
  101. package/build/controls/CentralLightController.js.map +0 -1
  102. package/build/controls/ColorPickerV2.js +0 -24
  103. package/build/controls/ColorPickerV2.js.map +0 -1
  104. package/build/controls/Colorpicker.js +0 -20
  105. package/build/controls/Colorpicker.js.map +0 -1
  106. package/build/controls/ColorpickerBase.js +0 -263
  107. package/build/controls/ColorpickerBase.js.map +0 -1
  108. package/build/controls/Daytimer.js +0 -119
  109. package/build/controls/Daytimer.js.map +0 -1
  110. package/build/controls/Dimmer.js +0 -34
  111. package/build/controls/Dimmer.js.map +0 -1
  112. package/build/controls/EIBDimmer.js +0 -31
  113. package/build/controls/EIBDimmer.js.map +0 -1
  114. package/build/controls/Fronius.js +0 -64
  115. package/build/controls/Fronius.js.map +0 -1
  116. package/build/controls/Gate.js +0 -109
  117. package/build/controls/Gate.js.map +0 -1
  118. package/build/controls/Hourcounter.js +0 -46
  119. package/build/controls/Hourcounter.js.map +0 -1
  120. package/build/controls/IRCDaytimer.js +0 -9
  121. package/build/controls/IRCDaytimer.js.map +0 -1
  122. package/build/controls/IRoomControllerV2.js +0 -272
  123. package/build/controls/IRoomControllerV2.js.map +0 -1
  124. package/build/controls/InfoOnlyAnalog.js +0 -38
  125. package/build/controls/InfoOnlyAnalog.js.map +0 -1
  126. package/build/controls/InfoOnlyDigital.js +0 -65
  127. package/build/controls/InfoOnlyDigital.js.map +0 -1
  128. package/build/controls/InfoOnlyText.js +0 -35
  129. package/build/controls/InfoOnlyText.js.map +0 -1
  130. package/build/controls/Intercom.js.map +0 -1
  131. package/build/controls/Jalousie.js +0 -156
  132. package/build/controls/Jalousie.js.map +0 -1
  133. package/build/controls/LightController.js +0 -68
  134. package/build/controls/LightController.js.map +0 -1
  135. package/build/controls/LightControllerV2.js +0 -195
  136. package/build/controls/LightControllerV2.js.map +0 -1
  137. package/build/controls/MailBox.js +0 -41
  138. package/build/controls/MailBox.js.map +0 -1
  139. package/build/controls/Meter.js +0 -52
  140. package/build/controls/Meter.js.map +0 -1
  141. package/build/controls/None.js +0 -23
  142. package/build/controls/None.js.map +0 -1
  143. package/build/controls/PresenceDetector.js +0 -29
  144. package/build/controls/PresenceDetector.js.map +0 -1
  145. package/build/controls/Pushbutton.js +0 -38
  146. package/build/controls/Pushbutton.js.map +0 -1
  147. package/build/controls/Radio.js +0 -42
  148. package/build/controls/Radio.js.map +0 -1
  149. package/build/controls/Slider.js +0 -44
  150. package/build/controls/Slider.js.map +0 -1
  151. package/build/controls/SmokeAlarm.js +0 -85
  152. package/build/controls/SmokeAlarm.js.map +0 -1
  153. package/build/controls/Switch.js +0 -34
  154. package/build/controls/Switch.js.map +0 -1
  155. package/build/controls/SystemScheme.js +0 -11
  156. package/build/controls/SystemScheme.js.map +0 -1
  157. package/build/controls/TextInput.js +0 -55
  158. package/build/controls/TextInput.js.map +0 -1
  159. package/build/controls/TextState.js +0 -20
  160. package/build/controls/TextState.js.map +0 -1
  161. package/build/controls/TimedSwitch.js +0 -36
  162. package/build/controls/TimedSwitch.js.map +0 -1
  163. package/build/controls/Tracker.js +0 -20
  164. package/build/controls/Tracker.js.map +0 -1
  165. package/build/controls/Unknown.js.map +0 -1
  166. package/build/controls/UpDownAnalog.js +0 -44
  167. package/build/controls/UpDownAnalog.js.map +0 -1
  168. package/build/controls/ValueSelector.js.map +0 -1
  169. package/build/controls/WindowMonitor.js +0 -84
  170. package/build/controls/WindowMonitor.js.map +0 -1
  171. package/build/controls/control-base.js +0 -12
  172. package/build/controls/control-base.js.map +0 -1
  173. package/build/loxone-handler-base.js +0 -186
  174. package/build/loxone-handler-base.js.map +0 -1
  175. package/build/main.js +0 -643
  176. package/build/main.js.map +0 -1
  177. package/build/weather-server-handler.js +0 -120
  178. package/build/weather-server-handler.js.map +0 -1
  179. package/doc/details-missing-control-type.png +0 -0
  180. package/doc/log-missing-control-type.png +0 -0
  181. package/doc/loxone-config-display-diagnostics.png +0 -0
  182. package/doc/loxone-config-info-only-digital.png +0 -0
  183. package/doc/loxone-config-use-in-visualization.png +0 -0
@@ -0,0 +1,78 @@
1
+ import type { CurrentStateValue, OldStateValue } from '../main';
2
+ import type { Control } from '../structure-file';
3
+ import type { ControlType } from './control-base';
4
+ import { ControlBase } from './control-base';
5
+
6
+ /**
7
+ * Handler for Slider controls.
8
+ */
9
+ export class Slider extends ControlBase {
10
+ /**
11
+ * Loads the control and sets up state objects and event handlers.
12
+ *
13
+ * @param type The type of the control ('device' or 'channel').
14
+ * @param uuid The unique identifier of the control.
15
+ * @param control The control data from the structure file.
16
+ */
17
+ async loadAsync(type: ControlType, uuid: string, control: Control): Promise<void> {
18
+ await this.updateObjectAsync(uuid, {
19
+ type: type,
20
+ common: {
21
+ name: control.name,
22
+ role: 'sensor',
23
+ },
24
+ native: { control },
25
+ });
26
+
27
+ await this.loadOtherControlStatesAsync(control.name, uuid, control.states, ['value', 'error']);
28
+
29
+ const common: Partial<ioBroker.StateCommon> = { write: true };
30
+ if ('details' in control) {
31
+ common.min = control.details.min as number;
32
+ common.max = control.details.max as number;
33
+ }
34
+
35
+ await this.createSimpleControlStateObjectAsync(
36
+ control.name,
37
+ uuid,
38
+ control.states,
39
+ 'value',
40
+ 'number',
41
+ 'level',
42
+ common,
43
+ );
44
+ this.addStateChangeListener(`${uuid}.value`, (oldValue: OldStateValue, newValue: CurrentStateValue) => {
45
+ this.sendCommand(control.uuidAction, (newValue || '0').toString());
46
+ });
47
+
48
+ await this.createBooleanControlStateObjectAsync(
49
+ control.name,
50
+ uuid,
51
+ control.states,
52
+ 'error',
53
+ 'indicator.maintenance',
54
+ );
55
+
56
+ if (!('details' in control)) {
57
+ return;
58
+ }
59
+
60
+ if ('format' in control.details) {
61
+ await this.updateStateObjectAsync(
62
+ `${uuid}.value-formatted`,
63
+ {
64
+ name: `${control.name}: formatted value`,
65
+ read: true,
66
+ write: false,
67
+ type: 'string',
68
+ role: 'text',
69
+ // TODO: re-add: smartIgnore: true,
70
+ },
71
+ control.states.value,
72
+ async (name: string, value: any) => {
73
+ await this.setFormattedStateAck(name, value, control.details.format as string);
74
+ },
75
+ );
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,163 @@
1
+ import type { CurrentStateValue, OldStateValue } from '../main';
2
+ import type { Control } from '../structure-file';
3
+ import type { ControlType } from './control-base';
4
+ import { ControlBase } from './control-base';
5
+
6
+ /**
7
+ * Handler for SmokeAlarm controls.
8
+ */
9
+ export class SmokeAlarm extends ControlBase {
10
+ /**
11
+ * Loads the control and sets up state objects and event handlers.
12
+ *
13
+ * @param type The type of the control ('device' or 'channel').
14
+ * @param uuid The unique identifier of the control.
15
+ * @param control The control data from the structure file.
16
+ */
17
+ async loadAsync(type: ControlType, uuid: string, control: Control): Promise<void> {
18
+ await this.updateObjectAsync(uuid, {
19
+ type: type,
20
+ common: {
21
+ name: control.name,
22
+ role: 'alarm',
23
+ },
24
+ native: { control },
25
+ });
26
+
27
+ await this.loadOtherControlStatesAsync(control.name, uuid, control.states, [
28
+ 'nextLevel',
29
+ 'nextLevelDelay',
30
+ 'nextLevelDelayTotal',
31
+ 'level',
32
+ 'sensors',
33
+ 'acousticAlarm',
34
+ 'testAlarm',
35
+ 'alarmCause',
36
+ 'startTime',
37
+ 'timeServiceMode',
38
+ ]);
39
+
40
+ const levelStates = {
41
+ 0: 'None',
42
+ 1: 'Silent',
43
+ 2: 'Acustic',
44
+ 3: 'Optical',
45
+ 4: 'Internal',
46
+ 5: 'External',
47
+ 6: 'Remote',
48
+ };
49
+ const causeStates = {
50
+ 0: 'None',
51
+ 1: 'Smoke',
52
+ 2: 'Water',
53
+ 3: 'Smoke & Water',
54
+ 4: 'Temperature',
55
+ 5: 'Temperature & Smoke',
56
+ 6: 'Temperature & Water',
57
+ 7: 'Temperature & Smoke & Water',
58
+ 8: 'Arc Fault',
59
+ 9: 'Arc Fault & Smoke',
60
+ 10: 'Arc Fault & Water',
61
+ 11: 'Arc Fault & Smoke & Water',
62
+ 12: 'Arc Fault & Temperature',
63
+ 13: 'Arc Fault & Temperature & Smoke',
64
+ 14: 'Arc Fault & Temperature & Water',
65
+ 15: 'Arc Fault & Temperature & Smoke & Water',
66
+ };
67
+ await this.createSimpleControlStateObjectAsync(
68
+ control.name,
69
+ uuid,
70
+ control.states,
71
+ 'nextLevel',
72
+ 'number',
73
+ 'value',
74
+ { states: levelStates },
75
+ );
76
+ await this.createSimpleControlStateObjectAsync(
77
+ control.name,
78
+ uuid,
79
+ control.states,
80
+ 'nextLevelDelay',
81
+ 'number',
82
+ 'value.interval',
83
+ );
84
+ await this.createSimpleControlStateObjectAsync(
85
+ control.name,
86
+ uuid,
87
+ control.states,
88
+ 'nextLevelDelayTotal',
89
+ 'number',
90
+ 'value.interval',
91
+ );
92
+ await this.createSimpleControlStateObjectAsync(control.name, uuid, control.states, 'level', 'number', 'value', {
93
+ states: levelStates,
94
+ });
95
+ await this.createListControlStateObjectAsync(control.name, uuid, control.states, 'sensors');
96
+ await this.createBooleanControlStateObjectAsync(
97
+ control.name,
98
+ uuid,
99
+ control.states,
100
+ 'acousticAlarm',
101
+ 'indicator',
102
+ );
103
+ await this.createBooleanControlStateObjectAsync(control.name, uuid, control.states, 'testAlarm', 'indicator');
104
+ await this.createSimpleControlStateObjectAsync(
105
+ control.name,
106
+ uuid,
107
+ control.states,
108
+ 'alarmCause',
109
+ 'number',
110
+ 'value',
111
+ { states: causeStates },
112
+ );
113
+ await this.createSimpleControlStateObjectAsync(
114
+ control.name,
115
+ uuid,
116
+ control.states,
117
+ 'startTime',
118
+ 'string',
119
+ 'value.datetime',
120
+ );
121
+ await this.createSimpleControlStateObjectAsync(
122
+ control.name,
123
+ uuid,
124
+ control.states,
125
+ 'timeServiceMode',
126
+ 'number',
127
+ 'level.interval',
128
+ { write: true },
129
+ );
130
+
131
+ await this.createButtonCommandStateObjectAsync(control.name, uuid, 'mute');
132
+ this.addStateChangeListener(
133
+ `${uuid}.mute`,
134
+ () => {
135
+ this.sendCommand(control.uuidAction, 'mute');
136
+ },
137
+ { selfAck: true },
138
+ );
139
+
140
+ await this.createButtonCommandStateObjectAsync(control.name, uuid, 'quit');
141
+ this.addStateChangeListener(
142
+ `${uuid}.quit`,
143
+ () => {
144
+ this.sendCommand(control.uuidAction, 'quit');
145
+ },
146
+ { selfAck: true },
147
+ );
148
+
149
+ this.addStateChangeListener(
150
+ `${uuid}.timeServiceMode`,
151
+ (oldValue: OldStateValue, newValue: CurrentStateValue) => {
152
+ newValue = this.convertStateToInt(newValue);
153
+ if (newValue === undefined || newValue < 0) {
154
+ return;
155
+ }
156
+
157
+ this.sendCommand(control.uuidAction, `servicemode/${newValue}`);
158
+ },
159
+ );
160
+
161
+ // subControls are not needed because "sensors" already contains the information from the tracker
162
+ }
163
+ }
@@ -0,0 +1,46 @@
1
+ import type { CurrentStateValue, OldStateValue } from '../main';
2
+ import type { Control } from '../structure-file';
3
+ import type { ControlType } from './control-base';
4
+ import { ControlBase } from './control-base';
5
+
6
+ /**
7
+ * Handler for Switch controls.
8
+ */
9
+ export class Switch extends ControlBase {
10
+ /**
11
+ * Loads the control and sets up state objects and event handlers.
12
+ *
13
+ * @param type The type of the control ('device' or 'channel').
14
+ * @param uuid The unique identifier of the control.
15
+ * @param control The control data from the structure file.
16
+ */
17
+ async loadAsync(type: ControlType, uuid: string, control: Control): Promise<void> {
18
+ await this.updateObjectAsync(uuid, {
19
+ type: type,
20
+ common: {
21
+ name: control.name,
22
+ role: 'switch',
23
+ },
24
+ native: { control },
25
+ });
26
+
27
+ await this.loadOtherControlStatesAsync(control.name, uuid, control.states, ['active']);
28
+
29
+ await this.createBooleanControlStateObjectAsync(control.name, uuid, control.states, 'active', 'switch', {
30
+ write: true,
31
+ // TODO: re-add: smartIgnore: type == 'channel',
32
+ });
33
+
34
+ this.addStateChangeListener(
35
+ `${uuid}.active`,
36
+ (oldValue: OldStateValue, newValue: CurrentStateValue) => {
37
+ if (newValue) {
38
+ this.sendCommand(control.uuidAction, 'on');
39
+ } else {
40
+ this.sendCommand(control.uuidAction, 'off');
41
+ }
42
+ },
43
+ { notIfEqual: true },
44
+ );
45
+ }
46
+ }
@@ -0,0 +1,13 @@
1
+ import { ControlBase } from './control-base';
2
+
3
+ /**
4
+ * Handler for the SystemScheme control.
5
+ */
6
+ export class SystemScheme extends ControlBase {
7
+ /**
8
+ * Loads the control and sets up state objects and event handlers.
9
+ */
10
+ async loadAsync(): Promise<void> {
11
+ // SystemScheme has no states, thus we don't use it at all
12
+ }
13
+ }
@@ -0,0 +1,96 @@
1
+ import type { CurrentStateValue, OldStateValue } from '../main';
2
+ import type { Control, ControlStates } from '../structure-file';
3
+ import type { ControlType } from './control-base';
4
+ import { ControlBase } from './control-base';
5
+
6
+ /**
7
+ * Handler for TextInput controls.
8
+ */
9
+ export class TextInput extends ControlBase {
10
+ /**
11
+ * Loads the control and sets up state objects and event handlers.
12
+ *
13
+ * @param type The type of the control ('device' or 'channel').
14
+ * @param uuid The unique identifier of the control.
15
+ * @param control The control data from the structure file.
16
+ */
17
+ async loadAsync(type: ControlType, uuid: string, control: Control): Promise<void> {
18
+ await this.updateObjectAsync(uuid, {
19
+ type: type,
20
+ common: {
21
+ name: control.name,
22
+ role: 'sensor',
23
+ },
24
+ native: { control },
25
+ });
26
+
27
+ await this.loadOtherControlStatesAsync(control.name, uuid, control.states, ['text']);
28
+
29
+ const common: Partial<ioBroker.StateCommon> = { write: true };
30
+
31
+ await this.createTextInputStateObjectAsync(
32
+ control.name,
33
+ uuid,
34
+ control.states,
35
+ 'text',
36
+ 'string',
37
+ 'text',
38
+ common,
39
+ );
40
+ this.addStateChangeListener(`${uuid}.text`, (oldValue: OldStateValue, newValue: CurrentStateValue) => {
41
+ this.sendCommand(control.uuidAction, (newValue || '').toString());
42
+ });
43
+
44
+ if (!('details' in control)) {
45
+ return;
46
+ }
47
+
48
+ if ('format' in control.details) {
49
+ await this.updateStateObjectAsync(
50
+ `${uuid}.value-formatted`,
51
+ {
52
+ name: `${control.name}: formatted value`,
53
+ read: true,
54
+ write: false,
55
+ type: 'string',
56
+ role: 'text',
57
+ // TODO: re-add: smartIgnore: true,
58
+ },
59
+ control.states.value,
60
+ async (name: string, value: any) => {
61
+ await this.setFormattedStateAck(name, value, control.details.format as string);
62
+ },
63
+ );
64
+ }
65
+ }
66
+
67
+ protected async createTextInputStateObjectAsync(
68
+ controlName: string,
69
+ uuid: string,
70
+ states: ControlStates,
71
+ name: string,
72
+ type: ioBroker.CommonType,
73
+ role: string,
74
+ commonExt?: Partial<ioBroker.StateCommon>,
75
+ ): Promise<void> {
76
+ if (states !== undefined && name in states) {
77
+ let common: ioBroker.StateCommon = {
78
+ name: `${controlName}: ${name}`,
79
+ read: false,
80
+ write: true,
81
+ type: type,
82
+ role: role,
83
+ //smartIgnore: true,
84
+ };
85
+ if (commonExt && typeof commonExt === 'object') {
86
+ common = { ...common, ...commonExt };
87
+ }
88
+ await this.updateStateObjectAsync(
89
+ `${uuid}.${this.normalizeName(name)}`,
90
+ common,
91
+ states[name],
92
+ this.setStateAck.bind(this),
93
+ );
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,37 @@
1
+ import type { Control } from '../structure-file';
2
+ import type { ControlType } from './control-base';
3
+ import { ControlBase } from './control-base';
4
+
5
+ /**
6
+ * Handler for TextState controls.
7
+ */
8
+ export class TextState extends ControlBase {
9
+ /**
10
+ * Loads the control and sets up state objects and event handlers.
11
+ *
12
+ * @param type The type of the control ('device' or 'channel').
13
+ * @param uuid The unique identifier of the control.
14
+ * @param control The control data from the structure file.
15
+ */
16
+ async loadAsync(type: ControlType, uuid: string, control: Control): Promise<void> {
17
+ await this.updateObjectAsync(uuid, {
18
+ type: type,
19
+ common: {
20
+ name: control.name,
21
+ role: 'info',
22
+ },
23
+ native: { control },
24
+ });
25
+
26
+ await this.loadOtherControlStatesAsync(control.name, uuid, control.states, ['textAndIcon']);
27
+
28
+ await this.createSimpleControlStateObjectAsync(
29
+ control.name,
30
+ uuid,
31
+ control.states,
32
+ 'textAndIcon',
33
+ 'string',
34
+ 'text',
35
+ );
36
+ }
37
+ }
@@ -0,0 +1,75 @@
1
+ import type { Control } from '../structure-file';
2
+ import type { ControlType } from './control-base';
3
+ import { ControlBase } from './control-base';
4
+
5
+ /**
6
+ * Handler for TimedSwitch controls.
7
+ */
8
+ export class TimedSwitch extends ControlBase {
9
+ /**
10
+ * Loads the control and sets up state objects and event handlers.
11
+ *
12
+ * @param type The type of the control ('device' or 'channel').
13
+ * @param uuid The unique identifier of the control.
14
+ * @param control The control data from the structure file.
15
+ */
16
+ async loadAsync(type: ControlType, uuid: string, control: Control): Promise<void> {
17
+ await this.updateObjectAsync(uuid, {
18
+ type: type,
19
+ common: {
20
+ name: control.name,
21
+ role: 'switch',
22
+ },
23
+ native: { control },
24
+ });
25
+
26
+ await this.loadOtherControlStatesAsync(control.name, uuid, control.states, [
27
+ 'deactivationDelayTotal',
28
+ 'deactivationDelay',
29
+ ]);
30
+
31
+ await this.createSimpleControlStateObjectAsync(
32
+ control.name,
33
+ uuid,
34
+ control.states,
35
+ 'deactivationDelayTotal',
36
+ 'number',
37
+ 'value.interval',
38
+ );
39
+ await this.createSimpleControlStateObjectAsync(
40
+ control.name,
41
+ uuid,
42
+ control.states,
43
+ 'deactivationDelay',
44
+ 'number',
45
+ 'value.interval',
46
+ );
47
+
48
+ await this.createButtonCommandStateObjectAsync(control.name, uuid, 'on');
49
+ this.addStateChangeListener(
50
+ `${uuid}.on`,
51
+ () => {
52
+ this.sendCommand(control.uuidAction, 'on');
53
+ },
54
+ { selfAck: true },
55
+ );
56
+
57
+ await this.createButtonCommandStateObjectAsync(control.name, uuid, 'off');
58
+ this.addStateChangeListener(
59
+ `${uuid}.off`,
60
+ () => {
61
+ this.sendCommand(control.uuidAction, 'off');
62
+ },
63
+ { selfAck: true },
64
+ );
65
+
66
+ await this.createButtonCommandStateObjectAsync(control.name, uuid, 'pulse');
67
+ this.addStateChangeListener(
68
+ `${uuid}.pulse`,
69
+ () => {
70
+ this.sendCommand(control.uuidAction, 'pulse');
71
+ },
72
+ { selfAck: true },
73
+ );
74
+ }
75
+ }
@@ -0,0 +1,30 @@
1
+ import type { Control } from '../structure-file';
2
+ import type { ControlType } from './control-base';
3
+ import { ControlBase } from './control-base';
4
+
5
+ /**
6
+ * Handler for Tracker controls.
7
+ */
8
+ export class Tracker extends ControlBase {
9
+ /**
10
+ * Loads the control and sets up state objects and event handlers.
11
+ *
12
+ * @param type The type of the control ('device' or 'channel').
13
+ * @param uuid The unique identifier of the control.
14
+ * @param control The control data from the structure file.
15
+ */
16
+ async loadAsync(type: ControlType, uuid: string, control: Control): Promise<void> {
17
+ await this.updateObjectAsync(uuid, {
18
+ type: type,
19
+ common: {
20
+ name: control.name,
21
+ role: 'info',
22
+ },
23
+ native: { control },
24
+ });
25
+
26
+ await this.loadOtherControlStatesAsync(control.name, uuid, control.states, ['entries']);
27
+
28
+ await this.createListControlStateObjectAsync(control.name, uuid, control.states, 'entries');
29
+ }
30
+ }
@@ -1,31 +1,37 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Unknown = void 0;
4
- const SentryNode = require("@sentry/node");
5
- const control_base_1 = require("./control-base");
1
+ import type { Control } from '../structure-file';
2
+ import type { ControlType } from './control-base';
3
+ import { ControlBase } from './control-base';
4
+
6
5
  /**
7
6
  * This class is used if the control has an unknown type.
8
7
  * It will just load the simple default states.
9
8
  */
10
- class Unknown extends control_base_1.ControlBase {
11
- async loadAsync(type, uuid, control) {
12
- var _a;
9
+ export class Unknown extends ControlBase {
10
+ /**
11
+ * Loads the control and sets up state objects and event handlers.
12
+ *
13
+ * @param type The type of the control ('device' or 'channel').
14
+ * @param uuid The unique identifier of the control.
15
+ * @param control The control data from the structure file.
16
+ */
17
+ async loadAsync(type: ControlType, uuid: string, control: Control): Promise<void> {
13
18
  // report unsupported control
14
19
  const existingObject = this.adapter.getExistingObject(uuid);
15
20
  const currentVersion = this.adapter.version;
16
21
  const msg = `Unsupported ${type} control ${control.type}`;
17
22
  this.adapter.log.info(msg);
18
- if (((_a = existingObject === null || existingObject === void 0 ? void 0 : existingObject.native) === null || _a === void 0 ? void 0 : _a.reportedVersion) !== currentVersion) {
23
+ if (existingObject?.native?.reportedVersion !== currentVersion) {
19
24
  // missing control wasn't reported yet for the current adapter version
20
25
  if (!this.adapter.reportedMissingControls.has(msg)) {
21
26
  this.adapter.reportedMissingControls.add(msg);
22
27
  const sentry = this.adapter.getSentry();
23
- sentry === null || sentry === void 0 ? void 0 : sentry.withScope((scope) => {
28
+ sentry?.withScope(scope => {
24
29
  scope.setExtra('control', JSON.stringify(control, null, 2));
25
- sentry.captureMessage(msg, SentryNode.Severity.Warning);
30
+ sentry.captureMessage(msg, 'warning');
26
31
  });
27
32
  }
28
33
  }
34
+
29
35
  await this.updateObjectAsync(uuid, {
30
36
  type: type,
31
37
  common: {
@@ -34,9 +40,9 @@ class Unknown extends control_base_1.ControlBase {
34
40
  },
35
41
  native: { control, reportedVersion: currentVersion },
36
42
  });
43
+
37
44
  await this.loadOtherControlStatesAsync(control.name, uuid, control.states, []);
45
+
38
46
  await this.loadSubControlsAsync(uuid, control);
39
47
  }
40
48
  }
41
- exports.Unknown = Unknown;
42
- //# sourceMappingURL=Unknown.js.map
@@ -0,0 +1,78 @@
1
+ import type { CurrentStateValue, OldStateValue } from '../main';
2
+ import type { Control } from '../structure-file';
3
+ import type { ControlType } from './control-base';
4
+ import { ControlBase } from './control-base';
5
+
6
+ /**
7
+ * Handler for UpDownAnalog controls.
8
+ */
9
+ export class UpDownAnalog extends ControlBase {
10
+ /**
11
+ * Loads the control and sets up state objects and event handlers.
12
+ *
13
+ * @param type The type of the control ('device' or 'channel').
14
+ * @param uuid The unique identifier of the control.
15
+ * @param control The control data from the structure file.
16
+ */
17
+ async loadAsync(type: ControlType, uuid: string, control: Control): Promise<void> {
18
+ await this.updateObjectAsync(uuid, {
19
+ type: type,
20
+ common: {
21
+ name: control.name,
22
+ role: 'sensor',
23
+ },
24
+ native: { control },
25
+ });
26
+
27
+ await this.loadOtherControlStatesAsync(control.name, uuid, control.states, ['value', 'error']);
28
+
29
+ const common: Partial<ioBroker.StateCommon> = { write: true };
30
+ if ('details' in control) {
31
+ common.min = control.details.min as number;
32
+ common.max = control.details.max as number;
33
+ }
34
+
35
+ await this.createSimpleControlStateObjectAsync(
36
+ control.name,
37
+ uuid,
38
+ control.states,
39
+ 'value',
40
+ 'number',
41
+ 'level',
42
+ common,
43
+ );
44
+ this.addStateChangeListener(`${uuid}.value`, (oldValue: OldStateValue, newValue: CurrentStateValue) => {
45
+ this.sendCommand(control.uuidAction, (newValue || '0').toString());
46
+ });
47
+
48
+ await this.createBooleanControlStateObjectAsync(
49
+ control.name,
50
+ uuid,
51
+ control.states,
52
+ 'error',
53
+ 'indicator.maintenance',
54
+ );
55
+
56
+ if (!('details' in control)) {
57
+ return;
58
+ }
59
+
60
+ if ('format' in control.details) {
61
+ await this.updateStateObjectAsync(
62
+ `${uuid}.value-formatted`,
63
+ {
64
+ name: `${control.name}: formatted value`,
65
+ read: true,
66
+ write: false,
67
+ type: 'string',
68
+ role: 'text',
69
+ // TODO: re-add: smartIgnore: true,
70
+ },
71
+ control.states.value,
72
+ async (name: string, value: any) => {
73
+ await this.setFormattedStateAck(name, value, control.details.format as string);
74
+ },
75
+ );
76
+ }
77
+ }
78
+ }