hoffmation-base 0.1.1 → 0.1.5
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/.eslintrc.js +27 -27
- package/.github/workflows/npm-publish.yml +50 -0
- package/.prettierrc.js +9 -9
- package/LICENSE +21 -21
- package/index.js +1 -1
- package/models/connectionCallbacks.ts +13 -13
- package/models/daytime.ts +3 -3
- package/models/deviceConfig.ts +8 -8
- package/models/dimmerSettings.ts +5 -5
- package/models/iTemperaturDataPoint.ts +9 -9
- package/models/lampSettings.ts +5 -5
- package/models/ledSettings.ts +19 -19
- package/models/logLevel.ts +9 -9
- package/models/persistence/BasicRoomInfo.ts +3 -3
- package/models/persistence/DailyMovementCount.ts +3 -3
- package/models/persistence/RoomDetailInfo.ts +4 -4
- package/models/persistence/temperaturDataPoint.ts +12 -12
- package/models/persistence/todaysCount.ts +3 -3
- package/models/rooms/RoomBase.ts +357 -357
- package/models/rooms/RoomSettings/RoomSettings.ts +159 -159
- package/models/rooms/RoomSettings/hmIPRoomSettings.ts +53 -53
- package/models/rooms/RoomSettings/iRoomDefaultSettings.ts +17 -17
- package/models/rooms/RoomSettings/readme.md +17 -17
- package/models/rooms/RoomSettings/zigbeeRoomSettings.ts +51 -51
- package/models/rooms/iRoomImportEnforcer.ts +3 -3
- package/models/rooms/readme.md +11 -11
- package/models/temperaturSettings.ts +22 -22
- package/models/timeCallback.ts +90 -90
- package/package.json +1 -1
- package/server/config/config-readme.md +19 -19
- package/server/config/iConfig.ts +53 -53
- package/server/config/private/mainConfig.json +64 -64
- package/server/devices/DeviceInfo.ts +66 -66
- package/server/devices/Griffe.ts +31 -31
- package/server/devices/Heizgruppen.ts +91 -91
- package/server/devices/Rollos.ts +48 -48
- package/server/devices/deviceUpdater.ts +72 -72
- package/server/devices/devices.ts +189 -189
- package/server/devices/groups/fensterGroup.ts +175 -175
- package/server/devices/groups/heatGroup.ts +32 -32
- package/server/devices/groups/lampenGroup.ts +88 -88
- package/server/devices/groups/praesenzGroup.ts +182 -182
- package/server/devices/groups/smokeGroup.ts +16 -16
- package/server/devices/groups/sonosGroup.ts +33 -33
- package/server/devices/groups/tasterGroup.ts +48 -48
- package/server/devices/groups/waterGroup.ts +16 -16
- package/server/devices/hmIPDevices/Fenster.ts +114 -114
- package/server/devices/hmIPDevices/FensterPosition.ts +5 -5
- package/server/devices/hmIPDevices/TuerPosition.ts +4 -4
- package/server/devices/hmIPDevices/hmIpBewegung.ts +126 -126
- package/server/devices/hmIPDevices/hmIpDevice.ts +90 -90
- package/server/devices/hmIPDevices/hmIpDeviceType.ts +14 -14
- package/server/devices/hmIPDevices/hmIpGriff.ts +143 -143
- package/server/devices/hmIPDevices/hmIpHeizgruppe.ts +172 -172
- package/server/devices/hmIPDevices/hmIpHeizung.ts +69 -69
- package/server/devices/hmIPDevices/hmIpLampe.ts +119 -119
- package/server/devices/hmIPDevices/hmIpPraezenz.ts +99 -99
- package/server/devices/hmIPDevices/hmIpRoll.ts +133 -133
- package/server/devices/hmIPDevices/hmIpTaster.ts +82 -73
- package/server/devices/hmIPDevices/hmIpTherm.ts +19 -19
- package/server/devices/hmIPDevices/hmIpTuer.ts +115 -115
- package/server/devices/hmIPDevices/hmIpWippe.ts +55 -55
- package/server/devices/iDeviceUpdater.ts +4 -4
- package/server/devices/iIoBrokerDevice.ts +44 -44
- package/server/devices/iTaster.ts +6 -0
- package/server/devices/{hmIPDevices/hmIpTaste.ts → taste.ts} +84 -72
- package/server/devices/wledDevice.ts +124 -124
- package/server/devices/zigbee/ZigbeeActuator.ts +113 -113
- package/server/devices/zigbee/zigbeeAquaraVibra.ts +171 -171
- package/server/devices/zigbee/zigbeeAquaraWater.ts +94 -94
- package/server/devices/zigbee/zigbeeBlitzShp.ts +77 -77
- package/server/devices/zigbee/zigbeeDevice.ts +115 -115
- package/server/devices/zigbee/zigbeeDeviceType.ts +13 -13
- package/server/devices/zigbee/zigbeeHeimanSmoke.ts +99 -99
- package/server/devices/zigbee/zigbeeIkeaSteckdose.ts +31 -31
- package/server/devices/zigbee/zigbeeIlluActuator.ts +37 -37
- package/server/devices/zigbee/zigbeeIlluDimmer.ts +165 -165
- package/server/devices/zigbee/zigbeeIlluLampe.ts +33 -33
- package/server/devices/zigbee/zigbeeIlluLedRGBCCT.ts +137 -137
- package/server/ioBroker/connection.ts +1655 -1655
- package/server/ioBroker/ioBroker.main.ts +99 -99
- package/server/ioBroker/socketIOAuthInfo.ts +5 -5
- package/server/ioBroker/socketIOConnectOptions.ts +6 -6
- package/server/ioBroker/socketIOLogging.ts +29 -29
- package/server/ioBroker/socketIOVisCommand.ts +11 -11
- package/server/services/HTTPSOptions.ts +14 -14
- package/server/services/Sonos/OwnSonosDevices.ts +9 -0
- package/server/services/Sonos/mp3-server.ts +75 -75
- package/server/services/Sonos/polly-service.ts +100 -100
- package/server/services/Sonos/sonos-service.ts +194 -199
- package/server/services/Telegram/telegram-Commands.ts +237 -215
- package/server/services/Telegram/telegram-service.ts +171 -171
- package/server/services/Telegram/telegramMessageCalback.ts +11 -11
- package/server/services/calendar/muell-tonne.ts +82 -83
- package/server/services/calendar/m/303/274ll-service.ts +147 -146
- package/server/services/dbo/persist.ts +125 -125
- package/server/services/https-service.ts +71 -71
- package/server/services/log-service.ts +69 -69
- package/server/services/news-service.ts +81 -81
- package/server/services/settings-service.ts +15 -15
- package/server/services/time-callback-service.ts +223 -223
- package/server/services/utils/ringstorage.ts +24 -24
- package/server/services/utils/utils.ts +52 -52
- package/server/services/weather/weather-alert.ts +7 -7
- package/server/services/weather/weather-current.ts +26 -26
- package/server/services/weather/weather-daily.ts +22 -22
- package/server/services/weather/weather-feelsLike.ts +6 -6
- package/server/services/weather/weather-hourly.ts +17 -17
- package/server/services/weather/weather-item.ts +6 -6
- package/server/services/weather/weather-minutes.ts +4 -4
- package/server/services/weather/weather-service.ts +277 -277
- package/server/services/weather/weather-temp.ts +8 -8
- package/tsconfig.json +58 -58
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import { HmIPDevice } from './hmIpDevice';
|
|
2
|
-
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
3
|
-
import { DeviceInfo } from '../DeviceInfo';
|
|
4
|
-
import { LogLevel } from '../../../models/logLevel';
|
|
5
|
-
import { ServerLogService } from '../../services/log-service';
|
|
6
|
-
import { TuerPosition } from './TuerPosition';
|
|
7
|
-
import { SonosService } from '../../services/Sonos/sonos-service';
|
|
8
|
-
import { TelegramService } from '../../services/Telegram/telegram-service';
|
|
9
|
-
import { Utils } from '../../services/utils/utils';
|
|
10
|
-
|
|
11
|
-
export class HmIpTuer extends HmIPDevice {
|
|
12
|
-
public position: TuerPosition = TuerPosition.geschlossen;
|
|
13
|
-
private _closedCallback: Array<(pValue: boolean) => void> = [];
|
|
14
|
-
private _offenCallback: Array<(pValue: boolean) => void> = [];
|
|
15
|
-
private _iOpen: NodeJS.Timeout | undefined;
|
|
16
|
-
private minutesOpen: number = 0;
|
|
17
|
-
|
|
18
|
-
public constructor(pInfo: DeviceInfo) {
|
|
19
|
-
super(pInfo, HmIpDeviceType.HmIpTuer);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public addOffenCallback(pCallback: (pValue: boolean) => void): void {
|
|
23
|
-
this._offenCallback.push(pCallback);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public addClosedCallback(pCallback: (pValue: boolean) => void): void {
|
|
27
|
-
this._closedCallback.push(pCallback);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
|
|
31
|
-
ServerLogService.writeLog(
|
|
32
|
-
LogLevel.DeepTrace,
|
|
33
|
-
`Tuer Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`,
|
|
34
|
-
);
|
|
35
|
-
super.update(idSplit, state, initial, true);
|
|
36
|
-
switch (idSplit[3]) {
|
|
37
|
-
case '1':
|
|
38
|
-
if (idSplit[4] === 'STATE') {
|
|
39
|
-
if (initial) {
|
|
40
|
-
this.position = TuerPosition.geschlossen;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
this.updatePosition(state.val as TuerPosition);
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public updatePosition(pValue: TuerPosition): void {
|
|
50
|
-
if (pValue === this.position) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
ServerLogService.writeLog(
|
|
55
|
-
LogLevel.Trace,
|
|
56
|
-
`Update Tür "${this.info.customName}"\nauf Position "${TuerPosition[pValue]}"`,
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
this.position = pValue;
|
|
60
|
-
for (const c1 of this._closedCallback) {
|
|
61
|
-
c1(pValue === 0);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
for (const c2 of this._offenCallback) {
|
|
65
|
-
c2(pValue === 1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (pValue === TuerPosition.geschlossen) {
|
|
69
|
-
if (this._iOpen !== undefined) {
|
|
70
|
-
clearInterval(this._iOpen);
|
|
71
|
-
|
|
72
|
-
let message = `Die Haustür ist nun nach ${this.minutesOpen} Minuten wieder zu!`;
|
|
73
|
-
if (this.minutesOpen === 0) {
|
|
74
|
-
message = 'Die Haustür ist wieder zu.';
|
|
75
|
-
}
|
|
76
|
-
// const message: string = `Die Tür mit dem Namen "${this.info.customName}" wurde nach ${this.minutesOpen} Minuten geschlossen!`;
|
|
77
|
-
ServerLogService.writeLog(LogLevel.Info, message);
|
|
78
|
-
|
|
79
|
-
TelegramService.inform(message);
|
|
80
|
-
this.minutesOpen = 0;
|
|
81
|
-
this._iOpen = undefined;
|
|
82
|
-
}
|
|
83
|
-
return;
|
|
84
|
-
} else if (this._iOpen === undefined) {
|
|
85
|
-
const message = `Die Haustür wurde geöffnet!`;
|
|
86
|
-
//const message: string = `Die Tür mit dem Namen "${this.info.customName}" wurde geöfnet!`
|
|
87
|
-
TelegramService.inform(message);
|
|
88
|
-
SonosService.speakOnAll(message, 40);
|
|
89
|
-
this._iOpen = Utils.guardedInterval(
|
|
90
|
-
() => {
|
|
91
|
-
this.minutesOpen++;
|
|
92
|
-
const message = `Tuer: "${this.info.customName}" seit ${this.minutesOpen} Minuten auf Position ${
|
|
93
|
-
TuerPosition[this.position]
|
|
94
|
-
}`;
|
|
95
|
-
switch (this.minutesOpen) {
|
|
96
|
-
case 2:
|
|
97
|
-
case 5:
|
|
98
|
-
case 10:
|
|
99
|
-
case 20:
|
|
100
|
-
case 45:
|
|
101
|
-
case 60:
|
|
102
|
-
ServerLogService.writeLog(LogLevel.Info, message);
|
|
103
|
-
TelegramService.inform(message);
|
|
104
|
-
break;
|
|
105
|
-
default:
|
|
106
|
-
ServerLogService.writeLog(LogLevel.Trace, message);
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
60000,
|
|
111
|
-
this,
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
1
|
+
import { HmIPDevice } from './hmIpDevice';
|
|
2
|
+
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
3
|
+
import { DeviceInfo } from '../DeviceInfo';
|
|
4
|
+
import { LogLevel } from '../../../models/logLevel';
|
|
5
|
+
import { ServerLogService } from '../../services/log-service';
|
|
6
|
+
import { TuerPosition } from './TuerPosition';
|
|
7
|
+
import { SonosService } from '../../services/Sonos/sonos-service';
|
|
8
|
+
import { TelegramService } from '../../services/Telegram/telegram-service';
|
|
9
|
+
import { Utils } from '../../services/utils/utils';
|
|
10
|
+
|
|
11
|
+
export class HmIpTuer extends HmIPDevice {
|
|
12
|
+
public position: TuerPosition = TuerPosition.geschlossen;
|
|
13
|
+
private _closedCallback: Array<(pValue: boolean) => void> = [];
|
|
14
|
+
private _offenCallback: Array<(pValue: boolean) => void> = [];
|
|
15
|
+
private _iOpen: NodeJS.Timeout | undefined;
|
|
16
|
+
private minutesOpen: number = 0;
|
|
17
|
+
|
|
18
|
+
public constructor(pInfo: DeviceInfo) {
|
|
19
|
+
super(pInfo, HmIpDeviceType.HmIpTuer);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public addOffenCallback(pCallback: (pValue: boolean) => void): void {
|
|
23
|
+
this._offenCallback.push(pCallback);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public addClosedCallback(pCallback: (pValue: boolean) => void): void {
|
|
27
|
+
this._closedCallback.push(pCallback);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
|
|
31
|
+
ServerLogService.writeLog(
|
|
32
|
+
LogLevel.DeepTrace,
|
|
33
|
+
`Tuer Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`,
|
|
34
|
+
);
|
|
35
|
+
super.update(idSplit, state, initial, true);
|
|
36
|
+
switch (idSplit[3]) {
|
|
37
|
+
case '1':
|
|
38
|
+
if (idSplit[4] === 'STATE') {
|
|
39
|
+
if (initial) {
|
|
40
|
+
this.position = TuerPosition.geschlossen;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.updatePosition(state.val as TuerPosition);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public updatePosition(pValue: TuerPosition): void {
|
|
50
|
+
if (pValue === this.position) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ServerLogService.writeLog(
|
|
55
|
+
LogLevel.Trace,
|
|
56
|
+
`Update Tür "${this.info.customName}"\nauf Position "${TuerPosition[pValue]}"`,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
this.position = pValue;
|
|
60
|
+
for (const c1 of this._closedCallback) {
|
|
61
|
+
c1(pValue === 0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
for (const c2 of this._offenCallback) {
|
|
65
|
+
c2(pValue === 1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (pValue === TuerPosition.geschlossen) {
|
|
69
|
+
if (this._iOpen !== undefined) {
|
|
70
|
+
clearInterval(this._iOpen);
|
|
71
|
+
|
|
72
|
+
let message = `Die Haustür ist nun nach ${this.minutesOpen} Minuten wieder zu!`;
|
|
73
|
+
if (this.minutesOpen === 0) {
|
|
74
|
+
message = 'Die Haustür ist wieder zu.';
|
|
75
|
+
}
|
|
76
|
+
// const message: string = `Die Tür mit dem Namen "${this.info.customName}" wurde nach ${this.minutesOpen} Minuten geschlossen!`;
|
|
77
|
+
ServerLogService.writeLog(LogLevel.Info, message);
|
|
78
|
+
|
|
79
|
+
TelegramService.inform(message);
|
|
80
|
+
this.minutesOpen = 0;
|
|
81
|
+
this._iOpen = undefined;
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
} else if (this._iOpen === undefined) {
|
|
85
|
+
const message = `Die Haustür wurde geöffnet!`;
|
|
86
|
+
//const message: string = `Die Tür mit dem Namen "${this.info.customName}" wurde geöfnet!`
|
|
87
|
+
TelegramService.inform(message);
|
|
88
|
+
SonosService.speakOnAll(message, 40);
|
|
89
|
+
this._iOpen = Utils.guardedInterval(
|
|
90
|
+
() => {
|
|
91
|
+
this.minutesOpen++;
|
|
92
|
+
const message = `Tuer: "${this.info.customName}" seit ${this.minutesOpen} Minuten auf Position ${
|
|
93
|
+
TuerPosition[this.position]
|
|
94
|
+
}`;
|
|
95
|
+
switch (this.minutesOpen) {
|
|
96
|
+
case 2:
|
|
97
|
+
case 5:
|
|
98
|
+
case 10:
|
|
99
|
+
case 20:
|
|
100
|
+
case 45:
|
|
101
|
+
case 60:
|
|
102
|
+
ServerLogService.writeLog(LogLevel.Info, message);
|
|
103
|
+
TelegramService.inform(message);
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
ServerLogService.writeLog(LogLevel.Trace, message);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
60000,
|
|
111
|
+
this,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { HmIPDevice } from './hmIpDevice';
|
|
2
|
-
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
3
|
-
import { DeviceInfo } from '../DeviceInfo';
|
|
4
|
-
import {
|
|
5
|
-
import { LogLevel } from '../../../models/logLevel';
|
|
6
|
-
import { ServerLogService } from '../../services/log-service';
|
|
7
|
-
|
|
8
|
-
export class HmIpWippe extends HmIPDevice {
|
|
9
|
-
public tasten: {
|
|
10
|
-
Unten:
|
|
11
|
-
Oben:
|
|
12
|
-
} = {
|
|
13
|
-
Unten: new
|
|
14
|
-
Oben: new
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
public constructor(pInfo: DeviceInfo) {
|
|
18
|
-
super(pInfo, HmIpDeviceType.HmIpWippe);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
|
|
22
|
-
ServerLogService.writeLog(LogLevel.Trace, `Wippe Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`);
|
|
23
|
-
super.update(idSplit, state, initial, true);
|
|
24
|
-
let cTaste:
|
|
25
|
-
switch (idSplit[3]) {
|
|
26
|
-
case '1':
|
|
27
|
-
cTaste = this.tasten.Unten;
|
|
28
|
-
break;
|
|
29
|
-
case '2':
|
|
30
|
-
cTaste = this.tasten.Oben;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (cTaste === undefined) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
switch (idSplit[4]) {
|
|
39
|
-
case 'PRESS_SHORT':
|
|
40
|
-
if (!initial) {
|
|
41
|
-
// Tasten beim Starten ignorieren
|
|
42
|
-
ServerLogService.writeLog(LogLevel.Debug, `Tasten Update initial für "${this.info.customName}" ignoriert`);
|
|
43
|
-
cTaste.updateShort(state.val as boolean);
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
case 'PRESS_LONG':
|
|
47
|
-
if (!initial) {
|
|
48
|
-
// Tasten beim Starten ignorieren
|
|
49
|
-
ServerLogService.writeLog(LogLevel.Debug, `Tasten Update initial für "${this.info.customName}" ignoriert`);
|
|
50
|
-
cTaste.updateLong(state.val as boolean);
|
|
51
|
-
}
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
import { HmIPDevice } from './hmIpDevice';
|
|
2
|
+
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
3
|
+
import { DeviceInfo } from '../DeviceInfo';
|
|
4
|
+
import { Taste } from '../taste';
|
|
5
|
+
import { LogLevel } from '../../../models/logLevel';
|
|
6
|
+
import { ServerLogService } from '../../services/log-service';
|
|
7
|
+
|
|
8
|
+
export class HmIpWippe extends HmIPDevice {
|
|
9
|
+
public tasten: {
|
|
10
|
+
Unten: Taste;
|
|
11
|
+
Oben: Taste;
|
|
12
|
+
} = {
|
|
13
|
+
Unten: new Taste(1),
|
|
14
|
+
Oben: new Taste(2),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
public constructor(pInfo: DeviceInfo) {
|
|
18
|
+
super(pInfo, HmIpDeviceType.HmIpWippe);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
|
|
22
|
+
ServerLogService.writeLog(LogLevel.Trace, `Wippe Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`);
|
|
23
|
+
super.update(idSplit, state, initial, true);
|
|
24
|
+
let cTaste: Taste | undefined = undefined;
|
|
25
|
+
switch (idSplit[3]) {
|
|
26
|
+
case '1':
|
|
27
|
+
cTaste = this.tasten.Unten;
|
|
28
|
+
break;
|
|
29
|
+
case '2':
|
|
30
|
+
cTaste = this.tasten.Oben;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (cTaste === undefined) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
switch (idSplit[4]) {
|
|
39
|
+
case 'PRESS_SHORT':
|
|
40
|
+
if (!initial) {
|
|
41
|
+
// Tasten beim Starten ignorieren
|
|
42
|
+
ServerLogService.writeLog(LogLevel.Debug, `Tasten Update initial für "${this.info.customName}" ignoriert`);
|
|
43
|
+
cTaste.updateShort(state.val as boolean);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
case 'PRESS_LONG':
|
|
47
|
+
if (!initial) {
|
|
48
|
+
// Tasten beim Starten ignorieren
|
|
49
|
+
ServerLogService.writeLog(LogLevel.Debug, `Tasten Update initial für "${this.info.customName}" ignoriert`);
|
|
50
|
+
cTaste.updateLong(state.val as boolean);
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface IDeviceUpdater {
|
|
2
|
-
updateState(id: string, state: ioBroker.State, initial?: boolean): void;
|
|
3
|
-
updateObject(pId: string, pObj: ioBroker.Object): void;
|
|
4
|
-
}
|
|
1
|
+
export interface IDeviceUpdater {
|
|
2
|
+
updateState(id: string, state: ioBroker.State, initial?: boolean): void;
|
|
3
|
+
updateObject(pId: string, pObj: ioBroker.Object): void;
|
|
4
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { DeviceInfo } from './DeviceInfo';
|
|
2
|
-
import { IOBrokerConnection } from '../ioBroker/connection';
|
|
3
|
-
|
|
4
|
-
export abstract class ioBrokerBaseDevice {
|
|
5
|
-
private _ioConnection?: IOBrokerConnection;
|
|
6
|
-
|
|
7
|
-
protected constructor(private _info: DeviceInfo) {}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Getter info
|
|
11
|
-
* @return {TradFriInfo}
|
|
12
|
-
*/
|
|
13
|
-
public get info(): DeviceInfo {
|
|
14
|
-
return this._info;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Setter info
|
|
19
|
-
* @param {TradFriInfo} value
|
|
20
|
-
*/
|
|
21
|
-
public set info(value: DeviceInfo) {
|
|
22
|
-
this._info = value;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Getter ioConn
|
|
27
|
-
* @return {IOBrokerConnection}
|
|
28
|
-
*/
|
|
29
|
-
public get ioConn(): IOBrokerConnection | undefined {
|
|
30
|
-
return this._ioConnection;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Setter ioConn
|
|
35
|
-
* @param {IOBrokerConnection} value
|
|
36
|
-
*/
|
|
37
|
-
public set ioConn(value: IOBrokerConnection | undefined) {
|
|
38
|
-
this._ioConnection = value;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
protected abstract addToCorrectRoom(): void;
|
|
42
|
-
|
|
43
|
-
protected abstract update(idSplit: string[], state: ioBroker.State, initial: boolean, pOverride: boolean): void;
|
|
44
|
-
}
|
|
1
|
+
import { DeviceInfo } from './DeviceInfo';
|
|
2
|
+
import { IOBrokerConnection } from '../ioBroker/connection';
|
|
3
|
+
|
|
4
|
+
export abstract class ioBrokerBaseDevice {
|
|
5
|
+
private _ioConnection?: IOBrokerConnection;
|
|
6
|
+
|
|
7
|
+
protected constructor(private _info: DeviceInfo) {}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Getter info
|
|
11
|
+
* @return {TradFriInfo}
|
|
12
|
+
*/
|
|
13
|
+
public get info(): DeviceInfo {
|
|
14
|
+
return this._info;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Setter info
|
|
19
|
+
* @param {TradFriInfo} value
|
|
20
|
+
*/
|
|
21
|
+
public set info(value: DeviceInfo) {
|
|
22
|
+
this._info = value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Getter ioConn
|
|
27
|
+
* @return {IOBrokerConnection}
|
|
28
|
+
*/
|
|
29
|
+
public get ioConn(): IOBrokerConnection | undefined {
|
|
30
|
+
return this._ioConnection;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Setter ioConn
|
|
35
|
+
* @param {IOBrokerConnection} value
|
|
36
|
+
*/
|
|
37
|
+
public set ioConn(value: IOBrokerConnection | undefined) {
|
|
38
|
+
this._ioConnection = value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
protected abstract addToCorrectRoom(): void;
|
|
42
|
+
|
|
43
|
+
protected abstract update(idSplit: string[], state: ioBroker.State, initial: boolean, pOverride: boolean): void;
|
|
44
|
+
}
|
|
@@ -1,72 +1,84 @@
|
|
|
1
|
-
import { Utils } from '
|
|
2
|
-
|
|
3
|
-
export class
|
|
4
|
-
public shortPressed: boolean = false;
|
|
5
|
-
public longPressed: boolean = false;
|
|
6
|
-
private _shortCallback: Array<(pValue: boolean) => void> = [];
|
|
7
|
-
private _longCallback: Array<(pValue: boolean) => void> = [];
|
|
8
|
-
private _shortResetTimeout: null | NodeJS.Timeout = null;
|
|
9
|
-
private _longResetTimeout: null | NodeJS.Timeout = null;
|
|
10
|
-
|
|
11
|
-
public constructor(public updateIndex: number) {}
|
|
12
|
-
|
|
13
|
-
public addShortCallback(pCallback: (pValue: boolean) => void): void {
|
|
14
|
-
this._shortCallback.push(pCallback);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public addLongCallback(pCallback: (pValue: boolean) => void): void {
|
|
18
|
-
this._longCallback.push(pCallback);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
}
|
|
1
|
+
import { Utils } from '../services/utils/utils';
|
|
2
|
+
|
|
3
|
+
export class Taste {
|
|
4
|
+
public shortPressed: boolean = false;
|
|
5
|
+
public longPressed: boolean = false;
|
|
6
|
+
private _shortCallback: Array<{cb: (pValue: boolean) => void, description: string}> = [];
|
|
7
|
+
private _longCallback: Array<{cb: (pValue: boolean) => void, description: string}> = [];
|
|
8
|
+
private _shortResetTimeout: null | NodeJS.Timeout = null;
|
|
9
|
+
private _longResetTimeout: null | NodeJS.Timeout = null;
|
|
10
|
+
|
|
11
|
+
public constructor(public updateIndex: number) {}
|
|
12
|
+
|
|
13
|
+
public addShortCallback(pCallback: (pValue: boolean) => void, description: string = "Not described") : void {
|
|
14
|
+
this._shortCallback.push({cb: pCallback, description: description});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public addLongCallback(pCallback: (pValue: boolean) => void, description: string = "Not described"): void {
|
|
18
|
+
this._longCallback.push({cb: pCallback, description: description});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
public getDescription(): string {
|
|
23
|
+
const description: string[] = [];
|
|
24
|
+
for (const c of this._shortCallback) {
|
|
25
|
+
description.push(`Short Press: "${c.description}"`)
|
|
26
|
+
}
|
|
27
|
+
for (const c of this._longCallback) {
|
|
28
|
+
description.push(`Long Press: "${c.description}"`)
|
|
29
|
+
}
|
|
30
|
+
return description.join('\n');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public updateShort(pValue: boolean): void {
|
|
34
|
+
if (pValue === this.shortPressed) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
this.shortPressed = pValue;
|
|
39
|
+
|
|
40
|
+
for (const c of this._shortCallback) {
|
|
41
|
+
c.cb(pValue);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!pValue) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this._shortResetTimeout !== null && clearTimeout(this._shortResetTimeout);
|
|
49
|
+
|
|
50
|
+
this._shortResetTimeout = Utils.guardedTimeout(
|
|
51
|
+
() => {
|
|
52
|
+
this.updateShort(false);
|
|
53
|
+
},
|
|
54
|
+
1000,
|
|
55
|
+
this,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public updateLong(pValue: boolean): void {
|
|
60
|
+
if (pValue === this.longPressed) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.longPressed = pValue;
|
|
65
|
+
|
|
66
|
+
for (const c of this._longCallback) {
|
|
67
|
+
c.cb(pValue);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!pValue) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this._longResetTimeout !== null && clearTimeout(this._longResetTimeout);
|
|
75
|
+
|
|
76
|
+
this._longResetTimeout = Utils.guardedTimeout(
|
|
77
|
+
() => {
|
|
78
|
+
this.updateLong(false);
|
|
79
|
+
},
|
|
80
|
+
5000,
|
|
81
|
+
this,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|