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.
Files changed (38) hide show
  1. package/lib/index.js +1 -4
  2. package/lib/models/persistence/index.d.ts +0 -1
  3. package/lib/models/persistence/index.js +0 -1
  4. package/lib/models/persistence/todaysCount.d.ts +2 -3
  5. package/lib/models/persistence/todaysCount.js +2 -3
  6. package/lib/server/config/iConfig.d.ts +0 -5
  7. package/lib/server/devices/baseDeviceInterfaces/iLamp.d.ts +1 -0
  8. package/lib/server/devices/device-cluster-type.d.ts +0 -1
  9. package/lib/server/devices/device-cluster-type.js +0 -1
  10. package/lib/server/devices/device-cluster.js +1 -3
  11. package/lib/server/devices/devices.d.ts +1 -1
  12. package/lib/server/devices/devices.js +4 -7
  13. package/lib/server/devices/groups/praesenzGroup.d.ts +1 -3
  14. package/lib/server/devices/groups/praesenzGroup.js +2 -37
  15. package/lib/server/devices/hmIPDevices/hmIpBewegung.js +2 -5
  16. package/lib/server/devices/hmIPDevices/hmIpLampe.d.ts +1 -0
  17. package/lib/server/devices/hmIPDevices/hmIpLampe.js +5 -0
  18. package/lib/server/devices/hmIPDevices/hmIpPraezenz.d.ts +10 -5
  19. package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +21 -12
  20. package/lib/server/devices/zigbee/BaseDevices/ZigbeeActuator.js +3 -1
  21. package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +3 -6
  22. package/lib/server/devices/zigbee/zigbeeIlluDimmer.d.ts +1 -0
  23. package/lib/server/devices/zigbee/zigbeeIlluDimmer.js +6 -0
  24. package/lib/server/devices/zigbee/zigbeeIlluLampe.d.ts +1 -0
  25. package/lib/server/devices/zigbee/zigbeeIlluLampe.js +6 -1
  26. package/lib/server/services/dbo/iPersist.d.ts +3 -3
  27. package/lib/server/services/dbo/index.d.ts +0 -1
  28. package/lib/server/services/dbo/index.js +0 -1
  29. package/lib/server/services/dbo/postgreSqlPersist.d.ts +3 -3
  30. package/lib/server/services/dbo/postgreSqlPersist.js +27 -60
  31. package/lib/server/services/time-callback-service.js +1 -1
  32. package/lib/server/services/utils/utils.js +2 -3
  33. package/lib/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +2 -2
  35. package/lib/models/persistence/DailyMovementCount.d.ts +0 -7
  36. package/lib/models/persistence/DailyMovementCount.js +0 -12
  37. package/lib/server/services/dbo/mongoPersistance.d.ts +0 -33
  38. package/lib/server/services/dbo/mongoPersistance.js +0 -174
package/lib/index.js CHANGED
@@ -36,10 +36,7 @@ class HoffmationBase {
36
36
  }
