hoffmation-base 0.1.31-8 → 0.1.33-2

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 (50) hide show
  1. package/lib/models/rooms/RoomBase.d.ts +1 -0
  2. package/lib/models/rooms/RoomBase.js +5 -0
  3. package/lib/server/devices/DeviceInfo.d.ts +1 -0
  4. package/lib/server/devices/DeviceInfo.js +7 -0
  5. package/lib/server/devices/IoBrokerBaseDevice.d.ts +1 -0
  6. package/lib/server/devices/IoBrokerBaseDevice.js +4 -0
  7. package/lib/server/devices/deviceType.d.ts +2 -1
  8. package/lib/server/devices/deviceType.js +2 -1
  9. package/lib/server/devices/devices.d.ts +1 -1
  10. package/lib/server/devices/devices.js +5 -1
  11. package/lib/server/devices/groups/praesenzGroup.d.ts +2 -2
  12. package/lib/server/devices/hmIPDevices/hmIpBewegung.d.ts +1 -1
  13. package/lib/server/devices/hmIPDevices/hmIpBewegung.js +4 -4
  14. package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +2 -1
  15. package/lib/server/devices/hmIPDevices/hmIpGriff.js +12 -5
  16. package/lib/server/devices/hmIPDevices/hmIpLampe.d.ts +1 -1
  17. package/lib/server/devices/hmIPDevices/hmIpLampe.js +6 -6
  18. package/lib/server/devices/hmIPDevices/hmIpRoll.d.ts +1 -0
  19. package/lib/server/devices/hmIPDevices/hmIpRoll.js +7 -0
  20. package/lib/server/devices/hmIPDevices/hmIpTuer.d.ts +1 -1
  21. package/lib/server/devices/hmIPDevices/hmIpTuer.js +5 -5
  22. package/lib/server/devices/zigbee/ZigbeeActuator.d.ts +1 -1
  23. package/lib/server/devices/zigbee/ZigbeeActuator.js +6 -6
  24. package/lib/server/devices/zigbee/zigbeeAquaraMotion.d.ts +2 -22
  25. package/lib/server/devices/zigbee/zigbeeAquaraMotion.js +2 -88
  26. package/lib/server/devices/zigbee/zigbeeAquaraWater.d.ts +1 -1
  27. package/lib/server/devices/zigbee/zigbeeAquaraWater.js +6 -6
  28. package/lib/server/devices/zigbee/zigbeeHeimanSmoke.d.ts +1 -1
  29. package/lib/server/devices/zigbee/zigbeeHeimanSmoke.js +6 -6
  30. package/lib/server/devices/zigbee/zigbeeIlluDimmer.d.ts +1 -1
  31. package/lib/server/devices/zigbee/zigbeeIlluDimmer.js +6 -6
  32. package/lib/server/devices/zigbee/zigbeeMagnetContact.d.ts +1 -1
  33. package/lib/server/devices/zigbee/zigbeeMagnetContact.js +5 -5
  34. package/lib/server/devices/zigbee/zigbeeMotionSensor.d.ts +28 -0
  35. package/lib/server/devices/zigbee/zigbeeMotionSensor.js +108 -0
  36. package/lib/server/devices/zigbee/zigbeeShutter.d.ts +1 -0
  37. package/lib/server/devices/zigbee/zigbeeShutter.js +7 -0
  38. package/lib/server/devices/zigbee/zigbeeSonoffMotion.d.ts +7 -0
  39. package/lib/server/devices/zigbee/zigbeeSonoffMotion.js +18 -0
  40. package/lib/server/ioBroker/connection.d.ts +1 -1
  41. package/lib/server/ioBroker/connection.js +3 -3
  42. package/lib/server/services/api/api-service.js +3 -0
  43. package/lib/server/services/room-service/room-service.d.ts +2 -2
  44. package/lib/server/services/room-service/room-service.js +12 -12
  45. package/lib/server/services/time-callback-service.d.ts +1 -1
  46. package/lib/server/services/time-callback-service.js +4 -4
  47. package/lib/server/services/utils/utils.d.ts +2 -0
  48. package/lib/server/services/utils/utils.js +22 -0
  49. package/lib/tsconfig.tsbuildinfo +1 -1
  50. package/package.json +3 -1
@@ -41,4 +41,5 @@ export declare class RoomBase implements iRoomBase {
41
41
  */
42
42
  setLightTimeBased(movementDependant?: boolean): void;
43
43
  isNowLightTime(): boolean;
44
+ toJSON(): Partial<RoomBase>;
44
45
  }
