hoffmation-base 1.1.48 → 1.2.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/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/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 +10 -2
- 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 +14 -4
- package/lib/server/devices/zigbee/BaseDevices/zigbeeDevice.js +35 -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/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/zigbeeEuroHeater.d.ts +8 -5
- package/lib/server/devices/zigbee/zigbeeEuroHeater.js +12 -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/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 +6 -5
- package/lib/server/services/dbo/postgreSqlPersist.d.ts +6 -5
- package/lib/server/services/dbo/postgreSqlPersist.js +67 -62
- 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 +11 -11
|
@@ -6,6 +6,7 @@ const devices_1 = require("../../devices");
|
|
|
6
6
|
const pg_1 = require("pg");
|
|
7
7
|
const log_service_1 = require("../log-service");
|
|
8
8
|
const DeviceCapability_1 = require("../../devices/DeviceCapability");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
9
10
|
class PostgreSqlPersist {
|
|
10
11
|
constructor(conf) {
|
|
11
12
|
this.initialized = false;
|
|
@@ -32,24 +33,6 @@ values ('${device.id}','${device.info.room}','${device.info.allDevicesKey}','${d
|
|
|
32
33
|
"alldeviceskey" = '${device.info.allDevicesKey}',
|
|
33
34
|
"customname" = '${device.info.customName}',
|
|
34
35
|
"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
36
|
;
|
|
54
37
|
`);
|
|
55
38
|
}
|
|
@@ -169,23 +152,6 @@ BEGIN
|
|
|
169
152
|
create unique index energycalculation_startdate_uindex
|
|
170
153
|
on hoffmation_schema."EnergyCalculation" ("startDate");
|
|
171
154
|
|
|
172
|
-
END IF;
|
|
173
|
-
IF (SELECT to_regclass('hoffmation_schema."HeatGroupCollection"') IS NULL) Then
|
|
174
|
-
create table hoffmation_schema."HeatGroupCollection"
|
|
175
|
-
(
|
|
176
|
-
date timestamp,
|
|
177
|
-
humidity integer,
|
|
178
|
-
"istTemperatur" double precision,
|
|
179
|
-
level integer,
|
|
180
|
-
name varchar(60) not null
|
|
181
|
-
constraint heatgroupcollection_pk
|
|
182
|
-
primary key,
|
|
183
|
-
"sollTemperatur" double precision
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
create unique index heatgroupcollection_name_uindex
|
|
187
|
-
on hoffmation_schema."HeatGroupCollection" (name);
|
|
188
|
-
|
|
189
155
|
END IF;
|
|
190
156
|
|
|
191
157
|
IF (SELECT to_regclass('hoffmation_schema."AcDeviceData"') IS NULL) Then
|
|
@@ -259,6 +225,53 @@ BEGIN
|
|
|
259
225
|
|
|
260
226
|
END IF;
|
|
261
227
|
|
|
228
|
+
IF (SELECT to_regclass('hoffmation_schema."HumiditySensorDeviceData"') IS NULL) Then
|
|
229
|
+
create table if not exists hoffmation_schema."HumiditySensorDeviceData"
|
|
230
|
+
(
|
|
231
|
+
"deviceID" varchar(60) not null
|
|
232
|
+
constraint "HumiditySensorDeviceData_DeviceInfo_null_fk"
|
|
233
|
+
references hoffmation_schema."DeviceInfo"
|
|
234
|
+
on delete set null,
|
|
235
|
+
humidity double precision,
|
|
236
|
+
date timestamp not null,
|
|
237
|
+
constraint humiditysensordevicedata_pk
|
|
238
|
+
primary key ("deviceID", date)
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
END IF;
|
|
242
|
+
|
|
243
|
+
IF (SELECT to_regclass('hoffmation_schema."BatteryDeviceData"') IS NULL) Then
|
|
244
|
+
create table if not exists hoffmation_schema."BatteryDeviceData"
|
|
245
|
+
(
|
|
246
|
+
"deviceID" varchar(60) not null
|
|
247
|
+
constraint "BatteryDeviceData_DeviceInfo_null_fk"
|
|
248
|
+
references hoffmation_schema."DeviceInfo"
|
|
249
|
+
on delete set null,
|
|
250
|
+
battery double precision,
|
|
251
|
+
date timestamp not null,
|
|
252
|
+
constraint batterydevicedata_pk
|
|
253
|
+
primary key ("deviceID", date)
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
END IF;
|
|
257
|
+
|
|
258
|
+
IF (SELECT to_regclass('hoffmation_schema."ZigbeeDeviceData"') IS NULL) Then
|
|
259
|
+
create table if not exists hoffmation_schema."ZigbeeDeviceData"
|
|
260
|
+
(
|
|
261
|
+
"deviceID" varchar(60) not null
|
|
262
|
+
constraint "ZigbeeDeviceData_DeviceInfo_null_fk"
|
|
263
|
+
references hoffmation_schema."DeviceInfo"
|
|
264
|
+
on delete set null,
|
|
265
|
+
date timestamp not null,
|
|
266
|
+
available boolean,
|
|
267
|
+
linkQuality double precision,
|
|
268
|
+
lastUpdate timestamp,
|
|
269
|
+
constraint zigbeedevicedata_pk
|
|
270
|
+
primary key ("deviceID", date)
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
END IF;
|
|
274
|
+
|
|
262
275
|
|
|
263
276
|
|
|
264
277
|
IF (SELECT to_regclass('hoffmation_schema."HeaterDeviceData"') IS NULL) Then
|
|
@@ -277,21 +290,6 @@ BEGIN
|
|
|
277
290
|
);
|
|
278
291
|
|
|
279
292
|
END IF;
|
|
280
|
-
|
|
281
|
-
IF (SELECT to_regclass('hoffmation_schema."TemperaturData"') IS NULL) Then
|
|
282
|
-
create table hoffmation_schema."TemperaturData"
|
|
283
|
-
(
|
|
284
|
-
date timestamp,
|
|
285
|
-
humidity integer,
|
|
286
|
-
"istTemperatur" double precision,
|
|
287
|
-
level integer,
|
|
288
|
-
name text,
|
|
289
|
-
"sollTemperatur" double precision,
|
|
290
|
-
constraint temperaturdata_pk
|
|
291
|
-
unique (date, name)
|
|
292
|
-
);
|
|
293
|
-
|
|
294
|
-
END IF;
|
|
295
293
|
END
|
|
296
294
|
$$;`);
|
|
297
295
|
this.initialized = true;
|
|
@@ -355,6 +353,25 @@ values ('${device.id}', ${currentLevel}, '${new Date().toISOString()}', ${desire
|
|
|
355
353
|
this.query(`
|
|
356
354
|
insert into hoffmation_schema."TemperatureSensorDeviceData" ("deviceID", "temperature", "date", "roomTemperature")
|
|
357
355
|
values ('${device.id}', ${device.iTemperature}, '${new Date().toISOString()}', ${roomTemp !== null && roomTemp !== void 0 ? roomTemp : 'null'});
|
|
356
|
+
`);
|
|
357
|
+
}
|
|
358
|
+
persistHumiditySensor(device) {
|
|
359
|
+
this.query(`
|
|
360
|
+
insert into hoffmation_schema."HumiditySensorDeviceData" ("deviceID", "humidity", "date")
|
|
361
|
+
values ('${device.id}', ${device.humidity}, '${new Date().toISOString()}');
|
|
362
|
+
`);
|
|
363
|
+
}
|
|
364
|
+
persistBatteryDevice(device) {
|
|
365
|
+
this.query(`
|
|
366
|
+
insert into hoffmation_schema."BatteryDeviceData" ("deviceID", "battery", "date")
|
|
367
|
+
values ('${device.id}', ${utils_1.Utils.round(device.battery, 1)}, '${new Date().toISOString()}');
|
|
368
|
+
`);
|
|
369
|
+
}
|
|
370
|
+
persistZigbeeDevice(device) {
|
|
371
|
+
const dateValue = device.lastUpdate.getTime() > 0 ? device.lastUpdate.toISOString() : 'null';
|
|
372
|
+
this.query(`
|
|
373
|
+
insert into hoffmation_schema."ZigbeeDeviceData" ("deviceID", "date", "available", "linkQuality", "lastUpdate")
|
|
374
|
+
values ('${device.id}', '${new Date().toISOString()}', ${device.available}, ${device.linkQuality}, '${dateValue}');
|
|
358
375
|
`);
|
|
359
376
|
}
|
|
360
377
|
persistIlluminationSensor(device) {
|
|
@@ -365,18 +382,6 @@ values ('${device.id}', ${device.currentIllumination}, '${new Date().toISOString
|
|
|
365
382
|
persistShutterCalibration(_data) {
|
|
366
383
|
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Postgres doesn't support Shutter Calibration yet.`);
|
|
367
384
|
}
|
|
368
|
-
async readTemperaturDataPoint(heater, limit) {
|
|
369
|
-
const dbResult = await this.query(`
|
|
370
|
-
SELECT * FROM hoffmation_schema."TemperaturData"
|
|
371
|
-
WHERE name = '${heater.info.customName}'
|
|
372
|
-
ORDER BY "date" DESC
|
|
373
|
-
LIMIT ${limit}
|
|
374
|
-
`);
|
|
375
|
-
if (dbResult !== null && dbResult.length > 0) {
|
|
376
|
-
return dbResult;
|
|
377
|
-
}
|
|
378
|
-
return [];
|
|
379
|
-
}
|
|
380
385
|
persistEnergyManager(calc) {
|
|
381
386
|
this.query(`
|
|
382
387
|
insert into hoffmation_schema."EnergyCalculation" ("startDate", "endDate", "selfConsumedKwH", "injectedKwH",
|
|
@@ -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);
|