37
37
  server_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Hoffmation-Base Startup`);
38
38
  if (initObject.config.persistence) {
39
- if (initObject.config.persistence.mongo) {
40
- server_1.Utils.dbo = new server_1.MongoPersistance(initObject.config.persistence);
41
- }
42
- else if (initObject.config.persistence.postgreSql) {
39
+ if (initObject.config.persistence.postgreSql) {
43
40
  server_1.Utils.dbo = new server_1.PostgreSqlPersist(initObject.config.persistence);
44
41
  }
45
42
  await ((_a = server_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.initialize());
@@ -1,6 +1,5 @@
1
1
  export * from './BasicRoomInfo';
2
2
  export * from './CurrentIlluminationDataPoint';
3
- export * from './DailyMovementCount';
4
3
  export * from './EnergyCalculation';
5
4
  export * from './RoomDetailInfo';
6
5
  export * from './ShutterCalibration';
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BasicRoomInfo"), exports);
18
18
  __exportStar(require("./CurrentIlluminationDataPoint"), exports);
19
- __exportStar(require("./DailyMovementCount"), exports);
20
19
  __exportStar(require("./EnergyCalculation"), exports);
21
20
  __exportStar(require("./RoomDetailInfo"), exports);
22
21
  __exportStar(require("./ShutterCalibration"), exports);
@@ -1,5 +1,4 @@
1
1
  export declare class CountToday {
2
- deviceID: string;
3
- counter: number;
4
- constructor(deviceID: string, counter: number);
2
+ count: number;
3
+ constructor(count: number);
5
4
  }
@@ -2,9 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CountToday = void 0;
4
4
  class CountToday {
5
- constructor(deviceID, counter) {
6
- this.deviceID = deviceID;
7
- this.counter = counter;
5
+ constructor(count) {
6
+ this.count = count;
8
7
  }
9
8
  }
10
9
  exports.CountToday = CountToday;
@@ -76,13 +76,8 @@ export interface iTelegramSettings {
76
76
  subscribedIDs: number[];
77
77
  }
78
78
  export interface iPersistenceSettings {
79
- mongo?: iMongoSettings;
80
79
  postgreSql?: PoolConfig;
81
80
  }
82
- export interface iMongoSettings {
83
- mongoConnection: string;
84
- mongoDbName: string;
85
- }
86
81
  export interface iPollySettings {
87
82
  mp3Path: string;
88
83
  region: string;
@@ -3,6 +3,7 @@ import { iRoomDevice } from './iRoomDevice';
3
3
  export interface iLamp extends iRoomDevice {
4
4
  settings: ActuatorSettings;
5
5
  lightOn: boolean;
6
+ persist(): void;
6
7
  setTimeBased(time: TimeOfDay, timeout: number, force: boolean): void;
7
8
  toggleLight(time: TimeOfDay, force: boolean, calculateTime: boolean): void;
8
9
  /**
@@ -6,7 +6,6 @@ export declare enum DeviceClusterType {
6
6
  Lamps = 4,
7
7
  MotionDetection = 5,
8
8
  Outlets = 6,
9
- PresenceDetection = 7,
10
9
  Speaker = 8,
11
10
  SmokeDetector = 9,
12
11
  WaterDetectors = 10,
@@ -10,7 +10,6 @@ var DeviceClusterType;
10
10
  DeviceClusterType[DeviceClusterType["Lamps"] = 4] = "Lamps";
11
11
  DeviceClusterType[DeviceClusterType["MotionDetection"] = 5] = "MotionDetection";
12
12
  DeviceClusterType[DeviceClusterType["Outlets"] = 6] = "Outlets";
13
- DeviceClusterType[DeviceClusterType["PresenceDetection"] = 7] = "PresenceDetection";
14
13
  DeviceClusterType[DeviceClusterType["Speaker"] = 8] = "Speaker";
15
14
  DeviceClusterType[DeviceClusterType["SmokeDetector"] = 9] = "SmokeDetector";
16
15
  DeviceClusterType[DeviceClusterType["WaterDetectors"] = 10] = "WaterDetectors";
@@ -48,9 +48,6 @@ class DeviceCluster {
48
48
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.TemperaturSensor);
49
49
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.HumiditySensor);
50
50
  break;
51
- case deviceType_1.DeviceType.HmIpPraezenz:
52
- clusterTypes.push(device_cluster_type_1.DeviceClusterType.PresenceDetection);
53
- break;
54
51
  case deviceType_1.DeviceType.HmIpGriff:
55
52
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.Handle);
56
53
  break;
@@ -67,6 +64,7 @@ class DeviceCluster {
67
64
  case deviceType_1.DeviceType.HmIpBewegung:
68
65
  case deviceType_1.DeviceType.ZigbeeAquaraMotion:
69
66
  case deviceType_1.DeviceType.ZigbeeSonoffMotion:
67
+ case deviceType_1.DeviceType.HmIpPraezenz:
70
68
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.MotionDetection);
71
69
  break;
72
70
  case deviceType_1.DeviceType.ZigbeeIkeaSteckdose:
@@ -13,7 +13,7 @@ export declare class Devices {
13
13
  [id: string]: deviceConfig;
14
14
  }, pRoomImportEnforcer?: iRoomImportEnforcer);
15
15
  static midnightReset(): void;
16
- static resetPraesenzCount(): void;
16
+ static resetDetectionsToday(): void;
17
17
  static getBatteryInfo(): string;
18
18
  private static processZigbeeDevice;
19
19
  private static processWledDevice;
@@ -45,15 +45,12 @@ class Devices {
45
45
  static midnightReset() {
46
46
  // Nothing yet
47
47
  }
48
- static resetPraesenzCount() {
49
- services_1.ServerLogService.writeLog(models_1.LogLevel.Info, `3 Uhr Reset der Präsenzmelder`);
48
+ static resetDetectionsToday() {
49
+ services_1.ServerLogService.writeLog(models_1.LogLevel.Info, `3 o'clock reset of motion sensors`);
50
50
  for (const dID in Devices.alLDevices) {
51
51
  const d = Devices.alLDevices[dID];
52
- if (d.deviceType === deviceType_1.DeviceType.HmIpPraezenz ||
53
- d.deviceType === deviceType_1.DeviceType.HmIpBewegung ||
54
- d.deviceType === deviceType_1.DeviceType.ZigbeeSonoffMotion ||
55
- d.deviceType === deviceType_1.DeviceType.ZigbeeAquaraMotion) {
56
- services_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `2 Uhr Reset der Tages Detektionen von ${d.info.customName}`);
52
+ if (d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.motionSensor)) {
53
+ d.log(models_1.LogLevel.Debug, `3 o'clock reset of detections`);
57
54
  d.detectionsToday = 0;
58
55
  }