@@ -9,6 +9,7 @@ const room_service_1 = require("../../server/services/room-service/room-service"
9
9
  const roomInfo_1 = require("./roomInfo");
10
10
  const group_type_1 = require("../../server/devices/groups/group-type");
11
11
  const ShutterService_1 = require("../../server/services/ShutterService");
12
+ const utils_1 = require("../../server/services/utils/utils");
12
13
  class RoomBase {
13
14
  constructor(roomName, Einstellungen, groups) {
14
15
  this.Einstellungen = Einstellungen;
@@ -119,5 +120,9 @@ class RoomBase {
119
120
  }
120
121
  return time_callback_service_1.TimeCallbackService.darkOutsideOrNight(timeOfDay);
121
122
  }
123
+ toJSON() {
124
+ const result = utils_1.Utils.jsonFilter(this);
125
+ return result;
126
+ }
122
127
  }
123
128
  exports.RoomBase = RoomBase;
@@ -15,4 +15,5 @@ export declare class DeviceInfo {
15
15
  constructor(pDevConf: deviceConfig);
16
16
  set customName(val: string);
17
17
  get customName(): string;
18
+ toJSON(): Partial<DeviceInfo>;
18
19
  }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.DeviceInfo = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
4
8
  class DeviceInfo {
5
9
  constructor(pDevConf) {
6
10
  this.devConf = pDevConf;
@@ -44,5 +48,8 @@ class DeviceInfo {
44
48
  }
45
49
  return this.fullName;
46
50
  }
51
+ toJSON() {
52
+ return lodash_1.default.omit(this, ['devConf']);
53
+ }
47
54
  }
48
55
  exports.DeviceInfo = DeviceInfo;
@@ -46,4 +46,5 @@ export declare abstract class IoBrokerBaseDevice {
46
46
  * @param onError Callback to run if an error has occurred during writing the data
47
47
  */
48
48
  protected setState(pointId: string, state: string | number | boolean | ioBroker.State | ioBroker.SettableState | null, onSuccess?: (() => void) | undefined, onError?: ((error: Error) => void) | undefined): void;
49
+ toJSON(): Partial<IoBrokerBaseDevice>;
49
50
  }
@@ -115,6 +115,10 @@ class IoBrokerBaseDevice {
115
115
  }
116
116
  });
117
117
  }
118
+ toJSON() {
119
+ const result = utils_1.Utils.jsonFilter(this);
120
+ return result;
121
+ }
118
122
  }
119
123
  exports.IoBrokerBaseDevice = IoBrokerBaseDevice;
120
124
  IoBrokerBaseDevice.roomAddingSettings = {};
@@ -23,6 +23,7 @@ export declare enum DeviceType {
23
23
  ZigbeeIlluActuator = 210,
24
24
  ZigbeeAquaraMotion = 211,
25
25
  ZigbeeIlluShutter = 212,
26
- ZigbeeSMaBiTMagnetContact = 212,
26
+ ZigbeeSMaBiTMagnetContact = 213,
27
+ ZigbeeSonoffMotion = 214,
27
28
  Wled = 1001
28
29
  }
@@ -27,6 +27,7 @@ var DeviceType;
27
27
  DeviceType[DeviceType["ZigbeeIlluActuator"] = 210] = "ZigbeeIlluActuator";
28
28
  DeviceType[DeviceType["ZigbeeAquaraMotion"] = 211] = "ZigbeeAquaraMotion";
29
29
  DeviceType[DeviceType["ZigbeeIlluShutter"] = 212] = "ZigbeeIlluShutter";
30
- DeviceType[DeviceType["ZigbeeSMaBiTMagnetContact"] = 212] = "ZigbeeSMaBiTMagnetContact";
30
+ DeviceType[DeviceType["ZigbeeSMaBiTMagnetContact"] = 213] = "ZigbeeSMaBiTMagnetContact";
31
+ DeviceType[DeviceType["ZigbeeSonoffMotion"] = 214] = "ZigbeeSonoffMotion";
31
32
  DeviceType[DeviceType["Wled"] = 1001] = "Wled";
32
33
  })(DeviceType = exports.DeviceType || (exports.DeviceType = {}));
@@ -9,7 +9,7 @@ export declare class Devices {
9
9
  };
10
10
  constructor(pDeviceData: {
11
11
  [id: string]: deviceConfig;
12
- }, pRoomImportEnforcer: iRoomImportEnforcer);
12
+ }, pRoomImportEnforcer?: iRoomImportEnforcer);
13
13
  static midnightReset(): void;
14
14
  static resetPraesenzCount(): void;
15
15
  private processZigbeeDevice;
@@ -30,10 +30,11 @@ const hmIpTuer_1 = require("./hmIPDevices/hmIpTuer");
30
30
  const hmIpHeizgruppe_1 = require("./hmIPDevices/hmIpHeizgruppe");
