hoffmation-base 1.0.62 → 1.0.65

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 (44) 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/iAcDevice.d.ts +2 -0
  8. package/lib/server/devices/baseDeviceInterfaces/iLamp.d.ts +1 -0
  9. package/lib/server/devices/baseDeviceInterfaces/iMotionSensor.d.ts +1 -0
  10. package/lib/server/devices/device-cluster-type.d.ts +0 -1
  11. package/lib/server/devices/device-cluster-type.js +0 -1
  12. package/lib/server/devices/device-cluster.js +1 -3
  13. package/lib/server/devices/devices.d.ts +1 -1
  14. package/lib/server/devices/devices.js +4 -7
  15. package/lib/server/devices/groups/heatGroup.js +3 -0
  16. package/lib/server/devices/groups/praesenzGroup.d.ts +1 -3
  17. package/lib/server/devices/groups/praesenzGroup.js +2 -37
  18. package/lib/server/devices/hmIPDevices/hmIpBewegung.d.ts +1 -0
  19. package/lib/server/devices/hmIPDevices/hmIpBewegung.js +7 -5
  20. package/lib/server/devices/hmIPDevices/hmIpLampe.d.ts +1 -0
  21. package/lib/server/devices/hmIPDevices/hmIpLampe.js +5 -0
  22. package/lib/server/devices/hmIPDevices/hmIpPraezenz.d.ts +10 -5
  23. package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +21 -12
  24. package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.d.ts +1 -0
  25. package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +8 -6
  26. package/lib/server/devices/zigbee/zigbeeIlluDimmer.d.ts +1 -0
  27. package/lib/server/devices/zigbee/zigbeeIlluDimmer.js +6 -0
  28. package/lib/server/devices/zigbee/zigbeeIlluLampe.d.ts +1 -0
  29. package/lib/server/devices/zigbee/zigbeeIlluLampe.js +5 -0
  30. package/lib/server/services/ac/ac-device.d.ts +5 -0
  31. package/lib/server/services/ac/ac-device.js +13 -0
  32. package/lib/server/services/dbo/iPersist.d.ts +4 -3
  33. package/lib/server/services/dbo/index.d.ts +0 -1
  34. package/lib/server/services/dbo/index.js +0 -1
  35. package/lib/server/services/dbo/postgreSqlPersist.d.ts +4 -3
  36. package/lib/server/services/dbo/postgreSqlPersist.js +50 -62
  37. package/lib/server/services/time-callback-service.js +1 -1
  38. package/lib/server/services/utils/utils.js +2 -3
  39. package/lib/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +2 -2
  41. package/lib/models/persistence/DailyMovementCount.d.ts +0 -7
  42. package/lib/models/persistence/DailyMovementCount.js +0 -12
  43. package/lib/server/services/dbo/mongoPersistance.d.ts +0 -32
  44. package/lib/server/services/dbo/mongoPersistance.js +0 -171
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;
@@ -4,11 +4,13 @@ import { iBaseDevice } from './iBaseDevice';
4
4
  export interface iAcDevice extends iBaseDevice {
5
5
  acSettings: AcSettings;
6
6
  readonly on: boolean;
7
+ readonly temperature: number;
7
8
  /**
8
9
  * Disable automatic Turn-On for given amount of ms and turn off immediately.
9
10
  * @param {number} timeout
10
11
  */
11
12
  deactivateAutomaticTurnOn(timeout: number): void;
13
+ onTemperaturChange(newTemperatur: number): void;
12
14
  setDesiredMode(mode: AcMode, writeToDevice: boolean): void;
13
15
  turnOn(): void;
14
16
  turnOff(): void;
@@ -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
  /**
@@ -10,4 +10,5 @@ export interface iMotionSensor extends iRoomDevice {
10
10
  * @param pCallback Function that accepts the new state as parameter
11
11
  */
12
12
  addMovementCallback(pCallback: (newState: boolean) => void): void;
13
+ persist(): void;
13
14
  }
@@ -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
  }
@@ -148,6 +148,9 @@ class HeatGroup extends base_group_1.BaseGroup {
148
148
  this.getHeater().forEach((heater) => {
149
149
  heater.onTemperaturChange(temp);
150
150
  });
151
+ this.getOwnAcDevices().forEach((ac) => {
152
+ ac.onTemperaturChange(temp);
153
+ });
151
154
  }
152
155
  }
153
156
  exports.HeatGroup = HeatGroup;
@@ -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);
@@ -21,6 +21,7 @@ export declare class HmIpBewegung extends HmIPDevice implements iIlluminationSen
21
21
  get currentIllumination(): number;
22
22
  private set currentIllumination(value);
23
23
  addMovementCallback(pCallback: (pValue: boolean) => void): void;
24
+ persist(): void;
24
25
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
25
26
  updateMovement(pVal: boolean): void;
26
27
  private resetFallbackTimeout;