59
56
  }
@@ -1,12 +1,10 @@
1
- import { HmIpPraezenz } from '../hmIPDevices';
2
1
  import { BaseGroup } from './base-group';
3
2
  import { iMotionSensor } from '../baseDeviceInterfaces';
4
3
  export declare class PraesenzGroup extends BaseGroup {
5
4
  private _lastMovement;
6
5
  private _lastLeftTimeout;
7
- constructor(roomName: string, presenceDetectorIds: string[], motionSensorIds: string[]);
6
+ constructor(roomName: string, motionSensorIds: string[]);
8
7
  getMotionDetector(): Array<iMotionSensor>;
9
- getPresenceSensors(): HmIpPraezenz[];
10
8
  initCallbacks(): void;
11
9
  presentAmount(): number;
12
10
  anyPresent(): boolean;
@@ -8,31 +8,16 @@ const device_cluster_type_1 = require("../device-cluster-type");
8
8
  const group_type_1 = require("./group-type");
9
9
  const device_list_1 = require("../device-list");
10
10
  class PraesenzGroup extends base_group_1.BaseGroup {
11
- constructor(roomName, presenceDetectorIds, motionSensorIds) {
11
+ constructor(roomName, motionSensorIds) {
12
12
  super(roomName, group_type_1.GroupType.Presence);
13
13
  this._lastMovement = new Date(0);
14
14
  this._lastLeftTimeout = null;
15
- this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.PresenceDetection, new device_list_1.DeviceList(presenceDetectorIds));
16
15
  this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.MotionDetection, new device_list_1.DeviceList(motionSensorIds));
17
16
  }
18
17
  getMotionDetector() {
19
- return this.deviceCluster.getIoBrokerDevicesByType(device_cluster_type_1.DeviceClusterType.MotionDetection);
20
- }
21
- getPresenceSensors() {
22
- return this.deviceCluster.getIoBrokerDevicesByType(device_cluster_type_1.DeviceClusterType.PresenceDetection);
18
+ return this.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.MotionDetection);
23
19
  }