31
31
  const zigbeeIlluShutter_1 = require("./zigbee/zigbeeIlluShutter");
32
32
  const zigbeeSMaBiTMagnetContact_1 = require("./zigbee/zigbeeSMaBiTMagnetContact");
33
+ const zigbeeSonoffMotion_1 = require("./zigbee/zigbeeSonoffMotion");
33
34
  class Devices {
34
35
  constructor(pDeviceData, pRoomImportEnforcer) {
35
36
  // This forces import of rooms at correct timing, to allow devices to land in proper rooms.
36
- pRoomImportEnforcer.addRoomConstructor();
37
+ pRoomImportEnforcer === null || pRoomImportEnforcer === void 0 ? void 0 : pRoomImportEnforcer.addRoomConstructor();
37
38
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Info, `Constructing devices now`);
38
39
  for (const cID in pDeviceData) {
39
40
  const cDevConf = pDeviceData[cID];
@@ -118,6 +119,9 @@ class Devices {
118
119
  case 'SMaBiTMagnet':
119
120
  d = new zigbeeSMaBiTMagnetContact_1.ZigbeeSMaBiTMagnetContact(zigbeeInfo);
120
121
  break;
122
+ case 'SonoffMotion':
123
+ d = new zigbeeSonoffMotion_1.ZigbeeSonoffMotion(zigbeeInfo);
124
+ break;
121
125
  default:
122
126
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Warn, `No zigbee Device Type for ${zigbeeInfo.deviceType} defined`);
123
127
  d = new zigbeeDevice_1.ZigbeeDevice(zigbeeInfo, deviceType_1.DeviceType.unknown);
@@ -1,10 +1,10 @@
1
1
  import { HmIpPraezenz } from '../hmIPDevices/hmIpPraezenz';
2
- import { ZigbeeAquaraMotion } from '../zigbee/zigbeeAquaraMotion';
3
2
  import { HmIpBewegung } from '../hmIPDevices/hmIpBewegung';
4
3
  import { BaseGroup } from './base-group';
4
+ import { ZigbeeMotionSensor } from '../zigbee/zigbeeMotionSensor';
5
5
  export declare class PraesenzGroup extends BaseGroup {
6
6
  private _lastMovement;
7
- getMotionDetector(): Array<HmIpBewegung | ZigbeeAquaraMotion>;
7
+ getMotionDetector(): Array<HmIpBewegung | ZigbeeMotionSensor>;
8
8
  getPresenceSensors(): HmIpPraezenz[];
9
9
  constructor(roomName: string, presenceDetectorIds: string[], motionSensorIds: string[]);
10
10
  initCallbacks(): void;
@@ -10,7 +10,7 @@ export declare class HmIpBewegung extends HmIPDevice implements iIlluminationSen
10
10
  private static MOVEMENT_DETECTION;
11
11
  private static CURRENT_ILLUMINATION;
12
12
  private initialized;
13
- private fallBackTimeout;
13
+ private _fallBackTimeout;
14
14
  private _currentIllumination;
15
15
  get currentIllumination(): number;
16
16
  private set currentIllumination(value);
@@ -91,15 +91,15 @@ class HmIpBewegung extends hmIpDevice_1.HmIPDevice {
91
91
  }
92
92
  }
93
93
  resetFallbackTimeout() {
94
- if (this.fallBackTimeout) {
94
+ if (this._fallBackTimeout) {
95
95
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Trace, `Fallback Timeout für "${this.info.customName}" zurücksetzen`);
96
- clearTimeout(this.fallBackTimeout);
96
+ clearTimeout(this._fallBackTimeout);
97
97
  }
98
98
  }
99
99
  startFallbackTimeout() {
100
- this.fallBackTimeout = utils_1.Utils.guardedTimeout(() => {
100
+ this._fallBackTimeout = utils_1.Utils.guardedTimeout(() => {
101
101
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Benötige Fallback Bewegungs Reset für "${this.info.customName}"`);
102
- this.fallBackTimeout = undefined;
102
+ this._fallBackTimeout = undefined;
103
103
  this.updateMovement(false);
104
104
  }, 270000, this);
105
105
  }
@@ -8,7 +8,7 @@ export declare class HmIpGriff extends HmIPDevice {
8
8
  private _kippCallback;
9
9
  private _closedCallback;
10
10
  private _offenCallback;
11
- private _iOpen;
11
+ private _iOpenTimeout;
12
12
  private minutesOpen;
13
13
  private _fenster;
14
14
  private _helpingRoomTemp;
@@ -19,4 +19,5 @@ export declare class HmIpGriff extends HmIPDevice {
19
19
  set Fenster(value: Fenster);
20
20
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
21
21
  updatePosition(pValue: FensterPosition): void;
22
+ toJSON(): Partial<HmIpGriff>;
22
23
  }
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.HmIpGriff = void 0;
4
7
  const hmIpDevice_1 = require("./hmIpDevice");
@@ -9,6 +12,7 @@ const weather_service_1 = require("../../services/weather/weather-service");
9
12
  const telegram_service_1 = require("../../services/Telegram/telegram-service");
10
13
  const FensterPosition_1 = require("../models/FensterPosition");
11
14
  const logLevel_1 = require("../../../models/logLevel");
15
+ const lodash_1 = __importDefault(require("lodash"));
12
16
  class HmIpGriff extends hmIpDevice_1.HmIPDevice {
13
17
  constructor(pInfo) {
14
18
  super(pInfo, deviceType_1.DeviceType.HmIpGriff);
@@ -59,16 +63,16 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
59
63
  c3(pValue === 2);
60
64
  }
61
65
  if (pValue === FensterPosition_1.FensterPosition.geschlossen) {
62
- if (this._iOpen !== undefined) {
63
- clearInterval(this._iOpen);
66
+ if (this._iOpenTimeout !== undefined) {
67
+ clearInterval(this._iOpenTimeout);
64
68
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Info, `Fenster: "${this.info.customName}" nach ${this.minutesOpen} Minuten geschlossen`);
65
69
  this.minutesOpen = 0;
66
- this._iOpen = undefined;
70
+ this._iOpenTimeout = undefined;
67
71
  }
68
72
  return;
69
73
  }
70
- else if (this._iOpen === undefined) {
71
- this._iOpen = utils_1.Utils.guardedInterval(() => {
74
+ else if (this._iOpenTimeout === undefined) {
75
+ this._iOpenTimeout = utils_1.Utils.guardedInterval(() => {
72
76
  var _a;
73
77
  this.minutesOpen++;
74
78
  const heatgroup = (_a = this._fenster) === null || _a === void 0 ? void 0 : _a.getRoom().HeatGroup;
@@ -115,5 +119,8 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
115
119
  }, 60000, this);
116
120
  }
117
121
  }
122
+ toJSON() {
123
+ return lodash_1.default.omit(this, ['_fenster']);
124
+ }
118
125
  }
119
126
  exports.HmIpGriff = HmIpGriff;
@@ -10,7 +10,7 @@ export declare class HmIpLampe extends HmIPDevice implements iLamp {
10
10
  isStromStoss: boolean;
11
11
  settings: ActuatorSettings;
12
12
  private lightOnSwitchID;
13
- private turnOffTimeout;
13
+ private _turnOffTimeout;
14
14
  private turnOffTime;
15
15
  constructor(pInfo: DeviceInfo);
16
16
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
@@ -16,7 +16,7 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
16
16
  this.isStromStoss = false;
17
17
  this.settings = new actuatorSettings_1.ActuatorSettings();
18
18
  this.lightOnSwitchID = '';
19
- this.turnOffTimeout = undefined;
19
+ this._turnOffTimeout = undefined;
20
20
  this.turnOffTime = 0;
21
21
  this.lightOnSwitchID = `${this.info.fullID}.2.STATE`;
22
22
  }
@@ -58,17 +58,17 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
58
58
  if (this.isStromStoss) {
59
59
  timeout = 5000;
60
60
  }
61
- if (this.turnOffTimeout !== undefined) {
62
- clearTimeout(this.turnOffTimeout);
63
- this.turnOffTimeout = undefined;
61
+ if (this._turnOffTimeout !== undefined) {
62
+ clearTimeout(this._turnOffTimeout);
63
+ this._turnOffTimeout = undefined;
64
64
  }
65
65
  if (timeout < 0 || !pValue) {
66
66
  return;
67
67
  }
68
68
  this.turnOffTime = utils_1.Utils.nowMS() + timeout;
69
- this.turnOffTimeout = utils_1.Utils.guardedTimeout(() => {
69
+ this._turnOffTimeout = utils_1.Utils.guardedTimeout(() => {
70
70
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Delayed Turnoff for "${this.info.customName}" initiated`);
71
- this.turnOffTimeout = undefined;
71
+ this._turnOffTimeout = undefined;
72
72
  if (!this.room) {
73
73
  this.setLight(false, -1, true);
74
74
  }
@@ -18,4 +18,5 @@ export declare class HmIpRoll extends HmIPDevice implements iShutter {
18
18
  constructor(pInfo: DeviceInfo);
19
19
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
20
20
  setLevel(pPosition: number, initial?: boolean, skipOpenWarning?: boolean): void;
21
+ toJSON(): Partial<HmIpRoll>;
21
22
  }
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.HmIpRoll = void 0;
4
7
  const hmIpDevice_1 = require("./hmIpDevice");
@@ -7,6 +10,7 @@ const utils_1 = require("../../services/utils/utils");
7
10
  const log_service_1 = require("../../services/log-service");
8
11
  const FensterPosition_1 = require("../models/FensterPosition");
9
12
  const logLevel_1 = require("../../../models/logLevel");
13
+ const lodash_1 = __importDefault(require("lodash"));
10
14
  class HmIpRoll extends hmIpDevice_1.HmIPDevice {
11
15
  constructor(pInfo) {
12
16
  super(pInfo, deviceType_1.DeviceType.HmIpRoll);
@@ -94,5 +98,8 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
94
98
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Fahre Rollo "${this.info.customName}" auf Position ${pPosition}`);
95
99
  this.setState(this._setLevelSwitchID, pPosition);
96
100
  }
101
+ toJSON() {
102
+ return lodash_1.default.omit(this, ['_fenster']);
103
+ }
97
104
  }
98
105
  exports.HmIpRoll = HmIpRoll;
@@ -6,7 +6,7 @@ export declare class HmIpTuer extends HmIPDevice {
6
6
  position: MagnetPosition;
7
7
  private _closedCallback;
8
8
  private _openCallback;
9
- private _iOpen;
9
+ private _iOpenTimeout;
10
10
  private minutesOpen;
11
11
  constructor(pInfo: DeviceInfo);
12
12
  addOpenCallback(pCallback: (pValue: boolean) => void): void;
@@ -52,8 +52,8 @@ class HmIpTuer extends hmIpDevice_1.HmIPDevice {
52
52
  c2(pValue === 1);
53
53
  }
54
54
  if (pValue === MagnetPosition_1.MagnetPosition.closed) {
55
- if (this._iOpen !== undefined) {
56
- clearInterval(this._iOpen);
55
+ if (this._iOpenTimeout !== undefined) {
56
+ clearInterval(this._iOpenTimeout);
57
57
  let message = `${this.info.customName} closed after ${this.minutesOpen} minutes!`;
58
58
  if (this.minutesOpen === 0) {
59
59
  message = `"${this.info.customName}" just closed`;
@@ -62,16 +62,16 @@ class HmIpTuer extends hmIpDevice_1.HmIPDevice {
62
62
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Info, message);
63
63
  telegram_service_1.TelegramService.inform(message);
64
64
  this.minutesOpen = 0;
65
- this._iOpen = undefined;
65
+ this._iOpenTimeout = undefined;
66
66
  }
67
67
  return;
68
68
  }
69
- else if (this._iOpen === undefined) {
69
+ else if (this._iOpenTimeout === undefined) {
70
70
  const message = res_1.Res.wasOpened(this.info.customName);
71
71
  //const message: string = `Die Tür mit dem Namen "${this.info.customName}" wurde geöfnet!`
72
72
  telegram_service_1.TelegramService.inform(message);
73
73
  sonos_service_1.SonosService.speakOnAll(message, 40);
74
- this._iOpen = utils_1.Utils.guardedInterval(() => {
74
+ this._iOpenTimeout = utils_1.Utils.guardedInterval(() => {
75
75
  this.minutesOpen++;
76
76
  const message = `Contact: "${this.info.customName}" is ${MagnetPosition_1.MagnetPosition[this.position]} since ${this.minutesOpen} minutes`;
77
77
  switch (this.minutesOpen) {
@@ -8,7 +8,7 @@ export declare class ZigbeeActuator extends ZigbeeDevice {
8
8
  protected readonly actuatorOnSwitchID: string;
9
9
  protected queuedValue: boolean | null;
10
10
  protected actuatorOn: boolean;
11
- private turnOffTimeout;
11
+ private _turnOffTimeout;
12
12
  private turnOffTime;
13
13
  constructor(pInfo: DeviceInfo, type: DeviceType, actuatorOnSwitchID: string);
14
14
  update(idSplit: string[], state: ioBroker.State, initial?: boolean, handledByChildObject?: boolean): void;
@@ -12,7 +12,7 @@ class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
12
12
  this.settings = new actuatorSettings_1.ActuatorSettings();
13
13
  this.queuedValue = null;
14
14
  this.actuatorOn = false;
15
- this.turnOffTimeout = undefined;
15
+ this._turnOffTimeout = undefined;
16
16
  this.turnOffTime = 0;
17
17
  this.actuatorOnSwitchID = actuatorOnSwitchID;
18
18
  }
@@ -48,17 +48,17 @@ class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
48
48
  console.log(`Stecker schalten ergab Fehler: ${err}`);
49
49
  });
50
50
  this.queuedValue = pValue;
51
- if (this.turnOffTimeout !== undefined) {
52
- clearTimeout(this.turnOffTimeout);
53
- this.turnOffTimeout = undefined;
51
+ if (this._turnOffTimeout !== undefined) {
52
+ clearTimeout(this._turnOffTimeout);
53
+ this._turnOffTimeout = undefined;
54
54
  }
55
55
  if (timeout < 0 || !pValue) {
56
56
  return;
57
57
  }
58
58
  this.turnOffTime = utils_1.Utils.nowMS() + timeout;
59
- this.turnOffTimeout = utils_1.Utils.guardedTimeout(() => {
59
+ this._turnOffTimeout = utils_1.Utils.guardedTimeout(() => {
60
60
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Delayed Turnoff for "${this.info.customName}" initiated`);
61
- this.turnOffTimeout = undefined;
61
+ this._turnOffTimeout = undefined;
62
62
  if (!this.room) {
63
63
  this.setActuator(false, -1, true);
64
64
  }
@@ -1,35 +1,15 @@
1
1
  /// <reference types="iobroker" />
2
- import { RoomBase } from '../../../models/rooms/RoomBase';
3
2
  import { DeviceInfo } from '../DeviceInfo';
4
- import { ZigbeeDevice } from './zigbeeDevice';
5
3
  import { iIlluminationSensor } from '../iIlluminationSensor';
6
- export declare class ZigbeeAquaraMotion extends ZigbeeDevice implements iIlluminationSensor {
7
- movementDetected: boolean;
8
- excludeFromNightAlarm: boolean;
9
- room: RoomBase | undefined;
10
- private _timeSinceLastMotion;
4
+ import { ZigbeeMotionSensor } from './zigbeeMotionSensor';
5
+ export declare class ZigbeeAquaraMotion extends ZigbeeMotionSensor implements iIlluminationSensor {
11
6
  private _illuminance;
12
7
  private _motionTimeout;
13
- private _detectionsToday;
14
- private _initialized;
15
- private _movementDetectedCallback;
16
- private _fallBackTimeout;
17
8
  private occupancyTimeoutID;
18
9
  get currentIllumination(): number;
19
10
  private set currentIllumination(value);
20
- get timeSinceLastMotion(): number;
21
11
  get motionTimeout(): number;
22
12
  set motionTimeout(value: number);
23
- get detectionsToday(): number;
24
- set detectionsToday(pVal: number);
25
13
  constructor(pInfo: DeviceInfo);
26
- /**
27
- * Adds a callback for when a motion state has changed.
28
- * @param pCallback Function that accepts the new state as parameter
29
- */
30
- addMovementCallback(pCallback: (newState: boolean) => void): void;
31
- updateMovement(newState: boolean): void;
32
14
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
33
- private resetFallbackTimeout;
34
- private startFallbackTimeout;
35
15
  }
@@ -3,34 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZigbeeAquaraMotion = void 0;
4
4
  const deviceType_1 = require("../deviceType");
5
5
  const log_service_1 = require("../../services/log-service");
6
- const utils_1 = require("../../services/utils/utils");
7
- const zigbeeDevice_1 = require("./zigbeeDevice");
8
6
  const persist_1 = require("../../services/dbo/persist");
9
7
  const CurrentIlluminationDataPoint_1 = require("../../../models/persistence/CurrentIlluminationDataPoint");
10
8
  const logLevel_1 = require("../../../models/logLevel");
11
- class ZigbeeAquaraMotion extends zigbeeDevice_1.ZigbeeDevice {
9
+ const zigbeeMotionSensor_1 = require("./zigbeeMotionSensor");
10
+ class ZigbeeAquaraMotion extends zigbeeMotionSensor_1.ZigbeeMotionSensor {
12
11
  constructor(pInfo) {
13
12
  super(pInfo, deviceType_1.DeviceType.ZigbeeAquaraMotion);
14
- this.movementDetected = false;
15
- this.excludeFromNightAlarm = false;
16
- this.room = undefined;
17
- this._timeSinceLastMotion = 0;
18
13
  this._illuminance = 0;
19
14
  this._motionTimeout = 0;
20
- this._detectionsToday = 0;
21
- this._initialized = false;
22
- this._movementDetectedCallback = [];
23
15
  this.occupancyTimeoutID = `occupancy_timeout`;
24
16
  this.occupancyTimeoutID = `${this.info.fullID}.${this.occupancyTimeoutID}`;
25
- persist_1.Persist.getCount(this)
26
- .then((todayCount) => {
27
- this.detectionsToday = todayCount.counter;
28
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Preinitialized movement counter for "${this.info.customName}" with ${this.detectionsToday}`);
29
- this._initialized = true;
30
- })
31
- .catch((err) => {
32
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Warn, `Failed to initialize movement counter for "${this.info.customName}", err ${err.message}`);
33
- });
34
17
  }
35
18
  // Currently measured brightness in lux
36
19
  get currentIllumination() {
@@ -41,10 +24,6 @@ class ZigbeeAquaraMotion extends zigbeeDevice_1.ZigbeeDevice {
41
24
  this._illuminance = value;
42
25
  persist_1.Persist.persistCurrentIllumination(new CurrentIlluminationDataPoint_1.CurrentIlluminationDataPoint(this.info.room, this.info.devID, value, new Date(), (_c = (_b = (_a = this.room) === null || _a === void 0 ? void 0 : _a.LampenGroup) === null || _b === void 0 ? void 0 : _b.anyLightsOwn()) !== null && _c !== void 0 ? _c : false));
43
26
  }
44
- // Time since last motion in seconds
45
- get timeSinceLastMotion() {
46
- return this._timeSinceLastMotion;
47
- }
48
27
  // Time after the last trigger until a motion event gets triggered again
49
28
  get motionTimeout() {
50
29
  return this._motionTimeout;
@@ -56,62 +35,10 @@ class ZigbeeAquaraMotion extends zigbeeDevice_1.ZigbeeDevice {
56
35
  console.log(`Error occurred while setting motion timeout: ${err}`);
57
36
  });
58
37
  }
59
- get detectionsToday() {
60
- return this._detectionsToday;
61
- }
62
- set detectionsToday(pVal) {
63
- const oldVal = this._detectionsToday;
64
- this._detectionsToday = pVal;
65
- persist_1.Persist.persistTodayCount(this, pVal, oldVal);
66
- }
67
- /**
68
- * Adds a callback for when a motion state has changed.
69
- * @param pCallback Function that accepts the new state as parameter
70
- */
71
- addMovementCallback(pCallback) {
72
- this._movementDetectedCallback.push(pCallback);
73
- }
74
- updateMovement(newState) {
75
- if (!this._initialized && newState) {
76
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Trace, `Movement recognized for "${this.info.customName}", but database initialization has not finished yet --> delay.`);
77
- utils_1.Utils.guardedTimeout(() => {
78
- this.updateMovement(newState);
79
- }, 1000, this);
80
- return;
81
- }
82
- if (newState === this.movementDetected) {
83
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Skip movement for "${this.info.customName}" because state is already ${newState}`);
84
- if (newState) {
85
- // Wenn ein Sensor sich nicht von alleine zurücksetzt, hier erzwingen.
86
- this.resetFallbackTimeout();
87
- this.startFallbackTimeout();
88
- }
89
- return;
90
- }
91
- this.resetFallbackTimeout();
92
- this.movementDetected = newState;
93
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `New movement state for "${this.info.customName}": ${newState}`);
94
- if (newState) {
95
- this.startFallbackTimeout();
96
- this.detectionsToday++;
97
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Trace, `This is movement no. ${this.detectionsToday} for "${this.info.customName}"`);
98
- }
99
- for (const c of this._movementDetectedCallback) {
100
- c(newState);
101
- }
102
- }
103
38
  update(idSplit, state, initial = false) {
104
39
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.DeepTrace, `Motion update for "${this.info.customName}": ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
105
40
  super.update(idSplit, state, initial, true);
106
41
  switch (idSplit[3]) {
107
- case 'occupancy':
108
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Trace, `Motion sensor: Update for motion state of ${this.info.customName}: ${state.val}`);
109
- this.updateMovement(state.val);
110
- break;
111
- case 'no_motion':
112
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Trace, `Motion sensor: Update for time since last motion of ${this.info.customName}: ${state.val}`);
113
- this._timeSinceLastMotion = state.val;
114
- break;
115
42
  case 'illuminance':
116
43
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Trace, `Motion sensor: Update for illuminance of ${this.info.customName}: ${state.val}`);
117
44
  this.currentIllumination = state.val;
@@ -122,18 +49,5 @@ class ZigbeeAquaraMotion extends zigbeeDevice_1.ZigbeeDevice {
122
49
  break;
123
50
  }
124
51
  }
125
- resetFallbackTimeout() {
126
- if (this._fallBackTimeout) {
127
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Trace, `Fallback Timeout für "${this.info.customName}" zurücksetzen`);
128
- clearTimeout(this._fallBackTimeout);
129
- }
130
- }
131
- startFallbackTimeout() {
132
- this._fallBackTimeout = utils_1.Utils.guardedTimeout(() => {
133
- log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Benötige Fallback Bewegungs Reset für "${this.info.customName}"`);
134
- this._fallBackTimeout = undefined;
135
- this.updateMovement(false);
136
- }, 270000, this);
137
- }
138
52
  }
139
53
  exports.ZigbeeAquaraMotion = ZigbeeAquaraMotion;
@@ -5,7 +5,7 @@ import { ZigbeeDevice } from './zigbeeDevice';
5
5
  export declare class ZigbeeAquaraWater extends ZigbeeDevice {
6
6
  water: boolean;
7
7
  private _roomName;
8
- iAlarm: NodeJS.Timeout | undefined;
8
+ iAlarmTimeout: NodeJS.Timeout | undefined;
9
9
  private _messageAlarmFirst;
10
10
  private _messageAlarm;
11
11
  private _messageAlarmEnd;
@@ -14,7 +14,7 @@ class ZigbeeAquaraWater extends zigbeeDevice_1.ZigbeeDevice {
14
14
  super(pInfo, deviceType_1.DeviceType.ZigbeeAquaraWater);
15
15
  this.water = false;
16
16
  this._roomName = '';
17
- this.iAlarm = undefined;
17
+ this.iAlarmTimeout = undefined;
18
18
  this._messageAlarmFirst = '';
19
19
  this._messageAlarm = '';
20
20
  this._messageAlarmEnd = '';
@@ -49,17 +49,17 @@ class ZigbeeAquaraWater extends zigbeeDevice_1.ZigbeeDevice {
49
49
  }
50
50
  }
51
51
  startAlarm() {
52
- if (this.iAlarm !== undefined) {
53
- clearInterval(this.iAlarm);
52
+ if (this.iAlarmTimeout !== undefined) {
53
+ clearInterval(this.iAlarmTimeout);
54
54
  }
55
- this.iAlarm = utils_1.Utils.guardedInterval(() => {
55
+ this.iAlarmTimeout = utils_1.Utils.guardedInterval(() => {
56
56
  this.alarm();
57
57
  }, 15000, this);
58
58
  this.alarm(true);
59
59
  }
60
60
  stopAlarm(quiet = false) {
61
- if (this.iAlarm) {
62
- clearInterval(this.iAlarm);
61
+ if (this.iAlarmTimeout) {
62
+ clearInterval(this.iAlarmTimeout);
63
63
  }
64
64
  if (quiet) {
65
65
  return;
@@ -5,7 +5,7 @@ import { ZigbeeDevice } from './zigbeeDevice';
5
5
  export declare class ZigbeeHeimanSmoke extends ZigbeeDevice {
6
6
  smoke: boolean;
7
7
  private _roomName;
8
- iAlarm: NodeJS.Timeout | undefined;
8
+ iAlarmTimeout: NodeJS.Timeout | undefined;
9
9
  private _messageAlarmFirst;
10
10
  private _messageAlarm;
11
11
  private _messageAlarmEnd;
@@ -15,7 +15,7 @@ class ZigbeeHeimanSmoke extends zigbeeDevice_1.ZigbeeDevice {
15
15
  super(pInfo, deviceType_1.DeviceType.ZigbeeHeimanSmoke);
16
16
  this.smoke = false;
17
17
  this._roomName = '';
18
- this.iAlarm = undefined;
18
+ this.iAlarmTimeout = undefined;
19
19
  this._messageAlarmFirst = '';
20
20
  this._messageAlarm = '';
21
21
  this._messageAlarmEnd = '';
@@ -50,17 +50,17 @@ class ZigbeeHeimanSmoke extends zigbeeDevice_1.ZigbeeDevice {
50
50
  }
51
51
  }
52
52
  startAlarm() {
53
- if (this.iAlarm !== undefined) {
54
- clearInterval(this.iAlarm);
53
+ if (this.iAlarmTimeout !== undefined) {
54
+ clearInterval(this.iAlarmTimeout);
55
55
  }
56
- this.iAlarm = utils_1.Utils.guardedInterval(() => {
56
+ this.iAlarmTimeout = utils_1.Utils.guardedInterval(() => {
57
57
  this.alarm();
58
58
  }, 15000, this);
59
59
  this.alarm(true);
60
60
  }
61
61
  stopAlarm(quiet = false) {
62
- if (this.iAlarm) {
63
- clearInterval(this.iAlarm);
62
+ if (this.iAlarmTimeout) {
63
+ clearInterval(this.iAlarmTimeout);
64
64
  }
65
65
  if (quiet) {
66
66
  return;