@@ -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;
@@ -56,6 +53,10 @@ class HmIpBewegung extends hmIpDevice_1.HmIPDevice {
56
53
  addMovementCallback(pCallback) {
57
54
  this._movementDetectedCallback.push(pCallback);
58
55
  }
56
+ persist() {
57
+ var _a;
58
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistMotionSensor(this);
59
+ }
59
60
  update(idSplit, state, initial = false) {
60
61
  this.log(models_1.LogLevel.DeepTrace, `Bewegungs Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`);
61
62
  super.update(idSplit, state, initial, true);
@@ -91,6 +92,7 @@ class HmIpBewegung extends hmIpDevice_1.HmIPDevice {
91
92
  this.resetFallbackTimeout();
92
93
  this.movementDetected = pVal;
93
94
  this.log(models_1.LogLevel.Debug, `Neuer Bewegunsstatus Wert : ${pVal}`);
95
+ this.persist();
94
96
  if (pVal) {
95
97
  this.startFallbackTimeout();
96
98
  this.detectionsToday++;
@@ -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,6 +24,7 @@ export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionS
24
24
  * @param pCallback Function that accepts the new state as parameter
25
25
  */
26
26
  addMovementCallback(pCallback: (newState: boolean) => void): void;
27
+ persist(): void;
27
28
  updateMovement(newState: boolean): void;
28
29
  update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverride?: boolean): void;
29
30
  private resetFallbackTimeout;
@@ -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.
@@ -53,6 +50,10 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
53
50
  addMovementCallback(pCallback) {
54
51
  this._movementDetectedCallback.push(pCallback);
55
52
  }
53
+ persist() {
54
+ var _a;
55
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistMotionSensor(this);
56
+ }
56
57
  updateMovement(newState) {
57
58
  if (!this._initialized && newState) {
58
59
  this.log(models_1.LogLevel.Trace, `Movement recognized, but database initialization has not finished yet --> delay.`);
@@ -72,6 +73,7 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
72
73
  }
73
74
  this.resetFallbackTimeout();
74
75
  this.movementDetected = newState;
76
+ this.persist();
75
77
  this.log(models_1.LogLevel.Debug, `New movement state: ${newState}`, services_1.LogDebugType.NewMovementState);
76
78
  if (newState) {
77
79
  this.startFallbackTimeout();
@@ -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
  }
@@ -19,6 +19,7 @@ class ZigbeeIlluLampe extends zigbeeIlluActuator_1.ZigbeeIlluActuator {
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;
@@ -14,8 +14,12 @@ export declare abstract class AcDevice implements iExcessEnergyConsumer, iRoomDe
14
14
  room: RoomBase | undefined;
15
15
  deviceCapabilities: DeviceCapability[];
16
16
  protected _info: DeviceInfo;
17
+ get roomTemperature(): number;
17
18
  protected constructor(name: string, roomName: string, ip: string, acDeviceType: AcDeviceType);
19
+ get temperature(): number;
20
+ private _roomTemperatur;
18
21
  get info(): DeviceInfo;
22
+ protected set roomTemperatur(val: number);
19
23
  set info(info: DeviceInfo);
20
24
  abstract get deviceType(): DeviceType;
21
25
  get name(): string;
@@ -32,6 +36,7 @@ export declare abstract class AcDevice implements iExcessEnergyConsumer, iRoomDe
32
36
  deactivateAutomaticTurnOn(timeout?: number): void;
33
37
  abstract setDesiredMode(mode: AcMode, writeToDevice: boolean): void;
34
38
  abstract turnOn(): void;
39
+ onTemperaturChange(newTemperatur: number): void;
35
40
  persist(): void;
36
41
  turnOnForExcessEnergy(): void;
37
42
  abstract turnOff(): void;
@@ -20,6 +20,7 @@ class AcDevice {
20
20
  this.energyConsumerSettings = new models_1.ExcessEnergyConsumerSettings();
21
21
  this.acSettings = new acSettings_1.AcSettings();
22
22
  this.deviceCapabilities = [DeviceCapability_1.DeviceCapability.ac];
23
+ this._roomTemperatur = 0;
23
24
  this._activatedByExcessEnergy = false;
24
25
  this._blockAutomaticTurnOnMS = -1;
25
26
  this._info = new devices_1.DeviceInfo();
@@ -30,9 +31,18 @@ class AcDevice {
30
31
  utils_1.Utils.guardedInterval(this.automaticCheck, 60000, this, true);
31
32
  utils_1.Utils.guardedInterval(this.persist, 15 * 60 * 1000, this, true);
32
33
  }
34
+ get roomTemperature() {
35
+ return this._roomTemperatur;
36
+ }
37
+ get temperature() {
38
+ return this._roomTemperatur;
39
+ }
33
40
  get info() {
34
41
  return this._info;
35
42
  }
43
+ set roomTemperatur(val) {
44
+ this._roomTemperatur = val;
45
+ }
36
46
  set info(info) {
37
47
  this._info = info;
38
48
  }
@@ -78,6 +88,9 @@ class AcDevice {
78
88
  this._blockAutomaticTurnOnMS = utils_1.Utils.nowMS() + timeout;
79
89
  this.turnOff();
80
90
  }
91
+ onTemperaturChange(newTemperatur) {
92
+ this.roomTemperatur = newTemperatur;
93
+ }
81
94
  persist() {
82
95
  var _a;
83
96
  if (!utils_1.Utils.anyDboActive) {