24
20
  initCallbacks() {
25
- this.getPresenceSensors().forEach((p) => {
26
- p.addPresenceCallback((val) => {
27
- if (!val) {
28
- return;
29
- }
30
- if (services_1.RoomService.awayModeActive || (services_1.RoomService.nightAlarmActive && !p.excludeFromNightAlarm)) {
31
- services_1.RoomService.startIntrusionAlarm(this.getRoom(), p);
32
- }
33
- services_1.RoomService.movementHistory.add(`${services_1.Utils.nowString()}: Raum "${this.roomName}" Gerät "${p.info.fullName}"`);
34
- });
35
- });
36
21
  this.getMotionDetector().forEach((b) => {
37
22
  b.addMovementCallback((val) => {
38
23
  var _a;
@@ -69,11 +54,6 @@ class PraesenzGroup extends base_group_1.BaseGroup {
69
54
  }
70
55
  presentAmount() {
71
56
  let count = 0;
72
- for (let i = 0; i < this.getPresenceSensors().length; i++) {
73
- if (this.getPresenceSensors()[i].presenceDetected) {
74
- count++;
75
- }
76
- }
77
57
  for (let i = 0; i < this.getMotionDetector().length; i++) {
78
58
  if (this.getMotionDetector()[i].movementDetected) {
79
59
  count++;
@@ -82,11 +62,6 @@ class PraesenzGroup extends base_group_1.BaseGroup {
82
62
  return count;
83
63
  }
84
64
  anyPresent() {
85
- for (let i = 0; i < this.getPresenceSensors().length; i++) {
86
- if (this.getPresenceSensors()[i].presenceDetected) {
87
- return true;
88
- }
89
- }
90
65
  for (let i = 0; i < this.getMotionDetector().length; i++) {
91
66
  if (this.getMotionDetector()[i].movementDetected) {
92
67
  return true;
@@ -121,11 +96,6 @@ class PraesenzGroup extends base_group_1.BaseGroup {
121
96
  }, Math.abs(timeAfterReset) + 500, this);
122
97
  }
123
98
  addLastLeftCallback(cb) {
124
- this.getPresenceSensors().forEach((p) => {
125
- p.addPresenceCallback((val) => {
126
- this.lastLeftCB(val, cb);
127
- });
128
- });
129
99
  this.getMotionDetector().forEach((b) => {
130
100
  b.addMovementCallback((val) => {
131
101
  this.lastLeftCB(val, cb);
@@ -133,11 +103,6 @@ class PraesenzGroup extends base_group_1.BaseGroup {
133
103
  });
134
104
  }
135
105
  addFirstEnterCallback(cb) {
136
- this.getPresenceSensors().forEach((p) => {
137
- p.addPresenceCallback((val) => {
138
- this.firstEnterCallback(val, cb);
139
- });
140
- });
141
106
  this.getMotionDetector().forEach((b) => {
142
107
  b.addMovementCallback((val) => {
143
108
  this.firstEnterCallback(val, cb);
@@ -23,8 +23,8 @@ class HmIpBewegung extends hmIpDevice_1.HmIPDevice {
23
23
  this.initialized = true;
24
24
  }
25
25
  else {
26
- (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.getCount(this).then((todayCount) => {
27
- this.detectionsToday = todayCount.counter;
26
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.motionSensorTodayCount(this).then((todayCount) => {
27
+ this.detectionsToday = todayCount.count;
28
28
  this.log(models_1.LogLevel.Debug, `Bewegungscounter vorinitialisiert mit ${this.detectionsToday}`);
29
29
  this.initialized = true;
30
30
  }).catch((err) => {
@@ -40,10 +40,7 @@ class HmIpBewegung extends hmIpDevice_1.HmIPDevice {
40
40
  return this._detectionsToday;
41
41
  }
42
42
  set detectionsToday(pVal) {
43
- var _a;
44
- const oldVal = this._detectionsToday;
45
43
  this._detectionsToday = pVal;
46
- (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistTodayCount(this, pVal, oldVal);
47
44
  }
48
45
  get currentIllumination() {
49
46
  return this._currentIllumination;
@@ -16,4 +16,5 @@ export declare class HmIpLampe extends HmIPDevice implements iLamp {
16
16
  setLight(pValue: boolean, timeout?: number, force?: boolean): void;
17
17
  toggleLight(time?: TimeOfDay, force?: boolean, calculateTime?: boolean): boolean;
18
18
  setTimeBased(time: TimeOfDay, timeout?: number, force?: boolean): void;
19
+ persist(): void;
19
20
  }
@@ -26,6 +26,7 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
26
26
  case '1':
27
27
  if (idSplit[4] === 'STATE') {
28
28
  this.lightOn = state.val;
29
+ this.persist();
29
30
  }
30
31
  break;
31
32
  }
@@ -98,5 +99,9 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
98
99
  this.setLight(true, timeout, force);
99
100
  }
100
101
  }
102
+ persist() {
103
+ var _a;
104
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistLamp(this);
105
+ }
101
106
  }
102
107
  exports.HmIpLampe = HmIpLampe;
@@ -1,23 +1,28 @@
1
1
  /// <reference types="iobroker" />
2
2
  import { HmIPDevice } from './hmIpDevice';
3
- import { iBatteryDevice, iIlluminationSensor } from '../baseDeviceInterfaces';
3
+ import { MotionSensorSettings } from '../../../models';
4
+ import { iBatteryDevice, iIlluminationSensor, iMotionSensor } from '../baseDeviceInterfaces';
4
5
  import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
5
- export declare class HmIpPraezenz extends HmIPDevice implements iIlluminationSensor, iBatteryDevice {
6
+ export declare class HmIpPraezenz extends HmIPDevice implements iIlluminationSensor, iBatteryDevice, iMotionSensor {
6
7
  private static PRESENCE_DETECTION;
7
8
  private static CURRENT_ILLUMINATION;
8
9
  excludeFromNightAlarm: boolean;
9
- presenceDetected: boolean;
10
+ movementDetected: boolean;
10
11
  battery: number;
11
- private _presenceDetectedCallback;
12
+ settings: MotionSensorSettings;
13
+ private _movementDetectedCallback;
12
14
  private initialized;
15
+ private _lastMotionTime;
13
16
  constructor(pInfo: IoBrokerDeviceInfo);
17
+ get timeSinceLastMotion(): number;
14
18
  private _detectionsToday;
15
19
  get detectionsToday(): number;
16
20
  set detectionsToday(pVal: number);
17
21
  private _currentIllumination;
18
22
  get currentIllumination(): number;
19
23
  private set currentIllumination(value);
20
- addPresenceCallback(pCallback: (pValue: boolean) => void): void;
24
+ addMovementCallback(pCallback: (pValue: boolean) => void): void;
21
25
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
22
26
  updatePresence(pVal: boolean): void;
27
+ persist(): void;
23
28
  }
@@ -11,22 +11,25 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
11
11
  var _a;
12
12
  super(pInfo, deviceType_1.DeviceType.HmIpPraezenz);
13
13
  this.excludeFromNightAlarm = false;
14
- this.presenceDetected = false;
14
+ this.movementDetected = false;
15
15
  this.battery = -99;
16
- this._presenceDetectedCallback = [];
16
+ this.settings = new models_1.MotionSensorSettings();
17
+ this._movementDetectedCallback = [];
17
18
  // private presenceStateID: string;
18
19
  this.initialized = false;
20
+ this._lastMotionTime = 0;
19
21
  this._detectionsToday = 0;
20
22
  this._currentIllumination = -1;
21
23
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.illuminationSensor);
22
24
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
25
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.motionSensor);
23
26
  // this.presenceStateID = `${this.info.fullID}.1.${HmIpPraezenz.PRESENCE_DETECTION}`;
24
27
  if (!services_1.Utils.anyDboActive) {
25
28
  this.initialized = true;
26
29
  }
27
30
  else {
28
- (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.getCount(this).then((todayCount) => {
29
- this.detectionsToday = todayCount.counter;
31
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.motionSensorTodayCount(this).then((todayCount) => {
32
+ this.detectionsToday = todayCount.count;
30
33
  this.log(models_1.LogLevel.Debug, `Präsenzcounter vorinitialisiert mit ${this.detectionsToday}`);
31
34
  this.initialized = true;
32
35
  }).catch((err) => {
@@ -35,14 +38,14 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
35
38
  });
36
39
  }
37
40
  }
41
+ get timeSinceLastMotion() {
42
+ return Math.floor((services_1.Utils.nowMS() - this._lastMotionTime) / 1000);
43
+ }
38
44
  get detectionsToday() {
39
45
  return this._detectionsToday;
40
46
  }
41
47
  set detectionsToday(pVal) {
42
- var _a;
43
- const oldVal = this._detectionsToday;
44
48
  this._detectionsToday = pVal;
45
- (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistTodayCount(this, pVal, oldVal);
46
49
  }
47
50
  get currentIllumination() {
48
51
  return this._currentIllumination;
@@ -52,8 +55,8 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
52
55
  this._currentIllumination = value;
53
56
  (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistCurrentIllumination(new models_1.CurrentIlluminationDataPoint(this.info.room, this.info.devID, value, new Date(), (_d = (_c = (_b = this.room) === null || _b === void 0 ? void 0 : _b.LampenGroup) === null || _c === void 0 ? void 0 : _c.anyLightsOn()) !== null && _d !== void 0 ? _d : false));
54
57
  }
55
- addPresenceCallback(pCallback) {
56
- this._presenceDetectedCallback.push(pCallback);
58
+ addMovementCallback(pCallback) {
59
+ this._movementDetectedCallback.push(pCallback);
57
60
  }
58
61
  update(idSplit, state, initial = false) {
59
62
  this.log(models_1.LogLevel.DeepTrace, `Präzens Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`);
@@ -86,20 +89,26 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
86
89
  }, 1000, this);
87
90
  return;
88
91
  }
89
- if (pVal === this.presenceDetected) {
92
+ if (pVal === this.movementDetected) {
90
93
  this.log(models_1.LogLevel.Debug, `Überspringe Präsenz da bereits der Wert ${pVal} vorliegt`);
91
94
  return;
92
95
  }
93
- this.presenceDetected = pVal;
96
+ this.movementDetected = pVal;
97
+ this.persist();
94
98
  this.log(models_1.LogLevel.Debug, `Neuer Präsenzstatus Wert : ${pVal}`);
95
99
  if (pVal) {
96
100
  this.detectionsToday++;
101
+ this._lastMotionTime = services_1.Utils.nowMS();
97
102
  this.log(models_1.LogLevel.Trace, `Dies ist die ${this.detectionsToday} Bewegung `);
98
103
  }
99
- for (const c of this._presenceDetectedCallback) {
104
+ for (const c of this._movementDetectedCallback) {
100
105
  c(pVal);
101
106
  }
102
107
  }
108
+ persist() {
109
+ var _a;
110
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistMotionSensor(this);
111
+ }
103
112
  }
104
113
  exports.HmIpPraezenz = HmIpPraezenz;
105
114
  // TODO: Add iPresenceSensor
@@ -24,7 +24,9 @@ class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
24
24
  super.update(idSplit, state, initial, true);
25
25
  switch (idSplit[3]) {
26
26
  case 'state':
27
- !handledByChildObject && this.log(models_1.LogLevel.Trace, `Aktor Update für ${this.info.customName} auf ${state.val}`);
27
+ if (!handledByChildObject) {
28
+ this.log(models_1.LogLevel.Trace, `Aktor Update für ${this.info.customName} auf ${state.val}`);
29
+ }
28
30
  this.actuatorOn = state.val;
29
31
  break;
30
32
  }
@@ -23,9 +23,9 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
23
23
  this._initialized = true;
24
24
  }
25
25
  else {
26
- (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.getCount(this).then((todayCount) => {
27
- this.detectionsToday = todayCount.counter;
28
- this.log(models_1.LogLevel.Debug, `Preinitialized movement counter with ${this.detectionsToday}`);
26
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.motionSensorTodayCount(this).then((todayCount) => {
27
+ this.detectionsToday = todayCount.count;
28
+ this.log(models_1.LogLevel.Debug, `Reinitialized movement counter with ${this.detectionsToday}`);
29
29
  this._initialized = true;
30
30
  }).catch((err) => {
31
31
  var _a;
@@ -41,10 +41,7 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
41
41
  return this._detectionsToday;
42
42
  }
43
43
  set detectionsToday(pVal) {
44
- var _a;
45
- const oldVal = this._detectionsToday;
46
44
  this._detectionsToday = pVal;
47
- (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistTodayCount(this, pVal, oldVal);
48
45
  }
49
46
  /**
50
47
  * Adds a callback for when a motion state has changed.
@@ -26,5 +26,6 @@ export declare class ZigbeeIlluDimmer extends ZigbeeDevice implements iDimmableL
26
26
  * @param {number} transitionTime The transition time for the brightness, to switch smoothly
27
27
  */
28
28
  setLight(pValue: boolean, timeout?: number, force?: boolean, brightness?: number, transitionTime?: number): void;
29
+ persist(): void;
29
30
  toggleLight(time?: TimeOfDay, force?: boolean, calculateTime?: boolean): boolean;
30
31
  }
@@ -33,10 +33,12 @@ class ZigbeeIlluDimmer extends BaseDevices_1.ZigbeeDevice {
33
33
  case 'state':
34
34
  this.log(models_1.LogLevel.Trace, `Dimmer Update für ${this.info.customName} auf ${state.val}`);
35
35
  this.lightOn = state.val;
36
+ this.persist();
36
37
  break;
37
38
  case 'brightness':
38
39
  this.log(models_1.LogLevel.Trace, `Dimmer Helligkeit Update für ${this.info.customName} auf ${state.val}`);
39
40
  this.brightness = state.val;
41
+ this.persist();
40
42
  break;
41
43
  case 'transition_time':
42
44
  this.log(models_1.LogLevel.Trace, `Dimmer Transition Time Update für ${this.info.customName} auf ${state.val}`);
@@ -126,6 +128,10 @@ class ZigbeeIlluDimmer extends BaseDevices_1.ZigbeeDevice {
126
128
  }
127
129
  }, timeout, this);
128
130
  }
131
+ persist() {
132
+ var _a;
133
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistLamp(this);
134
+ }
129
135
  toggleLight(time, force = false, calculateTime = false) {
130
136
  var _a;
131
137
  const newVal = this.queuedValue !== null ? !this.queuedValue : !this.lightOn;
@@ -11,4 +11,5 @@ export declare class ZigbeeIlluLampe extends ZigbeeIlluActuator implements iLamp
11
11
  setLight(pValue: boolean, timeout?: number, force?: boolean): void;
12
12
  toggleLight(time?: TimeOfDay, force?: boolean, calculateTime?: boolean): boolean;
13
13
  setTimeBased(time: TimeOfDay, timeout?: number, force?: boolean): void;
14
+ persist(): void;
14
15
  }
@@ -12,13 +12,14 @@ class ZigbeeIlluLampe extends zigbeeIlluActuator_1.ZigbeeIlluActuator {
12
12
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.lamp);
13
13
  }
14
14
  get lightOn() {
15
- return super.actuatorOn;
15
+ return super.isActuatorOn;
16
16
  }
17
17
  update(idSplit, state, initial = false) {
18
18
  super.update(idSplit, state, initial, true);
19
19
  switch (idSplit[3]) {
20
20
  case 'state':
21
21
  this.log(models_1.LogLevel.Trace, `Lampen Update für ${this.info.customName} auf ${state.val}`);
22
+ this.persist();
22
23
  break;
23
24
  }
24
25
  }
@@ -57,5 +58,9 @@ class ZigbeeIlluLampe extends zigbeeIlluActuator_1.ZigbeeIlluActuator {
57
58
  this.setLight(true, timeout, force);
58
59
  }
59
60
  }
61
+ persist() {
62
+ var _a;
63
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistLamp(this);
64
+ }
60
65
  }
61
66
  exports.ZigbeeIlluLampe = ZigbeeIlluLampe;
@@ -1,17 +1,17 @@
1
- import { iAcDevice, iHeater, iMotionSensor, IoBrokerBaseDevice } from '../../devices';
1
+ import { iAcDevice, iHeater, iLamp, iMotionSensor, IoBrokerBaseDevice } from '../../devices';
2
2
  import { CountToday, CurrentIlluminationDataPoint, EnergyCalculation, RoomBase, ShutterCalibration, TemperaturDataPoint } from '../../../models';
3
3
  export interface iPersist {
4
4
  initialized: boolean;
5
5
  addTemperaturDataPoint(heater: iHeater): void;
6
6
  addRoom(room: RoomBase): void;
7
- getCount(device: IoBrokerBaseDevice): Promise<CountToday>;
7
+ motionSensorTodayCount(device: iMotionSensor): Promise<CountToday>;
8
8
  getShutterCalibration(device: IoBrokerBaseDevice): Promise<ShutterCalibration>;
9
9
  initialize(): Promise<void>;
10
- persistTodayCount(device: IoBrokerBaseDevice, count: number, oldCount: number): void;
11
10
  persistShutterCalibration(data: ShutterCalibration): void;
12
11
  persistCurrentIllumination(data: CurrentIlluminationDataPoint): void;
13
12
  persistEnergyManager(energyData: EnergyCalculation): void;
14
13
  persistAC(device: iAcDevice): void;
14
+ persistLamp(device: iLamp): void;
15
15
  persistMotionSensor(device: iMotionSensor): void;
16
16
  readTemperaturDataPoint(hzGrp: iHeater, limit: number): Promise<TemperaturDataPoint[]>;
17
17
  }
@@ -1,3 +1,2 @@
1
- export * from './mongoPersistance';
2
1
  export * from './postgreSqlPersist';
3
2
  export * from './iPersist';
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./mongoPersistance"), exports);
18
17
  __exportStar(require("./postgreSqlPersist"), exports);
19
18
  __exportStar(require("./iPersist"), exports);
@@ -1,6 +1,6 @@
1
1
  import { iPersist } from './iPersist';
2
2
  import { CountToday, CurrentIlluminationDataPoint, EnergyCalculation, RoomBase, ShutterCalibration, TemperaturDataPoint } from '../../../models';
3
- import { iAcDevice, iHeater, iMotionSensor, IoBrokerBaseDevice } from '../../devices';
3
+ import { iAcDevice, iHeater, iLamp, iMotionSensor, IoBrokerBaseDevice } from '../../devices';
4
4
  import { iPersistenceSettings } from '../../config';
5
5
  export declare class PostgreSqlPersist implements iPersist {
6
6
  initialized: boolean;
@@ -8,14 +8,14 @@ export declare class PostgreSqlPersist implements iPersist {
8
8
  constructor(config: iPersistenceSettings);
9
9
  addRoom(room: RoomBase): void;
10
10
  addTemperaturDataPoint(heater: iHeater): void;
11
- getCount(device: IoBrokerBaseDevice): Promise<CountToday>;
11
+ motionSensorTodayCount(device: iMotionSensor): Promise<CountToday>;
12
12
  getShutterCalibration(_device: IoBrokerBaseDevice): Promise<ShutterCalibration>;
13
13
  initialize(): Promise<void>;
14
14
  persistAC(device: iAcDevice): void;
15
+ persistLamp(device: iLamp): void;
15
16
  persistMotionSensor(device: iMotionSensor): void;
16
17
  persistCurrentIllumination(data: CurrentIlluminationDataPoint): void;
17
18
  persistShutterCalibration(_data: ShutterCalibration): void;
18
- persistTodayCount(device: IoBrokerBaseDevice, count: number, oldCount: number): void;
19
19
  readTemperaturDataPoint(heater: iHeater, limit: number): Promise<TemperaturDataPoint[]>;
20
20
  persistEnergyManager(calc: EnergyCalculation): void;
21
21
  private query;