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,90 +1,90 @@
|
|
|
1
|
-
import { LogLevel } from '../../../models/logLevel';
|
|
2
|
-
import { DeviceInfo } from '../DeviceInfo';
|
|
3
|
-
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
4
|
-
import { HmIpAddDeviceItem, HmIpRoomSettings } from '../../../models/rooms/RoomSettings/hmIPRoomSettings';
|
|
5
|
-
import { ServerLogService } from '../../services/log-service';
|
|
6
|
-
import { ioBrokerBaseDevice } from '../iIoBrokerDevice';
|
|
7
|
-
import { RoomBase } from '../../../models/rooms/RoomBase';
|
|
8
|
-
|
|
9
|
-
export class HmIPDevice extends ioBrokerBaseDevice {
|
|
10
|
-
public static roomSettings: { [id: string]: HmIpRoomSettings } = {};
|
|
11
|
-
public lowBattery: boolean = false;
|
|
12
|
-
public deviceType: HmIpDeviceType;
|
|
13
|
-
public room: RoomBase | undefined = undefined;
|
|
14
|
-
|
|
15
|
-
public static addRoom(shortName: string, settings: HmIpRoomSettings): void {
|
|
16
|
-
if (this.roomSettings[shortName] !== undefined) {
|
|
17
|
-
ServerLogService.writeLog(
|
|
18
|
-
LogLevel.Alert,
|
|
19
|
-
`Es gibt bereits ein Registrat für HmIpRoomsettings für den Raumnamen "${shortName}"`,
|
|
20
|
-
);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this.roomSettings[shortName] = settings;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public static checkMissing(): void {
|
|
27
|
-
for (const rName in this.roomSettings) {
|
|
28
|
-
this.roomSettings[rName].checkMissing();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public constructor(pInfo: DeviceInfo, pType: HmIpDeviceType) {
|
|
33
|
-
super(pInfo);
|
|
34
|
-
this.deviceType = pType;
|
|
35
|
-
this.addToCorrectRoom();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
protected addToCorrectRoom(): void {
|
|
39
|
-
const settings: HmIpRoomSettings | undefined = HmIPDevice.roomSettings[this.info.room];
|
|
40
|
-
if (settings !== undefined) {
|
|
41
|
-
if (settings.devices[this.deviceType] === undefined) {
|
|
42
|
-
ServerLogService.missingRoomHandling(settings.RoomName, this.deviceType);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const deviceSettings: HmIpAddDeviceItem | undefined =
|
|
46
|
-
settings.devices[this.deviceType][this.info.deviceRoomIndex];
|
|
47
|
-
if (deviceSettings === undefined) {
|
|
48
|
-
ServerLogService.missingRoomIndexHandling(settings.RoomName, this.info.deviceRoomIndex, this.deviceType);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (deviceSettings.customName !== undefined) {
|
|
53
|
-
this.info.customName = deviceSettings.customName;
|
|
54
|
-
}
|
|
55
|
-
deviceSettings.setID(this.info.devID);
|
|
56
|
-
deviceSettings.added = true;
|
|
57
|
-
ServerLogService.addedDeviceToRoom(settings.RoomName, this.deviceType, this.info.deviceRoomIndex);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
switch (this.info.room) {
|
|
61
|
-
default:
|
|
62
|
-
ServerLogService.writeLog(LogLevel.Warn, `${this.info.room} is noch kein bekannter Raum`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false, pOverride: boolean = false): void {
|
|
67
|
-
if (!pOverride) {
|
|
68
|
-
ServerLogService.writeLog(
|
|
69
|
-
LogLevel.Trace,
|
|
70
|
-
`Keine Update Überschreibung für "${this.info.customName}":\n\tID: ${idSplit.join(
|
|
71
|
-
'.',
|
|
72
|
-
)}\n\tData: ${JSON.stringify(state)}`,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (idSplit[3] !== '0') {
|
|
77
|
-
// Dies ist etwas Gerätespezifisches
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
switch (idSplit[4]) {
|
|
82
|
-
case 'LOW_BAT':
|
|
83
|
-
const newBatLowVal: boolean = state.val as boolean;
|
|
84
|
-
if (newBatLowVal) {
|
|
85
|
-
ServerLogService.writeLog(LogLevel.Alert, `!!BATTERIE FAST LEER!! "${this.info.customName}"`);
|
|
86
|
-
}
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
import { LogLevel } from '../../../models/logLevel';
|
|
2
|
+
import { DeviceInfo } from '../DeviceInfo';
|
|
3
|
+
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
4
|
+
import { HmIpAddDeviceItem, HmIpRoomSettings } from '../../../models/rooms/RoomSettings/hmIPRoomSettings';
|
|
5
|
+
import { ServerLogService } from '../../services/log-service';
|
|
6
|
+
import { ioBrokerBaseDevice } from '../iIoBrokerDevice';
|
|
7
|
+
import { RoomBase } from '../../../models/rooms/RoomBase';
|
|
8
|
+
|
|
9
|
+
export class HmIPDevice extends ioBrokerBaseDevice {
|
|
10
|
+
public static roomSettings: { [id: string]: HmIpRoomSettings } = {};
|
|
11
|
+
public lowBattery: boolean = false;
|
|
12
|
+
public deviceType: HmIpDeviceType;
|
|
13
|
+
public room: RoomBase | undefined = undefined;
|
|
14
|
+
|
|
15
|
+
public static addRoom(shortName: string, settings: HmIpRoomSettings): void {
|
|
16
|
+
if (this.roomSettings[shortName] !== undefined) {
|
|
17
|
+
ServerLogService.writeLog(
|
|
18
|
+
LogLevel.Alert,
|
|
19
|
+
`Es gibt bereits ein Registrat für HmIpRoomsettings für den Raumnamen "${shortName}"`,
|
|
20
|
+
);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this.roomSettings[shortName] = settings;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static checkMissing(): void {
|
|
27
|
+
for (const rName in this.roomSettings) {
|
|
28
|
+
this.roomSettings[rName].checkMissing();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public constructor(pInfo: DeviceInfo, pType: HmIpDeviceType) {
|
|
33
|
+
super(pInfo);
|
|
34
|
+
this.deviceType = pType;
|
|
35
|
+
this.addToCorrectRoom();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected addToCorrectRoom(): void {
|
|
39
|
+
const settings: HmIpRoomSettings | undefined = HmIPDevice.roomSettings[this.info.room];
|
|
40
|
+
if (settings !== undefined) {
|
|
41
|
+
if (settings.devices[this.deviceType] === undefined) {
|
|
42
|
+
ServerLogService.missingRoomHandling(settings.RoomName, this.deviceType);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const deviceSettings: HmIpAddDeviceItem | undefined =
|
|
46
|
+
settings.devices[this.deviceType][this.info.deviceRoomIndex];
|
|
47
|
+
if (deviceSettings === undefined) {
|
|
48
|
+
ServerLogService.missingRoomIndexHandling(settings.RoomName, this.info.deviceRoomIndex, this.deviceType);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (deviceSettings.customName !== undefined) {
|
|
53
|
+
this.info.customName = deviceSettings.customName;
|
|
54
|
+
}
|
|
55
|
+
deviceSettings.setID(this.info.devID);
|
|
56
|
+
deviceSettings.added = true;
|
|
57
|
+
ServerLogService.addedDeviceToRoom(settings.RoomName, this.deviceType, this.info.deviceRoomIndex);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
switch (this.info.room) {
|
|
61
|
+
default:
|
|
62
|
+
ServerLogService.writeLog(LogLevel.Warn, `${this.info.room} is noch kein bekannter Raum`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false, pOverride: boolean = false): void {
|
|
67
|
+
if (!pOverride) {
|
|
68
|
+
ServerLogService.writeLog(
|
|
69
|
+
LogLevel.Trace,
|
|
70
|
+
`Keine Update Überschreibung für "${this.info.customName}":\n\tID: ${idSplit.join(
|
|
71
|
+
'.',
|
|
72
|
+
)}\n\tData: ${JSON.stringify(state)}`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (idSplit[3] !== '0') {
|
|
77
|
+
// Dies ist etwas Gerätespezifisches
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
switch (idSplit[4]) {
|
|
82
|
+
case 'LOW_BAT':
|
|
83
|
+
const newBatLowVal: boolean = state.val as boolean;
|
|
84
|
+
if (newBatLowVal) {
|
|
85
|
+
ServerLogService.writeLog(LogLevel.Alert, `!!BATTERIE FAST LEER!! "${this.info.customName}"`);
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export enum HmIpDeviceType {
|
|
2
|
-
unknown = 0,
|
|
3
|
-
HmIpLampe = 1,
|
|
4
|
-
HmIpTaster = 2,
|
|
5
|
-
HmIpRoll = 3,
|
|
6
|
-
HmIpTherm = 4,
|
|
7
|
-
HmIpPraezenz = 5,
|
|
8
|
-
HmIpGriff = 6,
|
|
9
|
-
HmIpWippe = 7,
|
|
10
|
-
HmIpHeizung = 8,
|
|
11
|
-
HmIpTuer = 9,
|
|
12
|
-
HmIpHeizgruppe = 10,
|
|
13
|
-
HmIpBewegung = 11,
|
|
14
|
-
}
|
|
1
|
+
export enum HmIpDeviceType {
|
|
2
|
+
unknown = 0,
|
|
3
|
+
HmIpLampe = 1,
|
|
4
|
+
HmIpTaster = 2,
|
|
5
|
+
HmIpRoll = 3,
|
|
6
|
+
HmIpTherm = 4,
|
|
7
|
+
HmIpPraezenz = 5,
|
|
8
|
+
HmIpGriff = 6,
|
|
9
|
+
HmIpWippe = 7,
|
|
10
|
+
HmIpHeizung = 8,
|
|
11
|
+
HmIpTuer = 9,
|
|
12
|
+
HmIpHeizgruppe = 10,
|
|
13
|
+
HmIpBewegung = 11,
|
|
14
|
+
}
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
import { LogLevel } from '../../../models/logLevel';
|
|
2
|
-
import { FensterPosition } from './FensterPosition';
|
|
3
|
-
import { HmIPDevice } from './hmIpDevice';
|
|
4
|
-
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
5
|
-
import { DeviceInfo } from '../DeviceInfo';
|
|
6
|
-
import { ServerLogService } from '../../services/log-service';
|
|
7
|
-
import { TelegramService } from '../../services/Telegram/telegram-service';
|
|
8
|
-
import { Utils } from '../../services/utils/utils';
|
|
9
|
-
import { Fenster } from './Fenster';
|
|
10
|
-
import { WeatherService } from '../../services/weather/weather-service';
|
|
11
|
-
|
|
12
|
-
export class HmIpGriff extends HmIPDevice {
|
|
13
|
-
public position: FensterPosition = FensterPosition.geschlossen;
|
|
14
|
-
private _kippCallback: Array<(pValue: boolean) => void> = [];
|
|
15
|
-
private _closedCallback: Array<(pValue: boolean) => void> = [];
|
|
16
|
-
private _offenCallback: Array<(pValue: boolean) => void> = [];
|
|
17
|
-
private _iOpen: NodeJS.Timeout | undefined;
|
|
18
|
-
private minutesOpen: number = 0;
|
|
19
|
-
private _fenster: Fenster | undefined = undefined;
|
|
20
|
-
private _helpingRoomTemp: boolean = false;
|
|
21
|
-
|
|
22
|
-
public constructor(pInfo: DeviceInfo) {
|
|
23
|
-
super(pInfo, HmIpDeviceType.HmIpGriff);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public addOffenCallback(pCallback: (pValue: boolean) => void): void {
|
|
27
|
-
this._offenCallback.push(pCallback);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public addKippCallback(pCallback: (pValue: boolean) => void): void {
|
|
31
|
-
this._kippCallback.push(pCallback);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public addClosedCallback(pCallback: (pValue: boolean) => void): void {
|
|
35
|
-
this._closedCallback.push(pCallback);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public set Fenster(value: Fenster) {
|
|
39
|
-
this._fenster = value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
|
|
43
|
-
ServerLogService.writeLog(
|
|
44
|
-
LogLevel.DeepTrace,
|
|
45
|
-
`Griff Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`,
|
|
46
|
-
);
|
|
47
|
-
super.update(idSplit, state, initial, true);
|
|
48
|
-
switch (idSplit[3]) {
|
|
49
|
-
case '1':
|
|
50
|
-
if (idSplit[4] === 'STATE') {
|
|
51
|
-
this.updatePosition(state.val as FensterPosition);
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public updatePosition(pValue: FensterPosition): void {
|
|
58
|
-
if (pValue === this.position) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
ServerLogService.writeLog(
|
|
63
|
-
LogLevel.Trace,
|
|
64
|
-
`Update Fenstergriff "${this.info.customName}"\nauf Position "${FensterPosition[pValue]}"`,
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
this.position = pValue;
|
|
68
|
-
for (const c1 of this._closedCallback) {
|
|
69
|
-
c1(pValue === 0);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
for (const c2 of this._kippCallback) {
|
|
73
|
-
c2(pValue === 1);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
for (const c3 of this._offenCallback) {
|
|
77
|
-
c3(pValue === 2);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (pValue === FensterPosition.geschlossen) {
|
|
81
|
-
if (this._iOpen !== undefined) {
|
|
82
|
-
clearInterval(this._iOpen);
|
|
83
|
-
ServerLogService.writeLog(
|
|
84
|
-
LogLevel.Info,
|
|
85
|
-
`Fenster: "${this.info.customName}" nach ${this.minutesOpen} Minuten geschlossen`,
|
|
86
|
-
);
|
|
87
|
-
this.minutesOpen = 0;
|
|
88
|
-
this._iOpen = undefined;
|
|
89
|
-
}
|
|
90
|
-
return;
|
|
91
|
-
} else if (this._iOpen === undefined) {
|
|
92
|
-
this._iOpen = Utils.guardedInterval(
|
|
93
|
-
() => {
|
|
94
|
-
this.minutesOpen++;
|
|
95
|
-
if (this._fenster !== undefined && this._fenster.room !== undefined) {
|
|
96
|
-
const desiredTemp: number = this._fenster.room.HeatGroup.desiredTemp;
|
|
97
|
-
const currentTemp: number = this._fenster.room.HeatGroup.currentTemp;
|
|
98
|
-
const outSideTemp: number = WeatherService.getCurrentTemp();
|
|
99
|
-
|
|
100
|
-
// Check if any of these values are unavailable
|
|
101
|
-
if (desiredTemp > -99 && currentTemp > -99 && outSideTemp > -99) {
|
|
102
|
-
const wouldHelp: boolean =
|
|
103
|
-
(desiredTemp < currentTemp && outSideTemp < currentTemp) ||
|
|
104
|
-
(desiredTemp > currentTemp && outSideTemp > currentTemp);
|
|
105
|
-
if (!wouldHelp && this._helpingRoomTemp) {
|
|
106
|
-
const info: string = `Das Fenster "${this.info.customName}" sollte geschlossen werden, es hilft dem Raum nicht mehr`;
|
|
107
|
-
ServerLogService.writeLog(LogLevel.Info, info);
|
|
108
|
-
TelegramService.inform(info);
|
|
109
|
-
this._helpingRoomTemp = false;
|
|
110
|
-
} else if (wouldHelp && !this._helpingRoomTemp) {
|
|
111
|
-
this._helpingRoomTemp = true;
|
|
112
|
-
const info: string = `Das Fenster "${this.info.customName}" hilft der Innentemperatur ihr Ziel von ${desiredTemp} zu erreichen. Draußen sind es ${outSideTemp}. Du wirst informiert wenn es nicht mehr hilft.`;
|
|
113
|
-
ServerLogService.writeLog(LogLevel.Info, info);
|
|
114
|
-
TelegramService.inform(info);
|
|
115
|
-
return;
|
|
116
|
-
} else if (wouldHelp && this._helpingRoomTemp) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const message = `Fenster: "${this.info.customName}" seit ${this.minutesOpen} Minuten auf Position ${
|
|
122
|
-
FensterPosition[this.position]
|
|
123
|
-
}`;
|
|
124
|
-
switch (this.minutesOpen) {
|
|
125
|
-
case 15:
|
|
126
|
-
case 30:
|
|
127
|
-
case 60:
|
|
128
|
-
case 120:
|
|
129
|
-
case 240:
|
|
130
|
-
ServerLogService.writeLog(LogLevel.Info, message);
|
|
131
|
-
TelegramService.inform(message);
|
|
132
|
-
break;
|
|
133
|
-
default:
|
|
134
|
-
ServerLogService.writeLog(LogLevel.Trace, message);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
60000,
|
|
139
|
-
this,
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
1
|
+
import { LogLevel } from '../../../models/logLevel';
|
|
2
|
+
import { FensterPosition } from './FensterPosition';
|
|
3
|
+
import { HmIPDevice } from './hmIpDevice';
|
|
4
|
+
import { HmIpDeviceType } from './hmIpDeviceType';
|
|
5
|
+
import { DeviceInfo } from '../DeviceInfo';
|
|
6
|
+
import { ServerLogService } from '../../services/log-service';
|
|
7
|
+
import { TelegramService } from '../../services/Telegram/telegram-service';
|
|
8
|
+
import { Utils } from '../../services/utils/utils';
|
|
9
|
+
import { Fenster } from './Fenster';
|
|
10
|
+
import { WeatherService } from '../../services/weather/weather-service';
|
|
11
|
+
|
|
12
|
+
export class HmIpGriff extends HmIPDevice {
|
|
13
|
+
public position: FensterPosition = FensterPosition.geschlossen;
|
|
14
|
+
private _kippCallback: Array<(pValue: boolean) => void> = [];
|
|
15
|
+
private _closedCallback: Array<(pValue: boolean) => void> = [];
|
|
16
|
+
private _offenCallback: Array<(pValue: boolean) => void> = [];
|
|
17
|
+
private _iOpen: NodeJS.Timeout | undefined;
|
|
18
|
+
private minutesOpen: number = 0;
|
|
19
|
+
private _fenster: Fenster | undefined = undefined;
|
|
20
|
+
private _helpingRoomTemp: boolean = false;
|
|
21
|
+
|
|
22
|
+
public constructor(pInfo: DeviceInfo) {
|
|
23
|
+
super(pInfo, HmIpDeviceType.HmIpGriff);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public addOffenCallback(pCallback: (pValue: boolean) => void): void {
|
|
27
|
+
this._offenCallback.push(pCallback);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public addKippCallback(pCallback: (pValue: boolean) => void): void {
|
|
31
|
+
this._kippCallback.push(pCallback);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public addClosedCallback(pCallback: (pValue: boolean) => void): void {
|
|
35
|
+
this._closedCallback.push(pCallback);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public set Fenster(value: Fenster) {
|
|
39
|
+
this._fenster = value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
|
|
43
|
+
ServerLogService.writeLog(
|
|
44
|
+
LogLevel.DeepTrace,
|
|
45
|
+
`Griff Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`,
|
|
46
|
+
);
|
|
47
|
+
super.update(idSplit, state, initial, true);
|
|
48
|
+
switch (idSplit[3]) {
|
|
49
|
+
case '1':
|
|
50
|
+
if (idSplit[4] === 'STATE') {
|
|
51
|
+
this.updatePosition(state.val as FensterPosition);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public updatePosition(pValue: FensterPosition): void {
|
|
58
|
+
if (pValue === this.position) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
ServerLogService.writeLog(
|
|
63
|
+
LogLevel.Trace,
|
|
64
|
+
`Update Fenstergriff "${this.info.customName}"\nauf Position "${FensterPosition[pValue]}"`,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
this.position = pValue;
|
|
68
|
+
for (const c1 of this._closedCallback) {
|
|
69
|
+
c1(pValue === 0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const c2 of this._kippCallback) {
|
|
73
|
+
c2(pValue === 1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
for (const c3 of this._offenCallback) {
|
|
77
|
+
c3(pValue === 2);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (pValue === FensterPosition.geschlossen) {
|
|
81
|
+
if (this._iOpen !== undefined) {
|
|
82
|
+
clearInterval(this._iOpen);
|
|
83
|
+
ServerLogService.writeLog(
|
|
84
|
+
LogLevel.Info,
|
|
85
|
+
`Fenster: "${this.info.customName}" nach ${this.minutesOpen} Minuten geschlossen`,
|
|
86
|
+
);
|
|
87
|
+
this.minutesOpen = 0;
|
|
88
|
+
this._iOpen = undefined;
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
} else if (this._iOpen === undefined) {
|
|
92
|
+
this._iOpen = Utils.guardedInterval(
|
|
93
|
+
() => {
|
|
94
|
+
this.minutesOpen++;
|
|
95
|
+
if (this._fenster !== undefined && this._fenster.room !== undefined) {
|
|
96
|
+
const desiredTemp: number = this._fenster.room.HeatGroup.desiredTemp;
|
|
97
|
+
const currentTemp: number = this._fenster.room.HeatGroup.currentTemp;
|
|
98
|
+
const outSideTemp: number = WeatherService.getCurrentTemp();
|
|
99
|
+
|
|
100
|
+
// Check if any of these values are unavailable
|
|
101
|
+
if (desiredTemp > -99 && currentTemp > -99 && outSideTemp > -99) {
|
|
102
|
+
const wouldHelp: boolean =
|
|
103
|
+
(desiredTemp < currentTemp && outSideTemp < currentTemp) ||
|
|
104
|
+
(desiredTemp > currentTemp && outSideTemp > currentTemp);
|
|
105
|
+
if (!wouldHelp && this._helpingRoomTemp) {
|
|
106
|
+
const info: string = `Das Fenster "${this.info.customName}" sollte geschlossen werden, es hilft dem Raum nicht mehr`;
|
|
107
|
+
ServerLogService.writeLog(LogLevel.Info, info);
|
|
108
|
+
TelegramService.inform(info);
|
|
109
|
+
this._helpingRoomTemp = false;
|
|
110
|
+
} else if (wouldHelp && !this._helpingRoomTemp) {
|
|
111
|
+
this._helpingRoomTemp = true;
|
|
112
|
+
const info: string = `Das Fenster "${this.info.customName}" hilft der Innentemperatur ihr Ziel von ${desiredTemp} zu erreichen. Draußen sind es ${outSideTemp}. Du wirst informiert wenn es nicht mehr hilft.`;
|
|
113
|
+
ServerLogService.writeLog(LogLevel.Info, info);
|
|
114
|
+
TelegramService.inform(info);
|
|
115
|
+
return;
|
|
116
|
+
} else if (wouldHelp && this._helpingRoomTemp) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const message = `Fenster: "${this.info.customName}" seit ${this.minutesOpen} Minuten auf Position ${
|
|
122
|
+
FensterPosition[this.position]
|
|
123
|
+
}`;
|
|
124
|
+
switch (this.minutesOpen) {
|
|
125
|
+
case 15:
|
|
126
|
+
case 30:
|
|
127
|
+
case 60:
|
|
128
|
+
case 120:
|
|
129
|
+
case 240:
|
|
130
|
+
ServerLogService.writeLog(LogLevel.Info, message);
|
|
131
|
+
TelegramService.inform(message);
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
ServerLogService.writeLog(LogLevel.Trace, message);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
60000,
|
|
139
|
+
this,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|