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.
- package/LICENSE +1 -1
- package/README.md +425 -402
- package/admin/i18n/de.json +15 -0
- package/admin/i18n/en.json +15 -0
- package/admin/i18n/es.json +18 -0
- package/admin/i18n/fr.json +18 -0
- package/admin/i18n/it.json +18 -0
- package/admin/i18n/nl.json +18 -0
- package/admin/i18n/pl.json +18 -0
- package/admin/i18n/pt.json +18 -0
- package/admin/i18n/ru.json +18 -0
- package/admin/i18n/uk.json +18 -0
- package/admin/i18n/zh-cn.json +18 -0
- package/admin/jsonConfig.json +96 -0
- package/io-package.json +309 -349
- package/package.json +42 -46
- package/src/controls/AalEmergency.ts +90 -0
- package/src/controls/AalSmartAlarm.ts +99 -0
- package/src/controls/Alarm.ts +146 -0
- package/src/controls/AlarmClock.ts +137 -0
- package/src/controls/Application.ts +13 -0
- package/src/controls/AudioZone.ts +227 -0
- package/src/controls/AudioZoneV2.ts +135 -0
- package/src/controls/CentralAlarm.ts +59 -0
- package/src/controls/CentralAudioZone.ts +41 -0
- package/src/controls/CentralGate.ts +53 -0
- package/src/controls/CentralJalousie.ts +67 -0
- package/src/controls/CentralLightController.ts +45 -0
- package/src/controls/ColorPickerV2.ts +34 -0
- package/src/controls/Colorpicker.ts +30 -0
- package/src/controls/ColorpickerBase.ts +326 -0
- package/src/controls/Daytimer.ts +201 -0
- package/src/controls/Dimmer.ts +64 -0
- package/src/controls/EIBDimmer.ts +61 -0
- package/src/controls/Fronius.ts +217 -0
- package/src/controls/Gate.ts +150 -0
- package/src/controls/Hourcounter.ts +115 -0
- package/src/controls/IRCDaytimer.ts +4 -0
- package/src/controls/IRCV2Daytimer.ts +4 -0
- package/src/controls/IRoomControllerV2.ts +595 -0
- package/src/controls/InfoOnlyAnalog.ts +56 -0
- package/src/controls/InfoOnlyDigital.ts +95 -0
- package/src/controls/InfoOnlyText.ts +52 -0
- package/{build/controls/Intercom.js → src/controls/Intercom.ts} +27 -11
- package/src/controls/Jalousie.ts +219 -0
- package/src/controls/LightController.ts +112 -0
- package/src/controls/LightControllerV2.ts +246 -0
- package/src/controls/MailBox.ts +92 -0
- package/src/controls/Meter.ts +94 -0
- package/src/controls/None.ts +29 -0
- package/src/controls/PresenceDetector.ts +47 -0
- package/src/controls/Pushbutton.ts +55 -0
- package/src/controls/Radio.ts +61 -0
- package/src/controls/Remote.ts +44 -0
- package/src/controls/Slider.ts +78 -0
- package/src/controls/SmokeAlarm.ts +163 -0
- package/src/controls/Switch.ts +46 -0
- package/src/controls/SystemScheme.ts +13 -0
- package/src/controls/TextInput.ts +96 -0
- package/src/controls/TextState.ts +37 -0
- package/src/controls/TimedSwitch.ts +75 -0
- package/src/controls/Tracker.ts +30 -0
- package/{build/controls/Unknown.js → src/controls/Unknown.ts} +19 -13
- package/src/controls/UpDownAnalog.ts +78 -0
- package/{build/controls/ValueSelector.js → src/controls/ValueSelector.ts} +21 -9
- package/src/controls/WindowMonitor.ts +139 -0
- package/src/controls/all-controls.ts +99 -0
- package/src/controls/control-base.ts +28 -0
- package/src/lib/adapter-config.d.ts +22 -0
- package/src/loxone-handler-base.ts +285 -0
- package/src/lxcommunicator.d.ts +1 -0
- package/src/main.test.ts +24 -0
- package/src/main.ts +1178 -0
- package/src/structure-file.d.ts +154 -0
- package/src/weather-server-handler.ts +266 -0
- package/admin/admin.d.ts +0 -58
- package/admin/index_m.html +0 -126
- package/admin/style.css +0 -32
- package/admin/words.js +0 -25
- package/build/controls/AalEmergency.js +0 -45
- package/build/controls/AalEmergency.js.map +0 -1
- package/build/controls/AalSmartAlarm.js +0 -48
- package/build/controls/AalSmartAlarm.js.map +0 -1
- package/build/controls/Alarm.js +0 -81
- package/build/controls/Alarm.js.map +0 -1
- package/build/controls/AlarmClock.js +0 -59
- package/build/controls/AlarmClock.js.map +0 -1
- package/build/controls/Application.js +0 -11
- package/build/controls/Application.js.map +0 -1
- package/build/controls/AudioZone.js +0 -116
- package/build/controls/AudioZone.js.map +0 -1
- package/build/controls/CentralAlarm.js +0 -30
- package/build/controls/CentralAlarm.js.map +0 -1
- package/build/controls/CentralAudioZone.js +0 -22
- package/build/controls/CentralAudioZone.js.map +0 -1
- package/build/controls/CentralGate.js +0 -30
- package/build/controls/CentralGate.js.map +0 -1
- package/build/controls/CentralJalousie.js +0 -39
- package/build/controls/CentralJalousie.js.map +0 -1
- package/build/controls/CentralLightController.js +0 -27
- package/build/controls/CentralLightController.js.map +0 -1
- package/build/controls/ColorPickerV2.js +0 -24
- package/build/controls/ColorPickerV2.js.map +0 -1
- package/build/controls/Colorpicker.js +0 -20
- package/build/controls/Colorpicker.js.map +0 -1
- package/build/controls/ColorpickerBase.js +0 -263
- package/build/controls/ColorpickerBase.js.map +0 -1
- package/build/controls/Daytimer.js +0 -119
- package/build/controls/Daytimer.js.map +0 -1
- package/build/controls/Dimmer.js +0 -34
- package/build/controls/Dimmer.js.map +0 -1
- package/build/controls/EIBDimmer.js +0 -31
- package/build/controls/EIBDimmer.js.map +0 -1
- package/build/controls/Fronius.js +0 -64
- package/build/controls/Fronius.js.map +0 -1
- package/build/controls/Gate.js +0 -109
- package/build/controls/Gate.js.map +0 -1
- package/build/controls/Hourcounter.js +0 -46
- package/build/controls/Hourcounter.js.map +0 -1
- package/build/controls/IRCDaytimer.js +0 -9
- package/build/controls/IRCDaytimer.js.map +0 -1
- package/build/controls/IRoomControllerV2.js +0 -272
- package/build/controls/IRoomControllerV2.js.map +0 -1
- package/build/controls/InfoOnlyAnalog.js +0 -38
- package/build/controls/InfoOnlyAnalog.js.map +0 -1
- package/build/controls/InfoOnlyDigital.js +0 -65
- package/build/controls/InfoOnlyDigital.js.map +0 -1
- package/build/controls/InfoOnlyText.js +0 -35
- package/build/controls/InfoOnlyText.js.map +0 -1
- package/build/controls/Intercom.js.map +0 -1
- package/build/controls/Jalousie.js +0 -156
- package/build/controls/Jalousie.js.map +0 -1
- package/build/controls/LightController.js +0 -68
- package/build/controls/LightController.js.map +0 -1
- package/build/controls/LightControllerV2.js +0 -195
- package/build/controls/LightControllerV2.js.map +0 -1
- package/build/controls/MailBox.js +0 -41
- package/build/controls/MailBox.js.map +0 -1
- package/build/controls/Meter.js +0 -52
- package/build/controls/Meter.js.map +0 -1
- package/build/controls/None.js +0 -23
- package/build/controls/None.js.map +0 -1
- package/build/controls/PresenceDetector.js +0 -29
- package/build/controls/PresenceDetector.js.map +0 -1
- package/build/controls/Pushbutton.js +0 -38
- package/build/controls/Pushbutton.js.map +0 -1
- package/build/controls/Radio.js +0 -42
- package/build/controls/Radio.js.map +0 -1
- package/build/controls/Slider.js +0 -44
- package/build/controls/Slider.js.map +0 -1
- package/build/controls/SmokeAlarm.js +0 -85
- package/build/controls/SmokeAlarm.js.map +0 -1
- package/build/controls/Switch.js +0 -34
- package/build/controls/Switch.js.map +0 -1
- package/build/controls/SystemScheme.js +0 -11
- package/build/controls/SystemScheme.js.map +0 -1
- package/build/controls/TextInput.js +0 -55
- package/build/controls/TextInput.js.map +0 -1
- package/build/controls/TextState.js +0 -20
- package/build/controls/TextState.js.map +0 -1
- package/build/controls/TimedSwitch.js +0 -36
- package/build/controls/TimedSwitch.js.map +0 -1
- package/build/controls/Tracker.js +0 -20
- package/build/controls/Tracker.js.map +0 -1
- package/build/controls/Unknown.js.map +0 -1
- package/build/controls/UpDownAnalog.js +0 -44
- package/build/controls/UpDownAnalog.js.map +0 -1
- package/build/controls/ValueSelector.js.map +0 -1
- package/build/controls/WindowMonitor.js +0 -84
- package/build/controls/WindowMonitor.js.map +0 -1
- package/build/controls/control-base.js +0 -12
- package/build/controls/control-base.js.map +0 -1
- package/build/loxone-handler-base.js +0 -186
- package/build/loxone-handler-base.js.map +0 -1
- package/build/main.js +0 -643
- package/build/main.js.map +0 -1
- package/build/weather-server-handler.js +0 -120
- package/build/weather-server-handler.js.map +0 -1
- package/doc/details-missing-control-type.png +0 -0
- package/doc/log-missing-control-type.png +0 -0
- package/doc/loxone-config-display-diagnostics.png +0 -0
- package/doc/loxone-config-info-only-digital.png +0 -0
- package/doc/loxone-config-use-in-visualization.png +0 -0
|
@@ -0,0 +1,217 @@
|
|
|
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 Fronius controls.
|
|
7
|
+
*/
|
|
8
|
+
export class Fronius 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
|
+
const systemConfig = await this.adapter.getForeignObjectAsync('system.config');
|
|
18
|
+
const currency = systemConfig?.common.currency;
|
|
19
|
+
await this.updateObjectAsync(uuid, {
|
|
20
|
+
type: type,
|
|
21
|
+
common: {
|
|
22
|
+
name: control.name,
|
|
23
|
+
role: 'sensor',
|
|
24
|
+
},
|
|
25
|
+
native: { control },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await this.loadOtherControlStatesAsync(control.name, uuid, control.states, [
|
|
29
|
+
'prodCurr',
|
|
30
|
+
'prodCurrDay',
|
|
31
|
+
'prodCurrMonth',
|
|
32
|
+
'prodCurrYear',
|
|
33
|
+
'prodTotal',
|
|
34
|
+
'consCurr',
|
|
35
|
+
'consCurrDay',
|
|
36
|
+
'consTotal',
|
|
37
|
+
'deliveryDay',
|
|
38
|
+
'earningsDay',
|
|
39
|
+
'earningsMonth',
|
|
40
|
+
'earningsYear',
|
|
41
|
+
'earningsTotal',
|
|
42
|
+
'gridCurr',
|
|
43
|
+
'batteryCurr',
|
|
44
|
+
'stateOfCharge',
|
|
45
|
+
'priceDelivery',
|
|
46
|
+
'priceConsumption',
|
|
47
|
+
'co2Factor',
|
|
48
|
+
'generatorType',
|
|
49
|
+
'mode',
|
|
50
|
+
'online',
|
|
51
|
+
]);
|
|
52
|
+
// note: priceDelivery, priceConsumption, generatorType and mode are ignored
|
|
53
|
+
// because they represent static data that is of no use to ioBroker
|
|
54
|
+
|
|
55
|
+
await this.createSimpleControlStateObjectAsync(
|
|
56
|
+
control.name,
|
|
57
|
+
uuid,
|
|
58
|
+
control.states,
|
|
59
|
+
'prodCurr',
|
|
60
|
+
'number',
|
|
61
|
+
'value',
|
|
62
|
+
{ unit: 'kW' },
|
|
63
|
+
);
|
|
64
|
+
await this.createSimpleControlStateObjectAsync(
|
|
65
|
+
control.name,
|
|
66
|
+
uuid,
|
|
67
|
+
control.states,
|
|
68
|
+
'prodCurrDay',
|
|
69
|
+
'number',
|
|
70
|
+
'value',
|
|
71
|
+
{ unit: 'kWh' },
|
|
72
|
+
);
|
|
73
|
+
await this.createSimpleControlStateObjectAsync(
|
|
74
|
+
control.name,
|
|
75
|
+
uuid,
|
|
76
|
+
control.states,
|
|
77
|
+
'prodCurrMonth',
|
|
78
|
+
'number',
|
|
79
|
+
'value',
|
|
80
|
+
{ unit: 'kWh' },
|
|
81
|
+
);
|
|
82
|
+
await this.createSimpleControlStateObjectAsync(
|
|
83
|
+
control.name,
|
|
84
|
+
uuid,
|
|
85
|
+
control.states,
|
|
86
|
+
'prodCurrYear',
|
|
87
|
+
'number',
|
|
88
|
+
'value',
|
|
89
|
+
{ unit: 'kWh' },
|
|
90
|
+
);
|
|
91
|
+
await this.createSimpleControlStateObjectAsync(
|
|
92
|
+
control.name,
|
|
93
|
+
uuid,
|
|
94
|
+
control.states,
|
|
95
|
+
'prodTotal',
|
|
96
|
+
'number',
|
|
97
|
+
'value',
|
|
98
|
+
{ unit: 'kWh' },
|
|
99
|
+
);
|
|
100
|
+
await this.createSimpleControlStateObjectAsync(
|
|
101
|
+
control.name,
|
|
102
|
+
uuid,
|
|
103
|
+
control.states,
|
|
104
|
+
'consCurr',
|
|
105
|
+
'number',
|
|
106
|
+
'value',
|
|
107
|
+
{ unit: 'kW' },
|
|
108
|
+
);
|
|
109
|
+
await this.createSimpleControlStateObjectAsync(
|
|
110
|
+
control.name,
|
|
111
|
+
uuid,
|
|
112
|
+
control.states,
|
|
113
|
+
'consCurrDay',
|
|
114
|
+
'number',
|
|
115
|
+
'value.power.consumption',
|
|
116
|
+
{ unit: 'kWh' },
|
|
117
|
+
);
|
|
118
|
+
await this.createSimpleControlStateObjectAsync(
|
|
119
|
+
control.name,
|
|
120
|
+
uuid,
|
|
121
|
+
control.states,
|
|
122
|
+
'consTotal',
|
|
123
|
+
'number',
|
|
124
|
+
'value.power.consumption',
|
|
125
|
+
{ unit: 'kWh' },
|
|
126
|
+
);
|
|
127
|
+
await this.createSimpleControlStateObjectAsync(
|
|
128
|
+
control.name,
|
|
129
|
+
uuid,
|
|
130
|
+
control.states,
|
|
131
|
+
'gridCurr',
|
|
132
|
+
'number',
|
|
133
|
+
'value',
|
|
134
|
+
{ unit: 'kW' },
|
|
135
|
+
);
|
|
136
|
+
await this.createSimpleControlStateObjectAsync(
|
|
137
|
+
control.name,
|
|
138
|
+
uuid,
|
|
139
|
+
control.states,
|
|
140
|
+
'batteryCurr',
|
|
141
|
+
'number',
|
|
142
|
+
'value',
|
|
143
|
+
{ unit: 'kW' },
|
|
144
|
+
);
|
|
145
|
+
await this.createSimpleControlStateObjectAsync(
|
|
146
|
+
control.name,
|
|
147
|
+
uuid,
|
|
148
|
+
control.states,
|
|
149
|
+
'stateOfCharge',
|
|
150
|
+
'number',
|
|
151
|
+
'value',
|
|
152
|
+
{ unit: '%' },
|
|
153
|
+
);
|
|
154
|
+
await this.createSimpleControlStateObjectAsync(
|
|
155
|
+
control.name,
|
|
156
|
+
uuid,
|
|
157
|
+
control.states,
|
|
158
|
+
'deliveryDay',
|
|
159
|
+
'number',
|
|
160
|
+
'value',
|
|
161
|
+
{ unit: 'kWh' },
|
|
162
|
+
);
|
|
163
|
+
await this.createSimpleControlStateObjectAsync(
|
|
164
|
+
control.name,
|
|
165
|
+
uuid,
|
|
166
|
+
control.states,
|
|
167
|
+
'earningsDay',
|
|
168
|
+
'number',
|
|
169
|
+
'value',
|
|
170
|
+
{ unit: currency },
|
|
171
|
+
);
|
|
172
|
+
await this.createSimpleControlStateObjectAsync(
|
|
173
|
+
control.name,
|
|
174
|
+
uuid,
|
|
175
|
+
control.states,
|
|
176
|
+
'earningsMonth',
|
|
177
|
+
'number',
|
|
178
|
+
'value',
|
|
179
|
+
{ unit: currency },
|
|
180
|
+
);
|
|
181
|
+
await this.createSimpleControlStateObjectAsync(
|
|
182
|
+
control.name,
|
|
183
|
+
uuid,
|
|
184
|
+
control.states,
|
|
185
|
+
'earningsYear',
|
|
186
|
+
'number',
|
|
187
|
+
'value',
|
|
188
|
+
{ unit: currency },
|
|
189
|
+
);
|
|
190
|
+
await this.createSimpleControlStateObjectAsync(
|
|
191
|
+
control.name,
|
|
192
|
+
uuid,
|
|
193
|
+
control.states,
|
|
194
|
+
'earningsTotal',
|
|
195
|
+
'number',
|
|
196
|
+
'value',
|
|
197
|
+
{ unit: currency },
|
|
198
|
+
);
|
|
199
|
+
await this.createSimpleControlStateObjectAsync(
|
|
200
|
+
control.name,
|
|
201
|
+
uuid,
|
|
202
|
+
control.states,
|
|
203
|
+
'co2Factor',
|
|
204
|
+
'number',
|
|
205
|
+
'value',
|
|
206
|
+
);
|
|
207
|
+
await this.createBooleanControlStateObjectAsync(
|
|
208
|
+
control.name,
|
|
209
|
+
uuid,
|
|
210
|
+
control.states,
|
|
211
|
+
'online',
|
|
212
|
+
'indicator.reachable',
|
|
213
|
+
{},
|
|
214
|
+
value => value != 1, // according to docs: 0 = online, 1 = offline
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
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 Gate controls.
|
|
8
|
+
*/
|
|
9
|
+
export class Gate 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: 'blind',
|
|
23
|
+
},
|
|
24
|
+
native: { control },
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
await this.loadOtherControlStatesAsync(control.name, uuid, control.states, [
|
|
28
|
+
'position',
|
|
29
|
+
'active',
|
|
30
|
+
'preventOpen',
|
|
31
|
+
'preventClose',
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
const activeStates = {
|
|
35
|
+
'-1': 'close',
|
|
36
|
+
0: 'not moving',
|
|
37
|
+
1: 'open',
|
|
38
|
+
};
|
|
39
|
+
await this.createPercentageControlStateObjectAsync(control.name, uuid, control.states, 'position', 'level', {
|
|
40
|
+
write: true,
|
|
41
|
+
// TODO: re-add: smartIgnore: false,
|
|
42
|
+
});
|
|
43
|
+
await this.createSimpleControlStateObjectAsync(
|
|
44
|
+
control.name,
|
|
45
|
+
uuid,
|
|
46
|
+
control.states,
|
|
47
|
+
'active',
|
|
48
|
+
'number',
|
|
49
|
+
'value',
|
|
50
|
+
{ write: true, states: activeStates },
|
|
51
|
+
);
|
|
52
|
+
await this.createBooleanControlStateObjectAsync(control.name, uuid, control.states, 'preventOpen', 'indicator');
|
|
53
|
+
await this.createBooleanControlStateObjectAsync(
|
|
54
|
+
control.name,
|
|
55
|
+
uuid,
|
|
56
|
+
control.states,
|
|
57
|
+
'preventClose',
|
|
58
|
+
'indicator',
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
this.addStateChangeListener(
|
|
62
|
+
`${uuid}.active`,
|
|
63
|
+
(oldValue: OldStateValue, newValue: CurrentStateValue) => {
|
|
64
|
+
if (newValue === 1) {
|
|
65
|
+
if (oldValue === -1) {
|
|
66
|
+
// open twice because we are currently closing
|
|
67
|
+
this.sendCommand(control.uuidAction, 'open');
|
|
68
|
+
}
|
|
69
|
+
this.sendCommand(control.uuidAction, 'open');
|
|
70
|
+
} else if (newValue === -1) {
|
|
71
|
+
if (oldValue === 1) {
|
|
72
|
+
// close twice because we are currently opening
|
|
73
|
+
this.sendCommand(control.uuidAction, 'close');
|
|
74
|
+
}
|
|
75
|
+
this.sendCommand(control.uuidAction, 'close');
|
|
76
|
+
} else if (newValue === 0) {
|
|
77
|
+
if (oldValue === 1) {
|
|
78
|
+
this.sendCommand(control.uuidAction, 'close');
|
|
79
|
+
} else if (oldValue === -1) {
|
|
80
|
+
this.sendCommand(control.uuidAction, 'open');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{ notIfEqual: true, convertToInt: true },
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
await this.createButtonCommandStateObjectAsync(control.name, uuid, 'open');
|
|
88
|
+
this.addStateChangeListener(
|
|
89
|
+
`${uuid}.open`,
|
|
90
|
+
() => {
|
|
91
|
+
this.sendCommand(control.uuidAction, 'open');
|
|
92
|
+
},
|
|
93
|
+
{ selfAck: true },
|
|
94
|
+
);
|
|
95
|
+
await this.createButtonCommandStateObjectAsync(control.name, uuid, 'close');
|
|
96
|
+
this.addStateChangeListener(
|
|
97
|
+
`${uuid}.close`,
|
|
98
|
+
() => {
|
|
99
|
+
this.sendCommand(control.uuidAction, 'close');
|
|
100
|
+
},
|
|
101
|
+
{ selfAck: true },
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// for Alexa support:
|
|
105
|
+
if (control.states.position) {
|
|
106
|
+
this.addStateChangeListener(
|
|
107
|
+
`${uuid}.position`,
|
|
108
|
+
(oldValue: OldStateValue, newValue: CurrentStateValue) => {
|
|
109
|
+
if (typeof oldValue !== 'number' || typeof newValue !== 'number') {
|
|
110
|
+
// This should never happen due to convertToInt flag
|
|
111
|
+
this.adapter.log.error(`Gate position is not a number`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let targetValue: number;
|
|
116
|
+
let isOpening: boolean;
|
|
117
|
+
if (oldValue < newValue) {
|
|
118
|
+
targetValue = (newValue - 1) / 100;
|
|
119
|
+
this.sendCommand(control.uuidAction, 'open');
|
|
120
|
+
isOpening = true;
|
|
121
|
+
} else {
|
|
122
|
+
targetValue = (newValue + 1) / 100;
|
|
123
|
+
this.sendCommand(control.uuidAction, 'close');
|
|
124
|
+
isOpening = false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (newValue === 100 || newValue === 0) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const listenerName = 'auto';
|
|
132
|
+
this.addStateEventHandler(
|
|
133
|
+
control.states.position,
|
|
134
|
+
(value: any) => {
|
|
135
|
+
if (isOpening && value >= targetValue) {
|
|
136
|
+
this.removeStateEventHandler(control.states.position, listenerName);
|
|
137
|
+
this.sendCommand(control.uuidAction, 'close');
|
|
138
|
+
} else if (!isOpening && value <= targetValue) {
|
|
139
|
+
this.removeStateEventHandler(control.states.position, listenerName);
|
|
140
|
+
this.sendCommand(control.uuidAction, 'open');
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
listenerName,
|
|
144
|
+
);
|
|
145
|
+
},
|
|
146
|
+
{ notIfEqual: true, convertToInt: true, minInt: 0, maxInt: 100, ackTimeoutMs: 2500 },
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
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 Hourcounter controls.
|
|
7
|
+
*/
|
|
8
|
+
export class Hourcounter 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: 'timer',
|
|
22
|
+
},
|
|
23
|
+
native: { control },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await this.loadOtherControlStatesAsync(control.name, uuid, control.states, [
|
|
27
|
+
'total',
|
|
28
|
+
'remaining',
|
|
29
|
+
'lastActivation',
|
|
30
|
+
'overdue',
|
|
31
|
+
'maintenanceInterval',
|
|
32
|
+
'stateUnit',
|
|
33
|
+
'active',
|
|
34
|
+
'overdueSince',
|
|
35
|
+
]);
|
|
36
|
+
// stateUnit is ignored as it is not used by ioBroker (all states are always in seconds)
|
|
37
|
+
|
|
38
|
+
await this.createSimpleControlStateObjectAsync(control.name, uuid, control.states, 'total', 'number', 'value', {
|
|
39
|
+
unit: 'sec',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
await this.createSimpleControlStateObjectAsync(
|
|
43
|
+
control.name,
|
|
44
|
+
uuid,
|
|
45
|
+
control.states,
|
|
46
|
+
'remaining',
|
|
47
|
+
'number',
|
|
48
|
+
'value',
|
|
49
|
+
{ unit: 'sec' },
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
await this.createSimpleControlStateObjectAsync(
|
|
53
|
+
control.name,
|
|
54
|
+
uuid,
|
|
55
|
+
control.states,
|
|
56
|
+
'lastActivation',
|
|
57
|
+
'number',
|
|
58
|
+
'value.time',
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
await this.createBooleanControlStateObjectAsync(
|
|
62
|
+
control.name,
|
|
63
|
+
uuid,
|
|
64
|
+
control.states,
|
|
65
|
+
'overdue',
|
|
66
|
+
'indicator.maintenance',
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
await this.createSimpleControlStateObjectAsync(
|
|
70
|
+
control.name,
|
|
71
|
+
uuid,
|
|
72
|
+
control.states,
|
|
73
|
+
'maintenanceInterval',
|
|
74
|
+
'number',
|
|
75
|
+
'value',
|
|
76
|
+
{ unit: 'sec' },
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
await this.createBooleanControlStateObjectAsync(
|
|
80
|
+
control.name,
|
|
81
|
+
uuid,
|
|
82
|
+
control.states,
|
|
83
|
+
'active',
|
|
84
|
+
'indicator.working',
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
await this.createSimpleControlStateObjectAsync(
|
|
88
|
+
control.name,
|
|
89
|
+
uuid,
|
|
90
|
+
control.states,
|
|
91
|
+
'overdueSince',
|
|
92
|
+
'number',
|
|
93
|
+
'value',
|
|
94
|
+
{ unit: 'sec' },
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
await this.createButtonCommandStateObjectAsync(control.name, uuid, 'reset');
|
|
98
|
+
this.addStateChangeListener(
|
|
99
|
+
`${uuid}.reset`,
|
|
100
|
+
() => {
|
|
101
|
+
this.sendCommand(control.uuidAction, 'reset');
|
|
102
|
+
},
|
|
103
|
+
{ selfAck: true },
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
await this.createButtonCommandStateObjectAsync(control.name, uuid, 'resetAll');
|
|
107
|
+
this.addStateChangeListener(
|
|
108
|
+
`${uuid}.resetAll`,
|
|
109
|
+
() => {
|
|
110
|
+
this.sendCommand(control.uuidAction, 'resetAll');
|
|
111
|
+
},
|
|
112
|
+
{ selfAck: true },
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|