hoffmation-base 1.0.63 → 1.0.66
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/index.js +1 -4
- package/lib/models/persistence/index.d.ts +0 -1
- package/lib/models/persistence/index.js +0 -1
- package/lib/models/persistence/todaysCount.d.ts +2 -3
- package/lib/models/persistence/todaysCount.js +2 -3
- package/lib/server/config/iConfig.d.ts +0 -5
- package/lib/server/devices/baseDeviceInterfaces/iLamp.d.ts +1 -0
- package/lib/server/devices/device-cluster-type.d.ts +0 -1
- package/lib/server/devices/device-cluster-type.js +0 -1
- package/lib/server/devices/device-cluster.js +1 -3
- package/lib/server/devices/devices.d.ts +1 -1
- package/lib/server/devices/devices.js +4 -7
- package/lib/server/devices/groups/praesenzGroup.d.ts +1 -3
- package/lib/server/devices/groups/praesenzGroup.js +2 -37
- package/lib/server/devices/hmIPDevices/hmIpBewegung.js +2 -5
- package/lib/server/devices/hmIPDevices/hmIpLampe.d.ts +1 -0
- package/lib/server/devices/hmIPDevices/hmIpLampe.js +5 -0
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.d.ts +10 -5
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +21 -12
- package/lib/server/devices/zigbee/BaseDevices/ZigbeeActuator.js +3 -1
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +3 -6
- package/lib/server/devices/zigbee/zigbeeIlluDimmer.d.ts +1 -0
- package/lib/server/devices/zigbee/zigbeeIlluDimmer.js +6 -0
- package/lib/server/devices/zigbee/zigbeeIlluLampe.d.ts +1 -0
- package/lib/server/devices/zigbee/zigbeeIlluLampe.js +6 -1
- package/lib/server/services/dbo/iPersist.d.ts +3 -3
- package/lib/server/services/dbo/index.d.ts +0 -1
- package/lib/server/services/dbo/index.js +0 -1
- package/lib/server/services/dbo/postgreSqlPersist.d.ts +3 -3
- package/lib/server/services/dbo/postgreSqlPersist.js +27 -60
- package/lib/server/services/time-callback-service.js +1 -1
- package/lib/server/services/utils/utils.js +2 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/lib/models/persistence/DailyMovementCount.d.ts +0 -7
- package/lib/models/persistence/DailyMovementCount.js +0 -12
- package/lib/server/services/dbo/mongoPersistance.d.ts +0 -33
- package/lib/server/services/dbo/mongoPersistance.js +0 -174
|
@@ -38,13 +38,15 @@ values ('${new Date().toISOString()}',${heater.humidity},${heater.iTemperature},
|
|
|
38
38
|
;
|
|
39
39
|
`);
|
|
40
40
|
}
|
|
41
|
-
async
|
|
42
|
-
const dbResult = await this.query(`SELECT *
|
|
41
|
+
async motionSensorTodayCount(device) {
|
|
42
|
+
const dbResult = await this.query(`SELECT Count(*)
|
|
43
|
+
from hoffmation_schema."MotionSensorDeviceData"
|
|
44
|
+
WHERE "deviceID" = '${device.id}' and "movementDetected" and date >= CURRENT_DATE AND date < CURRENT_DATE + INTERVAL '1 DAY'`);
|
|
43
45
|
if (dbResult !== null && dbResult.length > 0) {
|
|
44
46
|
return dbResult[0];
|
|
45
47
|
}
|
|
46
|
-
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `Es gibt noch
|
|
47
|
-
return new models_1.CountToday(
|
|
48
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `Es gibt noch keine persistierten Bewegungen für ${device.info.fullName}`);
|
|
49
|
+
return new models_1.CountToday(0);
|
|
48
50
|
}
|
|
49
51
|
getShutterCalibration(_device) {
|
|
50
52
|
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Postgres doesn't support Shutter Calibration yet.`);
|
|
@@ -88,25 +90,6 @@ create table "CurrentIllumination"
|
|
|
88
90
|
|
|
89
91
|
alter table "CurrentIllumination"
|
|
90
92
|
owner to postgres;
|
|
91
|
-
END IF;
|
|
92
|
-
IF (SELECT to_regclass('hoffmation_schema."DailyMovementCount"') IS NULL) Then
|
|
93
|
-
-- auto-generated definition
|
|
94
|
-
create table "DailyMovementCount"
|
|
95
|
-
(
|
|
96
|
-
counter integer,
|
|
97
|
-
date timestamp not null,
|
|
98
|
-
"deviceID" varchar(60) not null,
|
|
99
|
-
"roomName" varchar(30) not null
|
|
100
|
-
constraint dailymovementcount_basicrooms_name_fk
|
|
101
|
-
references hoffmation_schema."BasicRooms",
|
|
102
|
-
constraint dailymovementcount_pk
|
|
103
|
-
primary key (date, "deviceID")
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
alter table "DailyMovementCount"
|
|
107
|
-
owner to postgres;
|
|
108
|
-
|
|
109
|
-
|
|
110
93
|
END IF;
|
|
111
94
|
IF (SELECT to_regclass('hoffmation_schema."EnergyCalculation"') IS NULL) Then
|
|
112
95
|
create table "EnergyCalculation"
|
|
@@ -147,21 +130,6 @@ create unique index heatgroupcollection_name_uindex
|
|
|
147
130
|
on "HeatGroupCollection" (name);
|
|
148
131
|
|
|
149
132
|
END IF;
|
|
150
|
-
IF (SELECT to_regclass('hoffmation_schema."PresenceToday"') IS NULL) Then
|
|
151
|
-
create table "PresenceToday"
|
|
152
|
-
(
|
|
153
|
-
counter integer,
|
|
154
|
-
"deviceID" varchar(60) not null
|
|
155
|
-
constraint presencetoday_pk
|
|
156
|
-
primary key
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
alter table "PresenceToday"
|
|
160
|
-
owner to postgres;
|
|
161
|
-
|
|
162
|
-
create unique index presencetoday_deviceid_uindex
|
|
163
|
-
on "PresenceToday" ("deviceID");
|
|
164
|
-
END IF;
|
|
165
133
|
|
|
166
134
|
IF (SELECT to_regclass('hoffmation_schema."AcDeviceData"') IS NULL) Then
|
|
167
135
|
create table hoffmation_schema."AcDeviceData"
|
|
@@ -178,6 +146,21 @@ IF (SELECT to_regclass('hoffmation_schema."AcDeviceData"') IS NULL) Then
|
|
|
178
146
|
owner to postgres;
|
|
179
147
|
END IF;
|
|
180
148
|
|
|
149
|
+
|
|
150
|
+
IF (SELECT to_regclass('hoffmation_schema."LampDeviceData"') IS NULL) Then
|
|
151
|
+
create table hoffmation_schema."LampDeviceData"
|
|
152
|
+
(
|
|
153
|
+
"deviceID" varchar(60) not null,
|
|
154
|
+
"on" boolean,
|
|
155
|
+
date timestamp not null,
|
|
156
|
+
constraint lampdevicedata_pk
|
|
157
|
+
primary key ("deviceID", date)
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
alter table hoffmation_schema."LampDeviceData"
|
|
161
|
+
owner to postgres;
|
|
162
|
+
END IF;
|
|
163
|
+
|
|
181
164
|
IF (SELECT to_regclass('hoffmation_schema."MotionSensorDeviceData"') IS NULL) Then
|
|
182
165
|
create table hoffmation_schema."MotionSensorDeviceData"
|
|
183
166
|
(
|
|
@@ -217,6 +200,12 @@ $$;`);
|
|
|
217
200
|
this.query(`
|
|
218
201
|
insert into hoffmation_schema."AcDeviceData" ("deviceID", "on", "date", "roomTemperature")
|
|
219
202
|
values ('${device.id}', ${device.on}, '${new Date().toISOString()}', ${device.temperature});
|
|
203
|
+
`);
|
|
204
|
+
}
|
|
205
|
+
persistLamp(device) {
|
|
206
|
+
this.query(`
|
|
207
|
+
insert into hoffmation_schema."LampDeviceData" ("deviceID", "on", "date")
|
|
208
|
+
values ('${device.id}', ${device.lightOn}, '${new Date().toISOString()}');
|
|
220
209
|
`);
|
|
221
210
|
}
|
|
222
211
|
persistMotionSensor(device) {
|
|
@@ -234,28 +223,6 @@ values ('${data.roomName}','${data.deviceID}',${data.currentIllumination},'${dat
|
|
|
234
223
|
persistShutterCalibration(_data) {
|
|
235
224
|
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Postgres doesn't support Shutter Calibration yet.`);
|
|
236
225
|
}
|
|
237
|
-
persistTodayCount(device, count, oldCount) {
|
|
238
|
-
this.query(`
|
|
239
|
-
insert into hoffmation_schema."PresenceToday" (counter, "deviceID")
|
|
240
|
-
values (${count}, '${device.id}')
|
|
241
|
-
ON CONFLICT ("deviceID")
|
|
242
|
-
DO UPDATE SET
|
|
243
|
-
counter = ${count}
|
|
244
|
-
;
|
|
245
|
-
`);
|
|
246
|
-
if (count === 0) {
|
|
247
|
-
const date = new Date();
|
|
248
|
-
date.setHours(-24, 0, 0, 0);
|
|
249
|
-
this.query(`
|
|
250
|
-
insert into hoffmation_schema."DailyMovementCount" (counter, "date", "deviceID", "roomName")
|
|
251
|
-
values (${oldCount}, '${date.toISOString()}', '${device.id}', '${device.info.room}')
|
|
252
|
-
ON CONFLICT ("deviceID", "date")
|
|
253
|
-
DO UPDATE SET
|
|
254
|
-
counter = ${oldCount}
|
|
255
|
-
;
|
|
256
|
-
`);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
226
|
async readTemperaturDataPoint(heater, limit) {
|
|
260
227
|
const dbResult = await this.query(`
|
|
261
228
|
SELECT * FROM hoffmation_schema."TemperaturData"
|
|
@@ -110,7 +110,7 @@ class TimeCallbackService {
|
|
|
110
110
|
devices_1.Devices.midnightReset();
|
|
111
111
|
}, 0, 0, 0);
|
|
112
112
|
const daily3oClockRecalc = new models_1.TimeCallback('Daily3oClockRecalc', models_1.TimeCallbackType.TimeOfDay, () => {
|
|
113
|
-
devices_1.Devices.
|
|
113
|
+
devices_1.Devices.resetDetectionsToday();
|
|
114
114
|
}, 0, 3, 0);
|
|
115
115
|
TimeCallbackService.recalcSunTimes();
|
|
116
116
|
TimeCallbackService.addCallback(dailyRecalc);
|
|
@@ -12,9 +12,8 @@ const settings_service_1 = require("../settings-service");
|
|
|
12
12
|
exports.DAYMS = 24 * 60 * 60 * 1000;
|
|
13
13
|
class Utils {
|
|
14
14
|
static get anyDboActive() {
|
|
15
|
-
var _a
|
|
16
|
-
return ((
|
|
17
|
-
((_b = settings_service_1.SettingsService.settings.persistence) === null || _b === void 0 ? void 0 : _b.postgreSql) !== undefined);
|
|
15
|
+
var _a;
|
|
16
|
+
return ((_a = settings_service_1.SettingsService.settings.persistence) === null || _a === void 0 ? void 0 : _a.postgreSql) !== undefined;
|
|
18
17
|
}
|
|
19
18
|
static get timeTilMidnight() {
|
|
20
19
|
return new Date(Utils.nowMS() + exports.DAYMS).setHours(0, 0, 0, 0) - Utils.nowMS();
|