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,159 @@
|
|
|
1
|
+
import { HmIpRoomSettings } from './hmIPRoomSettings';
|
|
2
|
+
import { ZigbeeRoomSettings } from './zigbeeRoomSettings';
|
|
3
|
+
import { SettingsService } from '../../../server/services/settings-service';
|
|
4
|
+
import { iRoomDefaultSettings } from './iRoomDefaultSettings';
|
|
5
|
+
import { SunTimeOffsets } from '../../../server/services/time-callback-service';
|
|
6
|
+
|
|
7
|
+
import { RoomBase } from '../RoomBase';
|
|
8
|
+
import { iTimePair } from '../../../server/config/iConfig';
|
|
9
|
+
|
|
10
|
+
export class RoomSettings implements iRoomDefaultSettings {
|
|
11
|
+
public defaultSettings: iRoomDefaultSettings = SettingsService.settings.roomDefault;
|
|
12
|
+
private _lampenBeiBewegung: boolean = this.defaultSettings.lampenBeiBewegung;
|
|
13
|
+
private _lichtSonnenAufgangAus: boolean = this.defaultSettings.lichtSonnenAufgangAus;
|
|
14
|
+
private _sonnenUntergangRollos: boolean = this.defaultSettings.sonnenUntergangRollos;
|
|
15
|
+
private _sonnenAufgangRollos: boolean = this.defaultSettings.sonnenAufgangRollos;
|
|
16
|
+
private _movementResetTimer: number = this.defaultSettings.movementResetTimer;
|
|
17
|
+
private _sonnenUntergangRolloDelay: number = this.defaultSettings.sonnenUntergangRolloDelay;
|
|
18
|
+
private _sonnenUntergangRolloMaxTime: iTimePair = this.defaultSettings.sonnenUntergangRolloMaxTime;
|
|
19
|
+
private _sonnenUntergangLampenDelay: number = this.defaultSettings.sonnenUntergangLampenDelay;
|
|
20
|
+
private _sonnenAufgangRolloDelay: number = this.defaultSettings.sonnenAufgangRolloDelay;
|
|
21
|
+
private _sonnenAufgangRolloMinTime: iTimePair = this.defaultSettings.sonnenAufgangRolloMinTime;
|
|
22
|
+
private _sonnenAufgangLampenDelay: number = this.defaultSettings.sonnenAufgangLampenDelay;
|
|
23
|
+
private _lightIfNoWindows: boolean = this.defaultSettings.lightIfNoWindows;
|
|
24
|
+
public hmIpSettings?: HmIpRoomSettings;
|
|
25
|
+
public zigbeeSettings?: ZigbeeRoomSettings;
|
|
26
|
+
public radioUrl: string = 'https://hermes.bcs-systems.de/hitradio-rtl_top40_64k_aac'; // Radio RTL
|
|
27
|
+
public etage: number = -1;
|
|
28
|
+
public rolloOffset: SunTimeOffsets;
|
|
29
|
+
public lampOffset: SunTimeOffsets;
|
|
30
|
+
public room?: RoomBase;
|
|
31
|
+
public rolloHeatReduction: boolean = this.defaultSettings.rolloHeatReduction;
|
|
32
|
+
|
|
33
|
+
public constructor(public shortName: string) {
|
|
34
|
+
this.rolloOffset = new SunTimeOffsets(
|
|
35
|
+
this.sonnenAufgangRolloDelay,
|
|
36
|
+
this.sonnenUntergangRolloDelay,
|
|
37
|
+
this.sonnenAufgangRolloMinTime.hours,
|
|
38
|
+
this.sonnenAufgangRolloMinTime.minutes,
|
|
39
|
+
this.sonnenUntergangRolloMaxTime.hours,
|
|
40
|
+
this.sonnenUntergangRolloMaxTime.minutes,
|
|
41
|
+
);
|
|
42
|
+
this.lampOffset = new SunTimeOffsets(this.sonnenAufgangLampenDelay, this.sonnenUntergangLampenDelay);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private recalcRolloOffset(): void {
|
|
46
|
+
this.rolloOffset = new SunTimeOffsets(
|
|
47
|
+
this.sonnenAufgangRolloDelay,
|
|
48
|
+
this.sonnenUntergangRolloDelay,
|
|
49
|
+
this.sonnenAufgangRolloMinTime.hours,
|
|
50
|
+
this.sonnenAufgangRolloMinTime.minutes,
|
|
51
|
+
this.sonnenUntergangRolloMaxTime.hours,
|
|
52
|
+
this.sonnenUntergangRolloMaxTime.minutes,
|
|
53
|
+
);
|
|
54
|
+
if (this.room) {
|
|
55
|
+
this.room.recalcTimeCallbacks();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private recalcLampOffset(): void {
|
|
60
|
+
this.lampOffset = new SunTimeOffsets(this.sonnenAufgangLampenDelay, this.sonnenAufgangRolloDelay);
|
|
61
|
+
if (this.room) {
|
|
62
|
+
this.room.recalcTimeCallbacks();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get sonnenAufgangLampenDelay(): number {
|
|
67
|
+
return this._sonnenAufgangLampenDelay;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
set sonnenAufgangLampenDelay(value: number) {
|
|
71
|
+
this._sonnenAufgangLampenDelay = value;
|
|
72
|
+
this.recalcLampOffset();
|
|
73
|
+
}
|
|
74
|
+
get sonnenAufgangRolloDelay(): number {
|
|
75
|
+
return this._sonnenAufgangRolloDelay;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
set sonnenAufgangRolloDelay(value: number) {
|
|
79
|
+
this._sonnenAufgangRolloDelay = value;
|
|
80
|
+
this.recalcRolloOffset();
|
|
81
|
+
}
|
|
82
|
+
get sonnenUntergangLampenDelay(): number {
|
|
83
|
+
return this._sonnenUntergangLampenDelay;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
set sonnenUntergangLampenDelay(value: number) {
|
|
87
|
+
this._sonnenUntergangLampenDelay = value;
|
|
88
|
+
this.recalcLampOffset();
|
|
89
|
+
}
|
|
90
|
+
get sonnenUntergangRolloDelay(): number {
|
|
91
|
+
return this._sonnenUntergangRolloDelay;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
set sonnenUntergangRolloDelay(value: number) {
|
|
95
|
+
this._sonnenUntergangRolloDelay = value;
|
|
96
|
+
}
|
|
97
|
+
get movementResetTimer(): number {
|
|
98
|
+
return this._movementResetTimer;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
set movementResetTimer(value: number) {
|
|
102
|
+
this._movementResetTimer = value;
|
|
103
|
+
}
|
|
104
|
+
get lichtSonnenAufgangAus(): boolean {
|
|
105
|
+
return this._lichtSonnenAufgangAus;
|
|
106
|
+
}
|
|
107
|
+
get sonnenAufgangRollos(): boolean {
|
|
108
|
+
return this._sonnenAufgangRollos;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
set sonnenAufgangRollos(value: boolean) {
|
|
112
|
+
this._sonnenAufgangRollos = value;
|
|
113
|
+
this.recalcRolloOffset();
|
|
114
|
+
}
|
|
115
|
+
get sonnenUntergangRollos(): boolean {
|
|
116
|
+
return this._sonnenUntergangRollos;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
set sonnenUntergangRollos(value: boolean) {
|
|
120
|
+
this._sonnenUntergangRollos = value;
|
|
121
|
+
this.recalcRolloOffset();
|
|
122
|
+
}
|
|
123
|
+
set lichtSonnenAufgangAus(value: boolean) {
|
|
124
|
+
this._lichtSonnenAufgangAus = value;
|
|
125
|
+
}
|
|
126
|
+
get lampenBeiBewegung(): boolean {
|
|
127
|
+
return this._lampenBeiBewegung;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
set lampenBeiBewegung(value: boolean) {
|
|
131
|
+
this._lampenBeiBewegung = value;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get sonnenUntergangRolloMaxTime(): iTimePair {
|
|
135
|
+
return this._sonnenUntergangRolloMaxTime;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
set sonnenUntergangRolloMaxTime(value: iTimePair) {
|
|
139
|
+
this._sonnenUntergangRolloMaxTime = value;
|
|
140
|
+
this.recalcRolloOffset();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
get sonnenAufgangRolloMinTime(): iTimePair {
|
|
144
|
+
return this._sonnenAufgangRolloMinTime;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
set sonnenAufgangRolloMinTime(value: iTimePair) {
|
|
148
|
+
this._sonnenAufgangRolloMinTime = value;
|
|
149
|
+
this.recalcRolloOffset();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get lightIfNoWindows(): boolean {
|
|
153
|
+
return this._lightIfNoWindows;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
set lightIfNoWindows(value: boolean) {
|
|
157
|
+
this._lightIfNoWindows = value;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { HmIpDeviceType } from '../../../server/devices/hmIPDevices/hmIpDeviceType';
|
|
2
|
+
import { ServerLogService } from '../../../server/services/log-service';
|
|
3
|
+
import { LogLevel } from '../../logLevel';
|
|
4
|
+
|
|
5
|
+
export class HmIpAddDeviceItem {
|
|
6
|
+
private _added: boolean = false;
|
|
7
|
+
|
|
8
|
+
public get added(): boolean {
|
|
9
|
+
return this._added;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public set added(value: boolean) {
|
|
13
|
+
if (this._added) {
|
|
14
|
+
ServerLogService.writeLog(LogLevel.Error, `${this.customName} Added twice`);
|
|
15
|
+
}
|
|
16
|
+
this._added = value;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor(public setID: (value: string) => void, public index: number, public customName: string) {}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class HmIpRoomSettings {
|
|
23
|
+
public devices: Array<Array<HmIpAddDeviceItem>> = [];
|
|
24
|
+
|
|
25
|
+
constructor(public RoomName: string) {}
|
|
26
|
+
|
|
27
|
+
public addDevice(
|
|
28
|
+
deviceType: HmIpDeviceType,
|
|
29
|
+
setID: (value: string) => void,
|
|
30
|
+
index: number,
|
|
31
|
+
customName: string | undefined = undefined,
|
|
32
|
+
): void {
|
|
33
|
+
if (this.devices[deviceType] === undefined) {
|
|
34
|
+
this.devices[deviceType] = [];
|
|
35
|
+
}
|
|
36
|
+
if (customName === undefined) {
|
|
37
|
+
customName = `${this.RoomName} ${HmIpDeviceType[deviceType]}`;
|
|
38
|
+
}
|
|
39
|
+
this.devices[deviceType][index] = new HmIpAddDeviceItem(setID, index, customName);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public checkMissing(): void {
|
|
43
|
+
for (const type in this.devices) {
|
|
44
|
+
const devs = this.devices[type];
|
|
45
|
+
for (const index in devs) {
|
|
46
|
+
const dev = devs[index];
|
|
47
|
+
if (!dev.added) {
|
|
48
|
+
ServerLogService.writeLog(LogLevel.Error, `${dev.customName} fehlt in der Device JSON`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { iTimePair } from '../../../server/config/iConfig';
|
|
2
|
+
|
|
3
|
+
export interface iRoomDefaultSettings {
|
|
4
|
+
rolloHeatReduction: boolean;
|
|
5
|
+
lampenBeiBewegung: boolean;
|
|
6
|
+
lichtSonnenAufgangAus: boolean;
|
|
7
|
+
sonnenUntergangRollos: boolean;
|
|
8
|
+
sonnenUntergangRolloDelay: number;
|
|
9
|
+
sonnenUntergangRolloMaxTime: iTimePair;
|
|
10
|
+
sonnenUntergangLampenDelay: number;
|
|
11
|
+
sonnenAufgangRollos: boolean;
|
|
12
|
+
sonnenAufgangRolloDelay: number;
|
|
13
|
+
sonnenAufgangRolloMinTime: iTimePair;
|
|
14
|
+
sonnenAufgangLampenDelay: number;
|
|
15
|
+
movementResetTimer: number;
|
|
16
|
+
lightIfNoWindows: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
### Generate Setter for ID's ###
|
|
2
|
+
```
|
|
3
|
+
function fix(s) {
|
|
4
|
+
var t = [];
|
|
5
|
+
var e = s.split('\n');
|
|
6
|
+
for(var i=0;i<e.length;i++) {
|
|
7
|
+
var cI = e[i];
|
|
8
|
+
cI = cI.trim().trimStart();
|
|
9
|
+
cI = cI.replace("private static ", "");
|
|
10
|
+
cI = cI.replace(": string = '';", "");
|
|
11
|
+
cI = cI.replace(": string;", "");
|
|
12
|
+
var cL = `${cI.charAt(0).toUpperCase()}${cI.substr(1)}`;
|
|
13
|
+
t.push(`public static set${cL}(value: string): void {\n\tthis.${cI} = value;\n}`);
|
|
14
|
+
}
|
|
15
|
+
console.log(t.join("\n\n"));
|
|
16
|
+
}
|
|
17
|
+
fix(`YOUR_DECLARATIONS_COME_HERE`);
|
|
18
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ZigbeeDeviceType } from '../../../server/devices/zigbee/zigbeeDeviceType';
|
|
2
|
+
import { ServerLogService } from '../../../server/services/log-service';
|
|
3
|
+
import { LogLevel } from '../../logLevel';
|
|
4
|
+
|
|
5
|
+
export class ZigbeeAddDeviceItem {
|
|
6
|
+
private _added: boolean = false;
|
|
7
|
+
|
|
8
|
+
public get added(): boolean {
|
|
9
|
+
return this._added;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public set added(value: boolean) {
|
|
13
|
+
if (this._added) {
|
|
14
|
+
ServerLogService.writeLog(LogLevel.Error, `${this.customName} Added twice`);
|
|
15
|
+
}
|
|
16
|
+
this._added = value;
|
|
17
|
+
}
|
|
18
|
+
constructor(public setID: (value: string) => void, public index: number, public customName: string) {}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class ZigbeeRoomSettings {
|
|
22
|
+
public devices: Array<Array<ZigbeeAddDeviceItem>> = [];
|
|
23
|
+
constructor(public RoomName: string) {}
|
|
24
|
+
|
|
25
|
+
public addDevice(
|
|
26
|
+
deviceType: ZigbeeDeviceType,
|
|
27
|
+
setID: (value: string) => void,
|
|
28
|
+
index: number,
|
|
29
|
+
customName: string | undefined = undefined,
|
|
30
|
+
): void {
|
|
31
|
+
if (this.devices[deviceType] === undefined) {
|
|
32
|
+
this.devices[deviceType] = [];
|
|
33
|
+
}
|
|
34
|
+
if (customName === undefined) {
|
|
35
|
+
customName = `${this.RoomName} ${ZigbeeDeviceType[deviceType]}`;
|
|
36
|
+
}
|
|
37
|
+
this.devices[deviceType][index] = new ZigbeeAddDeviceItem(setID, index, customName);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public checkMissing(): void {
|
|
41
|
+
for (const type in this.devices) {
|
|
42
|
+
const devs = this.devices[type];
|
|
43
|
+
for (const index in devs) {
|
|
44
|
+
const dev = devs[index];
|
|
45
|
+
if (!dev.added) {
|
|
46
|
+
ServerLogService.writeLog(LogLevel.Error, `${dev.customName} fehlt in der Device JSON`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
### Create Rooms
|
|
2
|
+
Hoffmation is centered about rooms.
|
|
3
|
+
Many follow certain default behaviour while others have very specific rules.
|
|
4
|
+
To be modular Rooms within HoffMation should be generated automatically.
|
|
5
|
+
|
|
6
|
+
To do so use the Excel Document `Raumdefinition.xlsm`
|
|
7
|
+
Within that document you have to create all your rooms and the devices.
|
|
8
|
+
|
|
9
|
+
Afterwards you can create the resulting config code and paste that into
|
|
10
|
+
`server/config/roomConfig.txt`
|
|
11
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Daytime } from './daytime';
|
|
2
|
+
|
|
3
|
+
export class TemperaturSettings {
|
|
4
|
+
public constructor(
|
|
5
|
+
public start: Daytime,
|
|
6
|
+
public end: Daytime,
|
|
7
|
+
public temperatur: number,
|
|
8
|
+
public active: boolean = true,
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
public isNowInRange(): boolean {
|
|
12
|
+
const now: number = new Date().getTime();
|
|
13
|
+
const todayStart: number = new Date().setHours(this.start.hour, this.start.minute);
|
|
14
|
+
if (now < todayStart) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const todayEnd: number = new Date().setHours(this.end.hour, this.end.minute);
|
|
19
|
+
|
|
20
|
+
return now < todayEnd;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { LogLevel } from './logLevel';
|
|
2
|
+
import { ServerLogService } from '/server/services/log-service';
|
|
3
|
+
import { SunTimeOffsets, TimeCallbackService } from '/server/services/time-callback-service';
|
|
4
|
+
|
|
5
|
+
export class TimeCallback {
|
|
6
|
+
public lastDone: Date = new Date(0);
|
|
7
|
+
public nextToDo?: Date;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
public name: string,
|
|
11
|
+
public type: TimeCallbackType,
|
|
12
|
+
public cFunction: () => void,
|
|
13
|
+
public minuteOffset: number,
|
|
14
|
+
public hours?: number,
|
|
15
|
+
public minutes?: number,
|
|
16
|
+
public sunTimeOffset?: SunTimeOffsets,
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
public recalcNextToDo(now: Date): void {
|
|
20
|
+
const today: Date = new Date(now.getTime());
|
|
21
|
+
today.setHours(0, 0, 0, 0);
|
|
22
|
+
switch (this.type) {
|
|
23
|
+
case TimeCallbackType.TimeOfDay:
|
|
24
|
+
if (this.hours === undefined) {
|
|
25
|
+
this.hours = 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (this.minutes === undefined) {
|
|
29
|
+
this.minutes = 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.nextToDo = new Date(
|
|
33
|
+
today.getTime() + this.hours * 60 * 60 * 1000 + (this.minutes + this.minuteOffset) * 60 * 1000,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (this.nextToDo < now) {
|
|
37
|
+
// Heute ist schon abgelaufen, also morgen festlegen
|
|
38
|
+
this.nextToDo = new Date(this.nextToDo.getTime() + 24 * 60 * 60 * 1000);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ServerLogService.writeLog(
|
|
42
|
+
LogLevel.Trace,
|
|
43
|
+
`Nächste Zeitevent für "${this.name}" um ${this.nextToDo.toLocaleTimeString('de-DE')}`,
|
|
44
|
+
);
|
|
45
|
+
break;
|
|
46
|
+
case TimeCallbackType.Sunrise:
|
|
47
|
+
let fixedSRDate: Date = new Date(TimeCallbackService.nextSunRise.getTime() + this.minuteOffset * 60 * 1000);
|
|
48
|
+
if (this.sunTimeOffset) {
|
|
49
|
+
const nextMinSR: Date = this.sunTimeOffset.getNextMinimumSunrise();
|
|
50
|
+
if (fixedSRDate.getDate() === nextMinSR.getDate()) {
|
|
51
|
+
fixedSRDate = nextMinSR;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (now > fixedSRDate) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
ServerLogService.writeLog(
|
|
59
|
+
LogLevel.Trace,
|
|
60
|
+
`Nächste Zeitevent für "${this.name}" um ${fixedSRDate.toLocaleTimeString('de-DE')}`,
|
|
61
|
+
);
|
|
62
|
+
this.nextToDo = fixedSRDate;
|
|
63
|
+
break;
|
|
64
|
+
case TimeCallbackType.SunSet:
|
|
65
|
+
let fixedSSDate: Date = new Date(TimeCallbackService.nextSunSet.getTime() + this.minuteOffset * 60 * 1000);
|
|
66
|
+
if (this.sunTimeOffset) {
|
|
67
|
+
const nextMaxSS: Date = this.sunTimeOffset.getNextMaximumSunset();
|
|
68
|
+
if (fixedSSDate.getDate() === nextMaxSS.getDate()) {
|
|
69
|
+
fixedSSDate = nextMaxSS;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (now > fixedSSDate) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
ServerLogService.writeLog(
|
|
77
|
+
LogLevel.Trace,
|
|
78
|
+
`Nächste Zeitevent für "${this.name}" um ${fixedSSDate.toLocaleTimeString('de-DE')}`,
|
|
79
|
+
);
|
|
80
|
+
this.nextToDo = fixedSSDate;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export enum TimeCallbackType {
|
|
87
|
+
TimeOfDay = 1,
|
|
88
|
+
Sunrise = 2,
|
|
89
|
+
SunSet = 3,
|
|
90
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hoffmation-base",
|
|
3
|
+
"description": "Base Libraries and functions for own Hoffmation projects",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/theimo1221/Hoffmation-Base.git"
|
|
9
|
+
},
|
|
10
|
+
"author": "Thiemo Hoffmann",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/theimo1221/Hoffmation-Base/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/theimo1221/Hoffmation-Base#readme",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"lint-fix-all": "eslint ./**/{*.ts,*.js} --fix --no-error-on-unmatched-pattern"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@babel/runtime": "^7.15.4",
|
|
21
|
+
"@svrooij/sonos": "^2.4.1",
|
|
22
|
+
"aws-sdk": "2.999.0",
|
|
23
|
+
"bcrypt": "^5.0.1",
|
|
24
|
+
"get-mp3-duration": "^1.0.0",
|
|
25
|
+
"html-entities": "^2.3.2",
|
|
26
|
+
"https": "^1.0.0",
|
|
27
|
+
"iobroker.socketio": "^3.1.4",
|
|
28
|
+
"jquery": "^3.6.0",
|
|
29
|
+
"mocha": "^9.1.2",
|
|
30
|
+
"node-ical": "^0.13.0",
|
|
31
|
+
"node-telegram-bot-api": "^0.54.0",
|
|
32
|
+
"semantic-ui-react": "^2.0.4",
|
|
33
|
+
"socket.io-client": "2.4.x",
|
|
34
|
+
"sunrise-sunset-js": "^2.2.1",
|
|
35
|
+
"underscore": "^1.13.1",
|
|
36
|
+
"ws": "^7.5.5"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/meteor": "^1.4.78",
|
|
40
|
+
"@types/mocha": "^9.0.0",
|
|
41
|
+
"@types/node-telegram-bot-api": "^0.53.0",
|
|
42
|
+
"@types/iobroker": "^3.3.4",
|
|
43
|
+
"@types/node": "^16.10.2",
|
|
44
|
+
"@types/socket.io-client": "^1.4.36",
|
|
45
|
+
"@types/ws": "^7.4.7",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
|
47
|
+
"@typescript-eslint/parser": "^4.32.0",
|
|
48
|
+
"autoprefixer": "^10.3.6",
|
|
49
|
+
"eslint": "^7.32.0",
|
|
50
|
+
"eslint-config-prettier": "^8.3.0",
|
|
51
|
+
"eslint-plugin-prettier": "4.0.0",
|
|
52
|
+
"postcss": "^8.3.8",
|
|
53
|
+
"postcss-load-config": "^3.1.0",
|
|
54
|
+
"prettier": "^2.4.1",
|
|
55
|
+
"typescript": "^4.4.3"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Config
|
|
2
|
+
This home automation system is configured using multiple files which are described below.
|
|
3
|
+
|
|
4
|
+
## Device Config
|
|
5
|
+
To highly decrease workload manually entering device data from ioBroker
|
|
6
|
+
you can simply download your whole object tree from within the ioBroker -> objects page.
|
|
7
|
+
|
|
8
|
+
The resulting `.json` should be placed within `.\server\config\private` folder, renamed to `devices.json`
|
|
9
|
+
|
|
10
|
+
## Main Config
|
|
11
|
+
Please place a `mainConfig.json` in the `.\server\config\private` folder.
|
|
12
|
+
|
|
13
|
+
The file should contain all the desired services, which definitions can be found within the `iConfig.ts` file.
|
|
14
|
+
|
|
15
|
+
## RoomConfig
|
|
16
|
+
Please use the `.\models\rooms\Raumdefinition.xlsm` excel sheet to
|
|
17
|
+
generate a `RoomConfig.txt`. As this needs running a specific node script
|
|
18
|
+
afterwards you should follow the steps within `.\models\rooms\readme.md`
|
|
19
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { LogLevel } from '../../models/logLevel';
|
|
2
|
+
import { iRoomDefaultSettings } from '../../models/rooms/RoomSettings/iRoomDefaultSettings';
|
|
3
|
+
|
|
4
|
+
export interface iConfig {
|
|
5
|
+
roomDefault: iRoomDefaultSettings;
|
|
6
|
+
timeSettings: iTimeSettings;
|
|
7
|
+
ioBrokerUrl: string;
|
|
8
|
+
telegram?: iTelegramSettings;
|
|
9
|
+
polly?: iPollySettings;
|
|
10
|
+
mp3Server?: iMp3Settings;
|
|
11
|
+
weather?: iWeatherSettings;
|
|
12
|
+
muell?: iMuellSettings;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface iTimePair {
|
|
16
|
+
hours: number;
|
|
17
|
+
minutes: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface iTimeSettings {
|
|
21
|
+
nightStart: iTimePair;
|
|
22
|
+
nightEnd: iTimePair;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface iTelegramSettings {
|
|
26
|
+
logLevel: LogLevel;
|
|
27
|
+
telegramToken: string;
|
|
28
|
+
allowedIDs: number[];
|
|
29
|
+
subscribedIDs: number[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface iPollySettings {
|
|
33
|
+
mp3Path: string;
|
|
34
|
+
region: string;
|
|
35
|
+
signatureVersion: string;
|
|
36
|
+
accessKeyId: string;
|
|
37
|
+
secretAccessKey: string;
|
|
38
|
+
voiceID: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface iMp3Settings {
|
|
42
|
+
path: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface iWeatherSettings {
|
|
46
|
+
lattitude: string;
|
|
47
|
+
longitude: string;
|
|
48
|
+
appid: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface iMuellSettings {
|
|
52
|
+
calendarURL: string;
|
|
53
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { deviceConfig } from '/models/deviceConfig';
|
|
2
|
+
|
|
3
|
+
export class DeviceInfo {
|
|
4
|
+
public devID: string;
|
|
5
|
+
public room: string;
|
|
6
|
+
public deviceType: string;
|
|
7
|
+
public deviceRoomIndex: number;
|
|
8
|
+
public type: 'device' | 'channel' | 'state';
|
|
9
|
+
public fullName: string;
|
|
10
|
+
private _customName?: string;
|
|
11
|
+
public fullID: string;
|
|
12
|
+
public channel?: number;
|
|
13
|
+
public valueName?: string;
|
|
14
|
+
public devConf: deviceConfig;
|
|
15
|
+
|
|
16
|
+
public constructor(pDevConf: deviceConfig) {
|
|
17
|
+
this.devConf = pDevConf;
|
|
18
|
+
this.type = pDevConf.type as 'device' | 'channel' | 'state';
|
|
19
|
+
|
|
20
|
+
this.fullID = pDevConf._id;
|
|
21
|
+
/**
|
|
22
|
+
* 0: hm-rpc
|
|
23
|
+
* 1: rcpInstance
|
|
24
|
+
* 2: Device ID
|
|
25
|
+
* 3?: Channel
|
|
26
|
+
* 4?: ValueName
|
|
27
|
+
*/
|
|
28
|
+
const idSplit: string[] = pDevConf._id.split('.');
|
|
29
|
+
this.devID = idSplit[2];
|
|
30
|
+
|
|
31
|
+
if (idSplit.length > 3) {
|
|
32
|
+
this.channel = Number(idSplit[3]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (idSplit.length > 4) {
|
|
36
|
+
this.valueName = idSplit[4];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.fullName = pDevConf.common.name;
|
|
40
|
+
/**
|
|
41
|
+
* 0: Indikator own "00"
|
|
42
|
+
* 1: "HmIP"
|
|
43
|
+
* 2: Raum
|
|
44
|
+
* 3: Was für ein Gerät
|
|
45
|
+
* 4: Index dieses Gerätes im Raum (ggf. + :Channel)
|
|
46
|
+
* 5?: Name des Wertes
|
|
47
|
+
*/
|
|
48
|
+
const nameSplit: string[] = pDevConf.common.name.split('-');
|
|
49
|
+
|
|
50
|
+
this.room = nameSplit[2];
|
|
51
|
+
this.deviceType = nameSplit[3];
|
|
52
|
+
this.deviceRoomIndex = Number(nameSplit[4].split(':')[0]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public set customName(val: string) {
|
|
56
|
+
this._customName = val;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public get customName(): string {
|
|
60
|
+
if (this._customName !== undefined) {
|
|
61
|
+
return this._customName;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return this.fullName;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Devices } from './devices';
|
|
2
|
+
import { FensterPosition } from './hmIPDevices/FensterPosition';
|
|
3
|
+
import { HmIpDeviceType } from './hmIPDevices/hmIpDeviceType';
|
|
4
|
+
import { HmIpGriff } from './hmIPDevices/hmIpGriff';
|
|
5
|
+
|
|
6
|
+
export class Griffe {
|
|
7
|
+
public static getGriffPosition(): string {
|
|
8
|
+
const griffe: HmIpGriff[] = Griffe.getAllGriffe();
|
|
9
|
+
griffe.sort((a, b): number => {
|
|
10
|
+
a.position;
|
|
11
|
+
return b.position - a.position;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const response: string[] = [`Dies sind die aktuellen Stellungen der FensterGriffe:`];
|
|
15
|
+
for (const g of griffe) {
|
|
16
|
+
response.push(`${FensterPosition[g.position]} Fenster: "${g.info.customName}"`);
|
|
17
|
+
}
|
|
18
|
+
return response.join('\n');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static getAllGriffe(): HmIpGriff[] {
|
|
22
|
+
const griffe: HmIpGriff[] = [];
|
|
23
|
+
for (const dID in Devices.hmIP) {
|
|
24
|
+
const d = Devices.hmIP[dID];
|
|
25
|
+
if (d.deviceType === HmIpDeviceType.HmIpGriff) {
|
|
26
|
+
griffe.push(d as HmIpGriff);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return griffe;
|
|
30
|
+
}
|
|
31
|
+
}
|