hoffmation-base 1.1.46 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/models/persistence/index.d.ts +0 -1
- package/lib/models/persistence/index.js +0 -1
- package/lib/server/devices/Heizgruppen.d.ts +0 -1
- package/lib/server/devices/Heizgruppen.js +0 -20
- package/lib/server/devices/baseDeviceInterfaces/iBatteryDevice.d.ts +2 -1
- package/lib/server/devices/baseDeviceInterfaces/iHumiditySensor.d.ts +4 -1
- package/lib/server/devices/baseDeviceInterfaces/iIlluminationSensor.d.ts +2 -1
- package/lib/server/devices/hmIPDevices/hmIpBewegung.js +2 -2
- package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +6 -2
- package/lib/server/devices/hmIPDevices/hmIpGriff.js +18 -3
- package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.d.ts +5 -1
- package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.js +24 -4
- package/lib/server/devices/hmIPDevices/hmIpHeizung.d.ts +3 -1
- package/lib/server/devices/hmIPDevices/hmIpHeizung.js +11 -2
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.d.ts +3 -1
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +12 -4
- package/lib/server/devices/hmIPDevices/hmIpTaster.d.ts +3 -1
- package/lib/server/devices/hmIPDevices/hmIpTaster.js +10 -2
- package/lib/server/devices/hmIPDevices/hmIpTherm.d.ts +3 -1
- package/lib/server/devices/hmIPDevices/hmIpTherm.js +11 -2
- package/lib/server/devices/hmIPDevices/hmIpTuer.d.ts +3 -1
- package/lib/server/devices/hmIPDevices/hmIpTuer.js +6 -0
- package/lib/server/devices/jsObject/jsObjectEnergyManager.d.ts +3 -1
- package/lib/server/devices/jsObject/jsObjectEnergyManager.js +10 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeDevice.d.ts +12 -4
- package/lib/server/devices/zigbee/BaseDevices/zigbeeDevice.js +31 -11
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.d.ts +4 -1
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.js +21 -6
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.d.ts +4 -1
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.js +18 -3
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.d.ts +3 -1
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +11 -3
- package/lib/server/devices/zigbee/zigbeeAquaraMotion.js +2 -2
- package/lib/server/devices/zigbee/zigbeeAquaraVibra.d.ts +3 -1
- package/lib/server/devices/zigbee/zigbeeAquaraVibra.js +11 -3
- package/lib/server/devices/zigbee/zigbeeAquaraWater.d.ts +4 -1
- package/lib/server/devices/zigbee/zigbeeAquaraWater.js +18 -3
- package/lib/server/devices/zigbee/zigbeeHeimanSmoke.d.ts +4 -1
- package/lib/server/devices/zigbee/zigbeeHeimanSmoke.js +18 -3
- package/lib/server/devices/zigbee/zigbeeOsramDimmer.js +1 -1
- package/lib/server/devices/zigbee/zigbeeSonoffTemp.d.ts +6 -1
- package/lib/server/devices/zigbee/zigbeeSonoffTemp.js +27 -3
- package/lib/server/ioBroker/connection.d.ts +3 -1
- package/lib/server/ioBroker/connection.js +10 -0
- package/lib/server/services/Telegram/telegram-Commands.js +0 -6
- package/lib/server/services/dbo/iPersist.d.ts +7 -6
- package/lib/server/services/dbo/postgreSqlPersist.d.ts +7 -6
- package/lib/server/services/dbo/postgreSqlPersist.js +79 -74
- package/lib/server/services/time-callback-service.js +2 -2
- package/lib/server/services/utils/iDisposeable.d.ts +3 -0
- package/lib/server/services/utils/iDisposeable.js +2 -0
- package/lib/server/services/utils/index.d.ts +1 -0
- package/lib/server/services/utils/index.js +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/lib/models/persistence/CurrentIlluminationDataPoint.d.ts +0 -8
- package/lib/models/persistence/CurrentIlluminationDataPoint.js +0 -13
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { ButtonPressType, iAcDevice, iActuator, iBaseDevice, iButtonSwitch, iHeater,
|
|
2
|
-
import { CountToday,
|
|
1
|
+
import { ButtonPressType, iAcDevice, iActuator, iBaseDevice, iBatteryDevice, iButtonSwitch, iHeater, iHumiditySensor, iIlluminationSensor, iMotionSensor, iShutter, iTemperatureSensor, ZigbeeDevice } from '../../devices';
|
|
2
|
+
import { CountToday, DesiredShutterPosition, EnergyCalculation, RoomBase, ShutterCalibration } from '../../../models';
|
|
3
3
|
export interface iPersist {
|
|
4
4
|
initialized: boolean;
|
|
5
|
-
addTemperaturDataPoint(heater: iHeater): void;
|
|
6
5
|
addRoom(room: RoomBase): void;
|
|
7
6
|
addDevice(device: iBaseDevice): void;
|
|
8
7
|
motionSensorTodayCount(device: iMotionSensor): Promise<CountToday>;
|
|
9
8
|
getLastDesiredPosition(device: iShutter): Promise<DesiredShutterPosition>;
|
|
10
|
-
getShutterCalibration(device:
|
|
9
|
+
getShutterCalibration(device: iShutter): Promise<ShutterCalibration>;
|
|
11
10
|
initialize(): Promise<void>;
|
|
12
11
|
persistShutterCalibration(data: ShutterCalibration): void;
|
|
13
|
-
|
|
12
|
+
persistIlluminationSensor(device: iIlluminationSensor): void;
|
|
14
13
|
persistEnergyManager(energyData: EnergyCalculation): void;
|
|
15
14
|
persistAC(device: iAcDevice): void;
|
|
16
15
|
persistActuator(device: iActuator): void;
|
|
@@ -19,5 +18,7 @@ export interface iPersist {
|
|
|
19
18
|
persistSwitchInput(device: iButtonSwitch, pressType: ButtonPressType, buttonName: string): void;
|
|
20
19
|
persistShutter(device: iShutter): void;
|
|
21
20
|
persistTemperatureSensor(device: iTemperatureSensor): void;
|
|
22
|
-
|
|
21
|
+
persistHumiditySensor(device: iHumiditySensor): void;
|
|
22
|
+
persistBatteryDevice(device: iBatteryDevice): void;
|
|
23
|
+
persistZigbeeDevice(device: ZigbeeDevice): void;
|
|
23
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { iPersist } from './iPersist';
|
|
2
|
-
import { CountToday,
|
|
3
|
-
import { ButtonPressType, iAcDevice, iActuator, iBaseDevice, iButtonSwitch, iHeater,
|
|
2
|
+
import { CountToday, DesiredShutterPosition, EnergyCalculation, RoomBase, ShutterCalibration } from '../../../models';
|
|
3
|
+
import { ButtonPressType, iAcDevice, iActuator, iBaseDevice, iBatteryDevice, iButtonSwitch, iHeater, iHumiditySensor, iIlluminationSensor, iMotionSensor, iShutter, iTemperatureSensor, ZigbeeDevice } from '../../devices';
|
|
4
4
|
import { PoolConfig } from 'pg';
|
|
5
5
|
export declare class PostgreSqlPersist implements iPersist {
|
|
6
6
|
initialized: boolean;
|
|
@@ -9,10 +9,9 @@ export declare class PostgreSqlPersist implements iPersist {
|
|
|
9
9
|
constructor(conf: PoolConfig);
|
|
10
10
|
addRoom(room: RoomBase): void;
|
|
11
11
|
addDevice(device: iBaseDevice): void;
|
|
12
|
-
addTemperaturDataPoint(heater: iHeater): void;
|
|
13
12
|
getLastDesiredPosition(device: iShutter): Promise<DesiredShutterPosition>;
|
|
14
13
|
motionSensorTodayCount(device: iMotionSensor): Promise<CountToday>;
|
|
15
|
-
getShutterCalibration(_device:
|
|
14
|
+
getShutterCalibration(_device: iShutter): Promise<ShutterCalibration>;
|
|
16
15
|
initialize(): Promise<void>;
|
|
17
16
|
persistAC(device: iAcDevice): void;
|
|
18
17
|
persistActuator(device: iActuator): void;
|
|
@@ -21,9 +20,11 @@ export declare class PostgreSqlPersist implements iPersist {
|
|
|
21
20
|
persistMotionSensor(device: iMotionSensor): void;
|
|
22
21
|
persistShutter(device: iShutter): void;
|
|
23
22
|
persistTemperatureSensor(device: iTemperatureSensor): void;
|
|
24
|
-
|
|
23
|
+
persistHumiditySensor(device: iHumiditySensor): void;
|
|
24
|
+
persistBatteryDevice(device: iBatteryDevice): void;
|
|
25
|
+
persistZigbeeDevice(device: ZigbeeDevice): void;
|
|
26
|
+
persistIlluminationSensor(device: iIlluminationSensor): void;
|
|
25
27
|
persistShutterCalibration(_data: ShutterCalibration): void;
|
|
26
|
-
readTemperaturDataPoint(heater: iHeater, limit: number): Promise<TemperaturDataPoint[]>;
|
|
27
28
|
persistEnergyManager(calc: EnergyCalculation): void;
|
|
28
29
|
private query;
|
|
29
30
|
private isPsqlReady;
|
|
@@ -32,24 +32,6 @@ values ('${device.id}','${device.info.room}','${device.info.allDevicesKey}','${d
|
|
|
32
32
|
"alldeviceskey" = '${device.info.allDevicesKey}',
|
|
33
33
|
"customname" = '${device.info.customName}',
|
|
34
34
|
"devtype" = ${device.deviceType}
|
|
35
|
-
;
|
|
36
|
-
`);
|
|
37
|
-
}
|
|
38
|
-
addTemperaturDataPoint(heater) {
|
|
39
|
-
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Trace, `Persisting Temperatur Data for ${heater.info.customName}`);
|
|
40
|
-
this.query(`
|
|
41
|
-
insert into hoffmation_schema."TemperaturData" ("date", "humidity", "istTemperatur", "level", "name", "sollTemperatur")
|
|
42
|
-
values ('${new Date().toISOString()}',${heater.humidity},${heater.iTemperature},${heater.iLevel / 100},'${heater.info.customName}',${heater.desiredTemperature});`);
|
|
43
|
-
this.query(`
|
|
44
|
-
insert into hoffmation_schema."HeatGroupCollection" ("date", "humidity", "istTemperatur", "level", "name", "sollTemperatur")
|
|
45
|
-
values ('${new Date().toISOString()}',${heater.humidity},${heater.iTemperature},${heater.iLevel},'${heater.info.customName}',${heater.desiredTemperature})
|
|
46
|
-
ON CONFLICT (name)
|
|
47
|
-
DO UPDATE SET
|
|
48
|
-
"date" = '${new Date().toISOString()}',
|
|
49
|
-
"humidity" = ${heater.humidity},
|
|
50
|
-
"istTemperatur" = ${heater.iTemperature},
|
|
51
|
-
"level" = ${heater.iLevel},
|
|
52
|
-
"sollTemperatur" = ${heater.desiredTemperature}
|
|
53
35
|
;
|
|
54
36
|
`);
|
|
55
37
|
}
|
|
@@ -122,16 +104,17 @@ BEGIN
|
|
|
122
104
|
|
|
123
105
|
END IF;
|
|
124
106
|
|
|
125
|
-
IF (SELECT to_regclass('hoffmation_schema."
|
|
126
|
-
create table hoffmation_schema."
|
|
107
|
+
IF (SELECT to_regclass('hoffmation_schema."IlluminationSensorDeviceData"') IS NULL) Then
|
|
108
|
+
create table hoffmation_schema."IlluminationSensorDeviceData"
|
|
127
109
|
(
|
|
128
|
-
"
|
|
129
|
-
constraint
|
|
130
|
-
references hoffmation_schema."
|
|
131
|
-
|
|
132
|
-
"
|
|
133
|
-
date
|
|
134
|
-
|
|
110
|
+
"deviceID" varchar(60) not null
|
|
111
|
+
constraint "IlluminationSensorDeviceData_DeviceInfo_null_fk"
|
|
112
|
+
references hoffmation_schema."DeviceInfo"
|
|
113
|
+
on delete set null,
|
|
114
|
+
"illumination" int,
|
|
115
|
+
date timestamp not null,
|
|
116
|
+
constraint IlluminationSensorDeviceData_pk
|
|
117
|
+
primary key ("deviceID", date)
|
|
135
118
|
);
|
|
136
119
|
|
|
137
120
|
END IF;
|
|
@@ -168,23 +151,6 @@ BEGIN
|
|
|
168
151
|
create unique index energycalculation_startdate_uindex
|
|
169
152
|
on hoffmation_schema."EnergyCalculation" ("startDate");
|
|
170
153
|
|
|
171
|
-
END IF;
|
|
172
|
-
IF (SELECT to_regclass('hoffmation_schema."HeatGroupCollection"') IS NULL) Then
|
|
173
|
-
create table hoffmation_schema."HeatGroupCollection"
|
|
174
|
-
(
|
|
175
|
-
date timestamp,
|
|
176
|
-
humidity integer,
|
|
177
|
-
"istTemperatur" double precision,
|
|
178
|
-
level integer,
|
|
179
|
-
name varchar(60) not null
|
|
180
|
-
constraint heatgroupcollection_pk
|
|
181
|
-
primary key,
|
|
182
|
-
"sollTemperatur" double precision
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
create unique index heatgroupcollection_name_uindex
|
|
186
|
-
on hoffmation_schema."HeatGroupCollection" (name);
|
|
187
|
-
|
|
188
154
|
END IF;
|
|
189
155
|
|
|
190
156
|
IF (SELECT to_regclass('hoffmation_schema."AcDeviceData"') IS NULL) Then
|
|
@@ -207,6 +173,7 @@ BEGIN
|
|
|
207
173
|
"deviceID" varchar(60) not null,
|
|
208
174
|
"on" boolean,
|
|
209
175
|
date timestamp not null,
|
|
176
|
+
percentage integer,
|
|
210
177
|
constraint ActuatorDeviceData_pk
|
|
211
178
|
primary key ("deviceID", date)
|
|
212
179
|
);
|
|
@@ -257,6 +224,53 @@ BEGIN
|
|
|
257
224
|
|
|
258
225
|
END IF;
|
|
259
226
|
|
|
227
|
+
IF (SELECT to_regclass('hoffmation_schema."HumiditySensorDeviceData"') IS NULL) Then
|
|
228
|
+
create table if not exists hoffmation_schema."HumiditySensorDeviceData"
|
|
229
|
+
(
|
|
230
|
+
"deviceID" varchar(60) not null
|
|
231
|
+
constraint "HumiditySensorDeviceData_DeviceInfo_null_fk"
|
|
232
|
+
references hoffmation_schema."DeviceInfo"
|
|
233
|
+
on delete set null,
|
|
234
|
+
humidity double precision,
|
|
235
|
+
date timestamp not null,
|
|
236
|
+
constraint humiditysensordevicedata_pk
|
|
237
|
+
primary key ("deviceID", date)
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
END IF;
|
|
241
|
+
|
|
242
|
+
IF (SELECT to_regclass('hoffmation_schema."BatteryDeviceData"') IS NULL) Then
|
|
243
|
+
create table if not exists hoffmation_schema."BatteryDeviceData"
|
|
244
|
+
(
|
|
245
|
+
"deviceID" varchar(60) not null
|
|
246
|
+
constraint "BatteryDeviceData_DeviceInfo_null_fk"
|
|
247
|
+
references hoffmation_schema."DeviceInfo"
|
|
248
|
+
on delete set null,
|
|
249
|
+
battery double precision,
|
|
250
|
+
date timestamp not null,
|
|
251
|
+
constraint batterydevicedata_pk
|
|
252
|
+
primary key ("deviceID", date)
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
END IF;
|
|
256
|
+
|
|
257
|
+
IF (SELECT to_regclass('hoffmation_schema."ZigbeeDeviceData"') IS NULL) Then
|
|
258
|
+
create table if not exists hoffmation_schema."ZigbeeDeviceData"
|
|
259
|
+
(
|
|
260
|
+
"deviceID" varchar(60) not null
|
|
261
|
+
constraint "ZigbeeDeviceData_DeviceInfo_null_fk"
|
|
262
|
+
references hoffmation_schema."DeviceInfo"
|
|
263
|
+
on delete set null,
|
|
264
|
+
date timestamp not null,
|
|
265
|
+
available boolean,
|
|
266
|
+
linkQuality double precision,
|
|
267
|
+
lastUpdate timestamp,
|
|
268
|
+
constraint zigbeedevicedata_pk
|
|
269
|
+
primary key ("deviceID", date)
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
END IF;
|
|
273
|
+
|
|
260
274
|
|
|
261
275
|
|
|
262
276
|
IF (SELECT to_regclass('hoffmation_schema."HeaterDeviceData"') IS NULL) Then
|
|
@@ -275,21 +289,6 @@ BEGIN
|
|
|
275
289
|
);
|
|
276
290
|
|
|
277
291
|
END IF;
|
|
278
|
-
|
|
279
|
-
IF (SELECT to_regclass('hoffmation_schema."TemperaturData"') IS NULL) Then
|
|
280
|
-
create table hoffmation_schema."TemperaturData"
|
|
281
|
-
(
|
|
282
|
-
date timestamp,
|
|
283
|
-
humidity integer,
|
|
284
|
-
"istTemperatur" double precision,
|
|
285
|
-
level integer,
|
|
286
|
-
name text,
|
|
287
|
-
"sollTemperatur" double precision,
|
|
288
|
-
constraint temperaturdata_pk
|
|
289
|
-
unique (date, name)
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
END IF;
|
|
293
292
|
END
|
|
294
293
|
$$;`);
|
|
295
294
|
this.initialized = true;
|
|
@@ -355,26 +354,32 @@ insert into hoffmation_schema."TemperatureSensorDeviceData" ("deviceID", "temper
|
|
|
355
354
|
values ('${device.id}', ${device.iTemperature}, '${new Date().toISOString()}', ${roomTemp !== null && roomTemp !== void 0 ? roomTemp : 'null'});
|
|
356
355
|
`);
|
|
357
356
|
}
|
|
358
|
-
|
|
357
|
+
persistHumiditySensor(device) {
|
|
359
358
|
this.query(`
|
|
360
|
-
insert into hoffmation_schema."
|
|
361
|
-
values ('${
|
|
359
|
+
insert into hoffmation_schema."HumiditySensorDeviceData" ("deviceID", "humidity", "date")
|
|
360
|
+
values ('${device.id}', ${device.humidity}, '${new Date().toISOString()}');
|
|
362
361
|
`);
|
|
363
362
|
}
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
persistBatteryDevice(device) {
|
|
364
|
+
this.query(`
|
|
365
|
+
insert into hoffmation_schema."BatteryDeviceData" ("deviceID", "battery", "date")
|
|
366
|
+
values ('${device.id}', ${device.battery}, '${new Date().toISOString()}');
|
|
367
|
+
`);
|
|
366
368
|
}
|
|
367
|
-
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
LIMIT ${limit}
|
|
369
|
+
persistZigbeeDevice(device) {
|
|
370
|
+
const dateValue = device.lastUpdate.getTime() > 0 ? device.lastUpdate.toISOString() : 'null';
|
|
371
|
+
this.query(`
|
|
372
|
+
insert into hoffmation_schema."ZigbeeDeviceData" ("deviceID", "date", "available", "linkQuality", "lastUpdate")
|
|
373
|
+
values ('${device.id}', '${new Date().toISOString()}', ${device.available}, ${device.linkQuality}, '${dateValue}');
|
|
373
374
|
`);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
375
|
+
}
|
|
376
|
+
persistIlluminationSensor(device) {
|
|
377
|
+
this.query(`
|
|
378
|
+
insert into hoffmation_schema."IlluminationSensorDeviceData" ("deviceID", "illumination", "date")
|
|
379
|
+
values ('${device.id}', ${device.currentIllumination}, '${new Date().toISOString()}');`);
|
|
380
|
+
}
|
|
381
|
+
persistShutterCalibration(_data) {
|
|
382
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Postgres doesn't support Shutter Calibration yet.`);
|
|
378
383
|
}
|
|
379
384
|
persistEnergyManager(calc) {
|
|
380
385
|
this.query(`
|
|
@@ -62,7 +62,7 @@ class TimeCallbackService {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
let sunset = new Date(TimeCallbackService._todaySunSet.getTime() + pOffset.sunset * 60 * 1000);
|
|
65
|
-
const maximumSunset = pOffset.getNextMaximumSunset();
|
|
65
|
+
const maximumSunset = pOffset.getNextMaximumSunset(now);
|
|
66
66
|
if (maximumSunset.getDate() !== sunset.getDate()) {
|
|
67
67
|
maximumSunset.setDate(maximumSunset.getDate() - 1);
|
|
68
68
|
}
|
|
@@ -73,7 +73,7 @@ class TimeCallbackService {
|
|
|
73
73
|
if (now > sunset) {
|
|
74
74
|
return models_1.TimeOfDay.AfterSunset;
|
|
75
75
|
}
|
|
76
|
-
const minimumSunrise = pOffset.getNextMinimumSunrise();
|
|
76
|
+
const minimumSunrise = pOffset.getNextMinimumSunrise(now);
|
|
77
77
|
let sunrise = new Date(TimeCallbackService._todaySunRise.getTime() + pOffset.sunrise * 60 * 1000);
|
|
78
78
|
if (minimumSunrise.getDate() !== sunrise.getDate()) {
|
|
79
79
|
minimumSunrise.setDate(minimumSunrise.getDate() - 1);
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ringstorage"), exports);
|
|
18
18
|
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./iDisposeable"), exports);
|