hoffmation-base 0.0.1
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 -0
- package/.prettierrc.js +9 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/index.js +1 -0
- package/models/connectionCallbacks.ts +13 -0
- package/models/daytime.ts +3 -0
- package/models/deviceConfig.ts +8 -0
- package/models/dimmerSettings.ts +5 -0
- package/models/lampSettings.ts +5 -0
- package/models/ledSettings.ts +19 -0
- package/models/logLevel.ts +9 -0
- package/models/persistence/BasicRoomInfo.ts +3 -0
- package/models/persistence/DailyMovementCount.ts +3 -0
- package/models/persistence/RoomDetailInfo.ts +4 -0
- package/models/persistence/temperaturDataPoint.ts +12 -0
- package/models/persistence/todaysCount.ts +3 -0
- package/models/rooms/RoomBase.ts +357 -0
- package/models/rooms/RoomSettings/RoomSettings.ts +159 -0
- package/models/rooms/RoomSettings/hmIPRoomSettings.ts +53 -0
- package/models/rooms/RoomSettings/iRoomDefaultSettings.ts +17 -0
- package/models/rooms/RoomSettings/readme.md +18 -0
- package/models/rooms/RoomSettings/zigbeeRoomSettings.ts +51 -0
- package/models/rooms/iRoomImportEnforcer.ts +3 -0
- package/models/rooms/readme.md +11 -0
- package/models/temperaturSettings.ts +22 -0
- package/models/timeCallback.ts +90 -0
- package/package.json +57 -0
- package/server/config/config-readme.md +19 -0
- package/server/config/iConfig.ts +53 -0
- package/server/devices/DeviceInfo.ts +66 -0
- package/server/devices/Griffe.ts +31 -0
- package/server/devices/Heizgruppen.ts +91 -0
- package/server/devices/Rollos.ts +48 -0
- package/server/devices/deviceUpdater.ts +72 -0
- package/server/devices/devices.ts +189 -0
- package/server/devices/groups/fensterGroup.ts +175 -0
- package/server/devices/groups/heatGroup.ts +32 -0
- package/server/devices/groups/lampenGroup.ts +88 -0
- package/server/devices/groups/praesenzGroup.ts +182 -0
- package/server/devices/groups/smokeGroup.ts +16 -0
- package/server/devices/groups/sonosGroup.ts +33 -0
- package/server/devices/groups/tasterGroup.ts +48 -0
- package/server/devices/groups/waterGroup.ts +16 -0
- package/server/devices/hmIPDevices/Fenster.ts +114 -0
- package/server/devices/hmIPDevices/FensterPosition.ts +5 -0
- package/server/devices/hmIPDevices/TuerPosition.ts +4 -0
- package/server/devices/hmIPDevices/hmIpBewegung.ts +126 -0
- package/server/devices/hmIPDevices/hmIpDevice.ts +90 -0
- package/server/devices/hmIPDevices/hmIpDeviceType.ts +14 -0
- package/server/devices/hmIPDevices/hmIpGriff.ts +143 -0
- package/server/devices/hmIPDevices/hmIpHeizgruppe.ts +172 -0
- package/server/devices/hmIPDevices/hmIpHeizung.ts +69 -0
- package/server/devices/hmIPDevices/hmIpLampe.ts +119 -0
- package/server/devices/hmIPDevices/hmIpPraezenz.ts +99 -0
- package/server/devices/hmIPDevices/hmIpRoll.ts +133 -0
- package/server/devices/hmIPDevices/hmIpTaste.ts +72 -0
- package/server/devices/hmIPDevices/hmIpTaster.ts +73 -0
- package/server/devices/hmIPDevices/hmIpTherm.ts +19 -0
- package/server/devices/hmIPDevices/hmIpTuer.ts +115 -0
- package/server/devices/hmIPDevices/hmIpWippe.ts +55 -0
- package/server/devices/iDeviceUpdater.ts +4 -0
- package/server/devices/iIoBrokerDevice.ts +44 -0
- package/server/devices/wledDevice.ts +124 -0
- package/server/devices/zigbee/ZigbeeActuator.ts +113 -0
- package/server/devices/zigbee/zigbeeAquaraVibra.ts +171 -0
- package/server/devices/zigbee/zigbeeAquaraWater.ts +94 -0
- package/server/devices/zigbee/zigbeeBlitzShp.ts +77 -0
- package/server/devices/zigbee/zigbeeDevice.ts +115 -0
- package/server/devices/zigbee/zigbeeDeviceType.ts +13 -0
- package/server/devices/zigbee/zigbeeHeimanSmoke.ts +99 -0
- package/server/devices/zigbee/zigbeeIkeaSteckdose.ts +31 -0
- package/server/devices/zigbee/zigbeeIlluActuator.ts +37 -0
- package/server/devices/zigbee/zigbeeIlluDimmer.ts +165 -0
- package/server/devices/zigbee/zigbeeIlluLampe.ts +33 -0
- package/server/devices/zigbee/zigbeeIlluLedRGBCCT.ts +137 -0
- package/server/ioBroker/connection.ts +1655 -0
- package/server/ioBroker/ioBroker.main.ts +99 -0
- package/server/ioBroker/socketIOAuthInfo.ts +5 -0
- package/server/ioBroker/socketIOConnectOptions.ts +6 -0
- package/server/ioBroker/socketIOLogging.ts +29 -0
- package/server/ioBroker/socketIOVisCommand.ts +11 -0
- package/server/services/HTTPSOptions.ts +14 -0
- package/server/services/Sonos/mp3-server.ts +75 -0
- package/server/services/Sonos/polly-service.ts +100 -0
- package/server/services/Sonos/sonos-service.ts +199 -0
- package/server/services/Telegram/telegram-Commands.ts +215 -0
- package/server/services/Telegram/telegram-service.ts +171 -0
- package/server/services/Telegram/telegramMessageCalback.ts +11 -0
- package/server/services/calendar/m/303/274ll-service.ts +224 -0
- package/server/services/dbo/persist.ts +125 -0
- package/server/services/https-service.ts +71 -0
- package/server/services/log-service.ts +69 -0
- package/server/services/news-service.ts +81 -0
- package/server/services/settings-service.ts +23 -0
- package/server/services/time-callback-service.ts +223 -0
- package/server/services/utils/ringstorage.ts +24 -0
- package/server/services/utils/utils.ts +52 -0
- package/server/services/weather/weather-alert.ts +7 -0
- package/server/services/weather/weather-current.ts +26 -0
- package/server/services/weather/weather-daily.ts +22 -0
- package/server/services/weather/weather-feelsLike.ts +6 -0
- package/server/services/weather/weather-hourly.ts +17 -0
- package/server/services/weather/weather-item.ts +6 -0
- package/server/services/weather/weather-minutes.ts +4 -0
- package/server/services/weather/weather-service.ts +277 -0
- package/server/services/weather/weather-temp.ts +8 -0
- package/tsconfig.json +59 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Fenster } from './Fenster';
|
|
2
|
+
import { FensterPosition } from './FensterPosition';
|
|
3
|
+
import { HmIPDevice } from './hmIpDevice';
|
|
4
|
+
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
5
|
+
import { DeviceInfo } from '../DeviceInfo';
|
|
6
|
+
import { LogLevel } from '/models/logLevel';
|
|
7
|
+
import { ServerLogService } from '/server/services/log-service';
|
|
8
|
+
import { Utils } from '/server/services/utils/utils';
|
|
9
|
+
|
|
10
|
+
export class HmIpRoll extends HmIPDevice {
|
|
11
|
+
public get currentLevel(): number {
|
|
12
|
+
if (this._setLevel !== -1 && this._currentLevel !== this._setLevel) {
|
|
13
|
+
return this._setLevel;
|
|
14
|
+
}
|
|
15
|
+
return this._currentLevel;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public set currentLevel(value: number) {
|
|
19
|
+
if (value !== this._setLevel && Utils.nowMS() - this._setLevelTime < 60 * 10000) {
|
|
20
|
+
value = this._setLevel;
|
|
21
|
+
}
|
|
22
|
+
if (value !== this._currentLevel && this._fenster) {
|
|
23
|
+
Utils.guardedNewThread(() => {
|
|
24
|
+
this._fenster?.rolloPositionChange(value);
|
|
25
|
+
}, this);
|
|
26
|
+
}
|
|
27
|
+
this._currentLevel = value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public get desiredFensterLevel(): number {
|
|
31
|
+
if (this._fenster === undefined) {
|
|
32
|
+
return -1;
|
|
33
|
+
}
|
|
34
|
+
return this._fenster.desiredPosition;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private _currentLevel: number = -1;
|
|
38
|
+
private _setLevelSwitchID: string;
|
|
39
|
+
private _fenster?: Fenster;
|
|
40
|
+
private _firstCommandRecieved: boolean = false;
|
|
41
|
+
private _setLevel: number = -1;
|
|
42
|
+
private _setLevelTime: number = -1;
|
|
43
|
+
|
|
44
|
+
public set Fenster(value: Fenster) {
|
|
45
|
+
this._fenster = value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public constructor(pInfo: DeviceInfo) {
|
|
49
|
+
super(pInfo, HmIpDeviceType.HmIpRoll);
|
|
50
|
+
this._setLevelSwitchID = `${this.info.fullID}.4.LEVEL`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
|
|
54
|
+
ServerLogService.writeLog(
|
|
55
|
+
LogLevel.DeepTrace,
|
|
56
|
+
`Rollo Update für "${this.info.customName}": ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`,
|
|
57
|
+
);
|
|
58
|
+
super.update(idSplit, state, initial, true);
|
|
59
|
+
switch (idSplit[3]) {
|
|
60
|
+
case '3':
|
|
61
|
+
if (idSplit[4] === 'LEVEL') {
|
|
62
|
+
this.currentLevel = state.val as number;
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public setLevel(pPosition: number, initial: boolean = false, skipOpenWarning: boolean = false): void {
|
|
69
|
+
if (!this._firstCommandRecieved && !initial) {
|
|
70
|
+
this._firstCommandRecieved = true;
|
|
71
|
+
}
|
|
72
|
+
if (this._firstCommandRecieved && initial) {
|
|
73
|
+
ServerLogService.writeLog(
|
|
74
|
+
LogLevel.Debug,
|
|
75
|
+
`Skipped initial Rollo "${this.info.customName}" to ${pPosition} as we recieved a command already`,
|
|
76
|
+
);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.currentLevel === pPosition) {
|
|
80
|
+
ServerLogService.writeLog(
|
|
81
|
+
LogLevel.Debug,
|
|
82
|
+
`Skip Rollo command for "${this.info.customName}" to Position ${pPosition} as this is the current one`,
|
|
83
|
+
);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (this._setLevelSwitchID === '') {
|
|
87
|
+
console.error(`Keine Switch ID für "${this.info.customName}" bekannt.`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!this.ioConn) {
|
|
92
|
+
console.error(`Keine Connection für "${this.info.customName}" bekannt.`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (this._fenster !== undefined) {
|
|
97
|
+
if (this._fenster.griffeInPosition(FensterPosition.offen) > 0 && pPosition < 100) {
|
|
98
|
+
if (!skipOpenWarning) {
|
|
99
|
+
ServerLogService.writeLog(
|
|
100
|
+
LogLevel.Alert,
|
|
101
|
+
`Fahre Rollo "${this.info.customName}" nicht runter, weil das Fenster offen ist!`,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (this._fenster.griffeInPosition(FensterPosition.kipp) > 0 && pPosition < 50) {
|
|
107
|
+
pPosition = 50;
|
|
108
|
+
if (!skipOpenWarning) {
|
|
109
|
+
ServerLogService.writeLog(
|
|
110
|
+
LogLevel.Alert,
|
|
111
|
+
`Fahre Rollo "${this.info.customName}" nicht runter, weil das Fenster auf Kipp ist!`,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this._setLevel = pPosition;
|
|
118
|
+
ServerLogService.writeLog(LogLevel.Debug, `Fahre Rollo "${this.info.customName}" auf Position ${pPosition}`);
|
|
119
|
+
this.ioConn.setState(this._setLevelSwitchID, pPosition);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public down(initial: boolean = false): void {
|
|
123
|
+
this.setLevel(0, initial);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public middle(): void {
|
|
127
|
+
this.setLevel(50);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public up(initial: boolean = false): void {
|
|
131
|
+
this.setLevel(100, initial);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Utils } from '/server/services/utils/utils';
|
|
2
|
+
|
|
3
|
+
export class HmIPTaste {
|
|
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
|
+
public updateShort(pValue: boolean): void {
|
|
22
|
+
if (pValue === this.shortPressed) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.shortPressed = pValue;
|
|
27
|
+
|
|
28
|
+
for (const c of this._shortCallback) {
|
|
29
|
+
c(pValue);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!pValue) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this._shortResetTimeout !== null && clearTimeout(this._shortResetTimeout);
|
|
37
|
+
|
|
38
|
+
this._shortResetTimeout = Utils.guardedTimeout(
|
|
39
|
+
() => {
|
|
40
|
+
this.updateShort(false);
|
|
41
|
+
},
|
|
42
|
+
1000,
|
|
43
|
+
this,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public updateLong(pValue: boolean): void {
|
|
48
|
+
if (pValue === this.longPressed) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.longPressed = pValue;
|
|
53
|
+
|
|
54
|
+
for (const c of this._longCallback) {
|
|
55
|
+
c(pValue);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!pValue) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this._longResetTimeout !== null && clearTimeout(this._longResetTimeout);
|
|
63
|
+
|
|
64
|
+
this._longResetTimeout = Utils.guardedTimeout(
|
|
65
|
+
() => {
|
|
66
|
+
this.updateLong(false);
|
|
67
|
+
},
|
|
68
|
+
5000,
|
|
69
|
+
this,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { HmIPDevice } from './hmIpDevice';
|
|
2
|
+
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
3
|
+
import { DeviceInfo } from '../DeviceInfo';
|
|
4
|
+
import { HmIPTaste } from './hmIpTaste';
|
|
5
|
+
import { LogLevel } from '/models/logLevel';
|
|
6
|
+
import { ServerLogService } from '/server/services/log-service';
|
|
7
|
+
|
|
8
|
+
export class HmIpTaster extends HmIPDevice {
|
|
9
|
+
public tasten: {
|
|
10
|
+
ObenLinks: HmIPTaste;
|
|
11
|
+
ObenRechts: HmIPTaste;
|
|
12
|
+
MitteLinks: HmIPTaste;
|
|
13
|
+
MitteRechts: HmIPTaste;
|
|
14
|
+
UntenLinks: HmIPTaste;
|
|
15
|
+
UntenRechts: HmIPTaste;
|
|
16
|
+
} = {
|
|
17
|
+
ObenLinks: new HmIPTaste(1),
|
|
18
|
+
ObenRechts: new HmIPTaste(2),
|
|
19
|
+
MitteLinks: new HmIPTaste(3),
|
|
20
|
+
MitteRechts: new HmIPTaste(4),
|
|
21
|
+
UntenLinks: new HmIPTaste(5),
|
|
22
|
+
UntenRechts: new HmIPTaste(6),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
public constructor(pInfo: DeviceInfo) {
|
|
26
|
+
super(pInfo, HmIpDeviceType.HmIpTaster);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
|
|
30
|
+
ServerLogService.writeLog(LogLevel.Trace, `Taster Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`);
|
|
31
|
+
super.update(idSplit, state, initial, true);
|
|
32
|
+
let cTaste: HmIPTaste | undefined = undefined;
|
|
33
|
+
switch (idSplit[3]) {
|
|
34
|
+
case '1':
|
|
35
|
+
cTaste = this.tasten.ObenLinks;
|
|
36
|
+
break;
|
|
37
|
+
case '2':
|
|
38
|
+
cTaste = this.tasten.ObenRechts;
|
|
39
|
+
break;
|
|
40
|
+
case '3':
|
|
41
|
+
cTaste = this.tasten.MitteLinks;
|
|
42
|
+
break;
|
|
43
|
+
case '4':
|
|
44
|
+
cTaste = this.tasten.MitteRechts;
|
|
45
|
+
break;
|
|
46
|
+
case '5':
|
|
47
|
+
cTaste = this.tasten.UntenLinks;
|
|
48
|
+
break;
|
|
49
|
+
case '6':
|
|
50
|
+
cTaste = this.tasten.UntenRechts;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (cTaste === undefined) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
switch (idSplit[4]) {
|
|
59
|
+
case 'PRESS_SHORT':
|
|
60
|
+
if (!initial) {
|
|
61
|
+
// Tasten beim Starten ignorieren
|
|
62
|
+
cTaste.updateShort(state.val as boolean);
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
case 'PRESS_LONG':
|
|
66
|
+
if (!initial) {
|
|
67
|
+
// Tasten beim Starten ignorieren
|
|
68
|
+
cTaste.updateLong(state.val as boolean);
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 '/server/services/log-service';
|
|
6
|
+
|
|
7
|
+
export class HmIpTherm extends HmIPDevice {
|
|
8
|
+
public constructor(pInfo: DeviceInfo) {
|
|
9
|
+
super(pInfo, HmIpDeviceType.HmIpTherm);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
|
|
13
|
+
ServerLogService.writeLog(
|
|
14
|
+
LogLevel.Trace,
|
|
15
|
+
`Thermostat "${this.info.customName}" Update: ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`,
|
|
16
|
+
);
|
|
17
|
+
super.update(idSplit, state, initial, true);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +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 '/server/services/log-service';
|
|
6
|
+
import { TuerPosition } from './TuerPosition';
|
|
7
|
+
import { SonosService } from '/server/services/Sonos/sonos-service';
|
|
8
|
+
import { TelegramService } from '/server/services/Telegram/telegram-service';
|
|
9
|
+
import { Utils } from '/server/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
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { HmIPDevice } from './hmIpDevice';
|
|
2
|
+
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
3
|
+
import { DeviceInfo } from '../DeviceInfo';
|
|
4
|
+
import { HmIPTaste } from './hmIpTaste';
|
|
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: HmIPTaste;
|
|
11
|
+
Oben: HmIPTaste;
|
|
12
|
+
} = {
|
|
13
|
+
Unten: new HmIPTaste(1),
|
|
14
|
+
Oben: new HmIPTaste(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: HmIPTaste | 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
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { IOBrokerConnection } from '../ioBroker/connection';
|
|
2
|
+
import { DeviceInfo } from './DeviceInfo';
|
|
3
|
+
import { LogLevel } from '/models/logLevel';
|
|
4
|
+
import { ServerLogService } from '/server/services/log-service';
|
|
5
|
+
|
|
6
|
+
export class WledDevice {
|
|
7
|
+
public on: boolean = false;
|
|
8
|
+
public brightness: number = -1;
|
|
9
|
+
public linkQuality: number = 0;
|
|
10
|
+
public battery: number = -1;
|
|
11
|
+
public voltage: string = '';
|
|
12
|
+
private _info: DeviceInfo;
|
|
13
|
+
private _ioConnection?: IOBrokerConnection;
|
|
14
|
+
private _onID: string;
|
|
15
|
+
private _brightnessID: string;
|
|
16
|
+
|
|
17
|
+
public constructor(pInfo: DeviceInfo) {
|
|
18
|
+
this._info = pInfo;
|
|
19
|
+
this.addToCorrectRoom();
|
|
20
|
+
this._onID = `${this.info.fullID}.on`;
|
|
21
|
+
this._brightnessID = `${this.info.fullID}.bri`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Getter info
|
|
26
|
+
* @return {DeviceInfo}
|
|
27
|
+
*/
|
|
28
|
+
public get info(): DeviceInfo {
|
|
29
|
+
return this._info;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Setter info
|
|
34
|
+
* @param {DeviceInfo} value
|
|
35
|
+
*/
|
|
36
|
+
public set info(value: DeviceInfo) {
|
|
37
|
+
this._info = value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Getter ioConn
|
|
42
|
+
* @return {IOBrokerConnection}
|
|
43
|
+
*/
|
|
44
|
+
public get ioConn(): IOBrokerConnection | undefined {
|
|
45
|
+
return this._ioConnection;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Setter ioConn
|
|
50
|
+
* @param {IOBrokerConnection} value
|
|
51
|
+
*/
|
|
52
|
+
public set ioConn(value: IOBrokerConnection | undefined) {
|
|
53
|
+
this._ioConnection = value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private addToCorrectRoom(): void {
|
|
57
|
+
ServerLogService.writeLog(LogLevel.DeepTrace, `Neues Zigbee Gerät für ${this._info.room}`);
|
|
58
|
+
switch (this._info.room) {
|
|
59
|
+
case 'Wohnz':
|
|
60
|
+
// room1OGWohn.addWLED(this._info);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
console.warn(`${this._info.room} ist noch kein bekannter Raum für WLED Geräte`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false, pOverride: boolean = false): void {
|
|
68
|
+
ServerLogService.writeLog(
|
|
69
|
+
LogLevel.DeepTrace,
|
|
70
|
+
`Wled:Update für "${this.info.customName}": ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`,
|
|
71
|
+
);
|
|
72
|
+
if (!pOverride) {
|
|
73
|
+
ServerLogService.writeLog(
|
|
74
|
+
LogLevel.Warn,
|
|
75
|
+
`Keine Update Überschreibung für "${this.info.customName}":\n\tID: ${idSplit.join(
|
|
76
|
+
'.',
|
|
77
|
+
)}\n\tData: ${JSON.stringify(state)}`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
switch (idSplit[3]) {
|
|
82
|
+
case 'on':
|
|
83
|
+
this.on = state.val as boolean;
|
|
84
|
+
break;
|
|
85
|
+
case 'bri':
|
|
86
|
+
this.brightness = state.val as number;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public setLight(pValue: boolean, brightness: number = -1): void {
|
|
92
|
+
if (this._onID === '') {
|
|
93
|
+
ServerLogService.writeLog(LogLevel.Error, `Keine On ID für "${this.info.customName}" bekannt.`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!this.ioConn) {
|
|
98
|
+
ServerLogService.writeLog(LogLevel.Error, `Keine Connection für "${this.info.customName}" bekannt.`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (pValue && brightness === -1 && this.brightness < 10) {
|
|
103
|
+
brightness = 10;
|
|
104
|
+
}
|
|
105
|
+
ServerLogService.writeLog(
|
|
106
|
+
LogLevel.Debug,
|
|
107
|
+
`WLED Schalten: "${this.info.customName}" An: ${pValue}\tHelligkeit: ${brightness}%`,
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
this.ioConn.setState(this._onID, pValue, (err) => {
|
|
111
|
+
if (err) {
|
|
112
|
+
ServerLogService.writeLog(LogLevel.Error, `WLED schalten ergab Fehler: ${err}`);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (brightness > -1) {
|
|
117
|
+
this.ioConn.setState(this._brightnessID, brightness, (err) => {
|
|
118
|
+
if (err) {
|
|
119
|
+
ServerLogService.writeLog(LogLevel.Error, `Dimmer Helligkeit schalten ergab Fehler: ${err}`);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|