hoffmation-base 3.2.0 → 3.2.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/lib/action/baseAction.d.ts +1 -0
  2. package/lib/action/baseAction.js +3 -0
  3. package/lib/command/ShutterSetLevelCommand.d.ts +2 -1
  4. package/lib/command/WindowRestoreDesiredPositionCommand.d.ts +2 -1
  5. package/lib/command/WindowSetDesiredPositionCommand.d.ts +2 -1
  6. package/lib/command/WindowSetRolloByWeatherStatusCommand.d.ts +2 -1
  7. package/lib/command/actuatorSetStateCommand.d.ts +2 -1
  8. package/lib/command/actuatorToggleCommand.d.ts +2 -1
  9. package/lib/command/actuatorWriteStateToDeviceCommand.d.ts +2 -1
  10. package/lib/command/baseCommand.d.ts +10 -3
  11. package/lib/command/baseCommand.js +20 -1
  12. package/lib/command/blockAutomaticCommand.d.ts +2 -1
  13. package/lib/command/blockAutomaticLiftBlockCommand.d.ts +2 -1
  14. package/lib/command/blockAutomaticUntilCommand.d.ts +2 -1
  15. package/lib/command/dimmerSetLightCommand.d.ts +2 -2
  16. package/lib/command/floorSetAllShuttersCommand.d.ts +2 -1
  17. package/lib/command/iBaseCommand.d.ts +58 -0
  18. package/lib/command/iBaseCommand.js +2 -0
  19. package/lib/command/index.d.ts +1 -0
  20. package/lib/command/lampSetLightCommand.d.ts +2 -2
  21. package/lib/command/lampSetTimeBasedCommand.d.ts +2 -1
  22. package/lib/command/lampToggleLightCommand.d.ts +2 -2
  23. package/lib/command/ledSetLightCommand.d.ts +2 -2
  24. package/lib/command/lightGroupSwitchTimeConditionalCommand.d.ts +2 -1
  25. package/lib/command/restoreTargetAutomaticValueCommand.d.ts +2 -1
  26. package/lib/command/roomRestoreLightCommand.d.ts +2 -1
  27. package/lib/command/roomRestoreShutterPositionCommand.d.ts +2 -1
  28. package/lib/command/roomSetLightTimeBasedCommand.d.ts +2 -1
  29. package/lib/command/shutterSunriseUpCommand.d.ts +2 -1
  30. package/lib/command/shutterSunsetDownCommand.d.ts +2 -1
  31. package/lib/command/wledSetLightCommand.d.ts +2 -2
  32. package/lib/command/wledSetLightCommand.js +1 -1
  33. package/lib/devices/BaseDevice.d.ts +43 -0
  34. package/lib/devices/BaseDevice.js +92 -0
  35. package/lib/devices/CameraDevice.d.ts +6 -15
  36. package/lib/devices/CameraDevice.js +33 -51
  37. package/lib/devices/IoBrokerBaseDevice.d.ts +6 -34
  38. package/lib/devices/IoBrokerBaseDevice.js +5 -68
  39. package/lib/devices/RoomBaseDevice.d.ts +9 -0
  40. package/lib/devices/RoomBaseDevice.js +21 -0
  41. package/lib/devices/dachs/dachs.d.ts +4 -17
  42. package/lib/devices/dachs/dachs.js +12 -43
  43. package/lib/devices/dachs/dachsTemperatureSensor.d.ts +3 -24
  44. package/lib/devices/dachs/dachsTemperatureSensor.js +11 -58
  45. package/lib/devices/espresense/detectedBluetoothDevice.d.ts +6 -12
  46. package/lib/devices/espresense/detectedBluetoothDevice.js +13 -18
  47. package/lib/devices/espresense/espresenseDevice.d.ts +3 -19
  48. package/lib/devices/espresense/espresenseDevice.js +19 -51
  49. package/lib/devices/govee/own-govee-device.d.ts +5 -18
  50. package/lib/devices/govee/own-govee-device.js +30 -69
  51. package/lib/devices/groups/heatGroup.js +1 -1
  52. package/lib/devices/groups/lightGroup.js +1 -1
  53. package/lib/devices/hmIPDevices/hmIpLampe.js +1 -1
  54. package/lib/devices/hmIPDevices/hmIpRoll.js +2 -2
  55. package/lib/devices/index.d.ts +1 -0
  56. package/lib/devices/index.js +3 -1
  57. package/lib/devices/scene/room-scene.d.ts +2 -23
  58. package/lib/devices/scene/room-scene.js +12 -57
  59. package/lib/devices/sharedFunctions/lampUtils.js +4 -3
  60. package/lib/devices/shelly/shellyActuator.js +1 -1
  61. package/lib/devices/tv/tvDevice.d.ts +4 -16
  62. package/lib/devices/tv/tvDevice.js +12 -36
  63. package/lib/devices/velux/veluxShutter.js +1 -1
  64. package/lib/devices/victron/victron-device.d.ts +2 -15
  65. package/lib/devices/victron/victron-device.js +11 -43
  66. package/lib/devices/wledDevice.js +2 -2
  67. package/lib/devices/zigbee/BaseDevices/ZigbeeActuator.js +1 -1
  68. package/lib/devices/zigbee/BaseDevices/zigbeeShutter.d.ts +0 -3
  69. package/lib/devices/zigbee/BaseDevices/zigbeeShutter.js +4 -11
  70. package/lib/index.d.ts +2 -2
  71. package/lib/index.js +2 -2
  72. package/lib/interfaces/baseDevices/iAcDevice.d.ts +4 -0
  73. package/lib/interfaces/baseDevices/iBaseDevice.d.ts +11 -1
  74. package/lib/services/Sonos/own-sonos-device.d.ts +4 -14
  75. package/lib/services/Sonos/own-sonos-device.js +8 -46
  76. package/lib/services/ac/ac-device.d.ts +6 -22
  77. package/lib/services/ac/ac-device.js +23 -53
  78. package/lib/services/ac/own-daikin-device.js +2 -2
  79. package/lib/tsconfig.tsbuildinfo +1 -1
  80. package/lib/utils/utils.d.ts +2 -1
  81. package/lib/utils/utils.js +15 -2
  82. package/package.json +1 -1
@@ -130,7 +130,7 @@ class HeatGroup extends base_group_1.BaseGroup {
130
130
  });
131
131
  });
132
132
  this.getOwnAcDevices().forEach((acDev) => {
133
- acDev.room = this.getRoom();
133
+ acDev.initializeRoomCbs();
134
134
  });
135
135
  (_a = this.getRoom().WindowGroup) === null || _a === void 0 ? void 0 : _a.addHandleChangeCallback((handleChangeAction) => {
136
136
  this.getHeater().forEach((heater) => {
@@ -52,7 +52,7 @@ class LightGroup extends base_group_1.BaseGroup {
52
52
  switchAll(c) {
53
53
  this.getAllAsActuator().forEach((a) => {
54
54
  if (a.settings.includeInAmbientLight && !c.isForceAction && !c.on && this._ambientLightOn) {
55
- a.log(enums_1.LogLevel.Info, `Ambient light mode is active --> Skip non force light off command in ${this.roomName}; command: ${c.logMessage}`);
55
+ a.logCommand(c, `Ambient light mode is active --> Skip non force light off command in ${this.roomName}`, enums_1.LogDebugType.None, enums_1.LogLevel.Info);
56
56
  return;
57
57
  }
58
58
  a.setActuator(c);
@@ -61,7 +61,7 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
61
61
  sharedFunctions_1.LampUtils.setActuator(this, c);
62
62
  }
63
63
  writeActuatorStateToDevice(c) {
64
- this.log(enums_1.LogLevel.Debug, c.logMessage, enums_1.LogDebugType.SetActuator);
64
+ this.logCommand(c, undefined, enums_1.LogDebugType.SetActuator);
65
65
  this.setState(this.lightOnSwitchID, c.stateValue, undefined, (err) => {
66
66
  this.log(enums_1.LogLevel.Error, `Lampe schalten ergab Fehler: ${err}`);
67
67
  });
@@ -88,7 +88,7 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
88
88
  return;
89
89
  }
90
90
  if (this.currentLevel === targetLevel && !command.isForceAction) {
91
- this.log(enums_1.LogLevel.Debug, `Skip Rollo command to Position ${targetLevel} as this is the current one, commandLog: ${command.logMessage}`, enums_1.LogDebugType.SkipUnchangedRolloPosition);
91
+ this.logCommand(command, `Skip Rollo command to Position ${targetLevel} as this is the current one`, enums_1.LogDebugType.SkipUnchangedRolloPosition);
92
92
  return;
93
93
  }
94
94
  if (this._setLevelSwitchID === '') {
@@ -98,7 +98,7 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
98
98
  if (!this.checkIoConnection(true)) {
99
99
  return;
100
100
  }
101
- this.log(enums_1.LogLevel.Debug, command.logMessage);
101
+ this.logCommand(command);
102
102
  if (this._window !== undefined) {
103
103
  if (this._window.griffeInPosition(enums_1.WindowPosition.open) > 0 && command.level < 100) {
104
104
  if (!command.skipOpenWarning) {
@@ -31,3 +31,4 @@ export * from './CameraDevice';
31
31
  export * from './govee';
32
32
  export * from './unifi';
33
33
  export * from './victron';
34
+ export { RoomBaseDevice } from './RoomBaseDevice';
@@ -14,7 +14,7 @@ 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
- exports.NameAmountValuePair = void 0;
17
+ exports.RoomBaseDevice = exports.NameAmountValuePair = void 0;
18
18
  __exportStar(require("../settingsObjects/deviceSettings"), exports);
19
19
  __exportStar(require("./blueIris"), exports);
20
20
  __exportStar(require("./button"), exports);
@@ -49,3 +49,5 @@ __exportStar(require("./CameraDevice"), exports);
49
49
  __exportStar(require("./govee"), exports);
50
50
  __exportStar(require("./unifi"), exports);
51
51
  __exportStar(require("./victron"), exports);
52
+ var RoomBaseDevice_1 = require("./RoomBaseDevice");
53
+ Object.defineProperty(exports, "RoomBaseDevice", { enumerable: true, get: function () { return RoomBaseDevice_1.RoomBaseDevice; } });
@@ -1,34 +1,21 @@
1
1
  import { iRoomBase, iScene } from '../../interfaces';
2
2
  import { SceneSettings } from '../../settingsObjects';
3
- import { DeviceCapability, DeviceType, LogDebugType, LogLevel } from '../../enums';
4
- import { DeviceInfo } from '../DeviceInfo';
5
- import { TvDevice } from '../tv';
6
- export declare class RoomScene implements iScene {
3
+ import { RoomBaseDevice } from '../RoomBaseDevice';
4
+ export declare class RoomScene extends RoomBaseDevice implements iScene {
7
5
  /** @inheritDoc */
8
6
  description: string;
9
7
  /** @inheritDoc */
10
- room: iRoomBase | undefined;
11
- /** @inheritDoc */
12
8
  settings: SceneSettings;
13
- protected _deviceType: DeviceType;
14
- protected _info: DeviceInfo;
15
9
  private readonly _onSceneStart;
16
10
  private readonly _onSceneEnd;
17
11
  private _automaticEndTimeout;
18
- private _deviceCapabilities;
19
12
  private _on;
20
13
  constructor(name: string, room: iRoomBase, onSceneStart: () => void, onSceneEnd: () => void, turnOffTimeout?: number);
21
14
  /** @inheritDoc */
22
15
  get customName(): string;
23
16
  /** @inheritDoc */
24
- get deviceType(): DeviceType;
25
- /** @inheritDoc */
26
- get info(): DeviceInfo;
27
- /** @inheritDoc */
28
17
  get automaticEndTimeout(): NodeJS.Timeout | null;
29
18
  /** @inheritDoc */
30
- get deviceCapabilities(): DeviceCapability[];
31
- /** @inheritDoc */
32
19
  get on(): boolean;
33
20
  get name(): string;
34
21
  /** @inheritDoc */
@@ -41,12 +28,4 @@ export declare class RoomScene implements iScene {
41
28
  startScene(timeout?: number | undefined): void;
42
29
  /** @inheritDoc */
43
30
  endScene(): void;
44
- /** @inheritDoc */
45
- log(level: LogLevel, message: string, debugType?: LogDebugType): void;
46
- /** @inheritDoc */
47
- persistDeviceInfo(): void;
48
- /** @inheritDoc */
49
- loadDeviceSettings(): void;
50
- /** @inheritDoc */
51
- toJSON(): Partial<TvDevice>;
52
31
  }
@@ -1,61 +1,43 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.RoomScene = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
8
- const services_1 = require("../../services");
9
4
  const settingsObjects_1 = require("../../settingsObjects");
10
5
  const enums_1 = require("../../enums");
11
6
  const DeviceInfo_1 = require("../DeviceInfo");
12
7
  const devices_1 = require("../devices");
13
8
  const utils_1 = require("../../utils");
14
- const logging_1 = require("../../logging");
15
- class RoomScene {
9
+ const RoomBaseDevice_1 = require("../RoomBaseDevice");
10
+ class RoomScene extends RoomBaseDevice_1.RoomBaseDevice {
16
11
  constructor(name, room, onSceneStart, onSceneEnd, turnOffTimeout) {
12
+ const info = new DeviceInfo_1.DeviceInfo();
13
+ info.fullName = `Scene ${name}`;
14
+ info.customName = `${room.roomName} ${name}`;
15
+ info.room = room.roomName;
16
+ const allDevicesKey = `scene-${room.roomName}-${name}`;
17
+ info.allDevicesKey = allDevicesKey;
18
+ super(info, enums_1.DeviceType.RoomScene);
17
19
  /** @inheritDoc */
18
20
  this.description = '';
19
21
  /** @inheritDoc */
20
22
  this.settings = new settingsObjects_1.SceneSettings();
21
23
  this._automaticEndTimeout = null;
22
- this._deviceCapabilities = [enums_1.DeviceCapability.scene];
23
24
  this._on = false;
25
+ this.jsonOmitKeys.push(...['_onSceneStart', '_onSceneEnd']);
26
+ this.deviceCapabilities.push(enums_1.DeviceCapability.scene);
27
+ devices_1.Devices.alLDevices[allDevicesKey] = this;
24
28
  this._onSceneStart = onSceneStart;
25
29
  this._onSceneEnd = onSceneEnd;
26
- this.room = room;
27
30
  this.settings.defaultTurnOffTimeout = turnOffTimeout;
28
- this._info = new DeviceInfo_1.DeviceInfo();
29
- this._info.fullName = `Scene ${name}`;
30
- this._info.customName = `${room.roomName} ${name}`;
31
- this._info.room = room.roomName;
32
- this._info.allDevicesKey = `scene-${room.roomName}-${name}`;
33
- this._deviceType = enums_1.DeviceType.RoomScene;
34
- devices_1.Devices.alLDevices[this._info.allDevicesKey] = this;
35
- this.persistDeviceInfo();
36
- this.loadDeviceSettings();
37
31
  }
38
32
  /** @inheritDoc */
39
33
  get customName() {
40
34
  return this.info.customName;
41
35
  }
42
36
  /** @inheritDoc */
43
- get deviceType() {
44
- return this._deviceType;
45
- }
46
- /** @inheritDoc */
47
- get info() {
48
- return this._info;
49
- }
50
- /** @inheritDoc */
51
37
  get automaticEndTimeout() {
52
38
  return this._automaticEndTimeout;
53
39
  }
54
40
  /** @inheritDoc */
55
- get deviceCapabilities() {
56
- return this._deviceCapabilities;
57
- }
58
- /** @inheritDoc */
59
41
  get on() {
60
42
  return this._on;
61
43
  }
@@ -105,32 +87,5 @@ class RoomScene {
105
87
  this._on = false;
106
88
  this._onSceneEnd();
107
89
  }
108
- /** @inheritDoc */
109
- log(level, message, debugType = enums_1.LogDebugType.None) {
110
- var _a, _b;
111
- logging_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
112
- debugType: debugType,
113
- room: (_b = (_a = this.room) === null || _a === void 0 ? void 0 : _a.roomName) !== null && _b !== void 0 ? _b : '',
114
- deviceId: this.name,
115
- deviceName: this.name,
116
- });
117
- }
118
- /** @inheritDoc */
119
- persistDeviceInfo() {
120
- utils_1.Utils.guardedTimeout(() => {
121
- var _a;
122
- (_a = services_1.Persistence.dbo) === null || _a === void 0 ? void 0 : _a.addDevice(this);
123
- }, 5000, this);
124
- }
125
- /** @inheritDoc */
126
- loadDeviceSettings() {
127
- this.settings.initializeFromDb(this);
128
- }
129
- /** @inheritDoc */
130
- toJSON() {
131
- // eslint-disable-next-line
132
- const result = lodash_1.default.omit(this, ['room', '_onSceneStart', '_onSceneEnd']);
133
- return utils_1.Utils.jsonFilter(result);
134
- }
135
90
  }
136
91
  exports.RoomScene = RoomScene;
@@ -61,7 +61,7 @@ class LampUtils {
61
61
  }
62
62
  static checkBlockActive(device, c) {
63
63
  if (!c.isForceAction && device.blockAutomationHandler.automaticBlockActive) {
64
- device.log(enums_1.LogLevel.Debug, `Skip command to ${c.on} as it is locked until ${new Date(device.blockAutomationHandler.automaticBlockedUntil).toLocaleTimeString('de-DE')}; command Log: ${c.logMessage}`);
64
+ device.logCommand(c, `Skip command to ${c.on} as it is locked until ${new Date(device.blockAutomationHandler.automaticBlockedUntil).toLocaleTimeString('de-DE')}`);
65
65
  device.targetAutomaticState = c.on;
66
66
  return true;
67
67
  }
@@ -95,7 +95,7 @@ class LampUtils {
95
95
  return false;
96
96
  }
97
97
  if (!noLog) {
98
- device.log(enums_1.LogLevel.DeepTrace, `Light command can be skipped as device is already in desired state; command: ${c.logMessage}`, enums_1.LogDebugType.SkipUnchangedActuatorCommand);
98
+ device.logCommand(c, `Light command can be skipped as device is already in desired state`, enums_1.LogDebugType.SkipUnchangedActuatorCommand);
99
99
  }
100
100
  return true;
101
101
  }
@@ -103,7 +103,7 @@ class LampUtils {
103
103
  if (device.settings.isStromStoss &&
104
104
  c.on &&
105
105
  c.containsType(enums_1.CommandType.ActuatorRestoreTargetAutomaticValueCommand)) {
106
- // Don't restore automatic state on Strommstoss-Relais as this might result in a loop.
106
+ device.logCommand(c, "Don't restore automatic state on Strommstoss-Relais as this might result in a loop.");
107
107
  return;
108
108
  }
109
109
  const dontBlock = LampUtils.checkUnBlock(device, c);
@@ -115,6 +115,7 @@ class LampUtils {
115
115
  device.targetAutomaticState = c.on;
116
116
  }
117
117
  if (LampUtils.canActuatorChangeBeSkipped(device, c)) {
118
+ device.logCommand(c, 'Actuator change can be skipped');
118
119
  return;
119
120
  }
120
121
  device.queuedValue = c.on;
@@ -75,7 +75,7 @@ class ShellyActuator extends shellyDevice_1.ShellyDevice {
75
75
  }
76
76
  /** @inheritDoc */
77
77
  writeActuatorStateToDevice(c) {
78
- this.log(enums_1.LogLevel.Debug, c.logMessage, enums_1.LogDebugType.SetActuator);
78
+ this.logCommand(c, undefined, enums_1.LogDebugType.SetActuator);
79
79
  this.setState(this._actuatorOnStateId, c.stateValue, undefined, (err) => {
80
80
  this.log(enums_1.LogLevel.Error, `Lampe schalten ergab Fehler: ${err}`);
81
81
  });
@@ -1,37 +1,25 @@
1
- import { DeviceCapability, DeviceType, LogDebugType, LogLevel, TvDeviceType } from '../../enums';
1
+ import { DeviceCapability, DeviceType, TvDeviceType } from '../../enums';
2
2
  import { iTvDevice } from '../../interfaces';
3
3
  import { TvSettings } from '../../settingsObjects';
4
- import { RoomBase } from '../../services';
5
- import { DeviceInfo } from '../DeviceInfo';
6
- export declare abstract class TvDevice implements iTvDevice {
4
+ import { RoomBaseDevice } from '../RoomBaseDevice';
5
+ export declare abstract class TvDevice extends RoomBaseDevice implements iTvDevice {
7
6
  ip: string;
8
7
  tvDeviceType: TvDeviceType;
9
8
  /** @inheritDoc */
10
9
  settings: TvSettings;
11
- /**
12
- * @inheritDoc
13
- */
14
- room: RoomBase | undefined;
15
10
  /**
16
11
  * @inheritDoc
17
12
  */
18
13
  deviceCapabilities: DeviceCapability[];
19
- protected constructor(name: string, roomName: string, ip: string, tvDeviceType: TvDeviceType);
20
- protected _info: DeviceInfo;
21
- get info(): DeviceInfo;
22
- abstract get deviceType(): DeviceType;
14
+ protected constructor(name: string, roomName: string, ip: string, tvDeviceType: TvDeviceType, deviceType: DeviceType);
23
15
  get name(): string;
24
16
  get id(): string;
25
- get customName(): string;
26
17
  abstract get on(): boolean;
27
18
  abstract volumeDown(): void;
28
19
  abstract volumeUp(): void;
29
20
  abstract turnOn(): void;
30
21
  abstract turnOff(): void;
31
22
  turnOffDueToMissingEnergy(): void;
32
- log(level: LogLevel, message: string, debugType?: LogDebugType): void;
33
23
  automaticCheck(): void;
34
- persistDeviceInfo(): void;
35
- loadDeviceSettings(): void;
36
24
  toJSON(): Partial<TvDevice>;
37
25
  }
@@ -7,12 +7,18 @@ exports.TvDevice = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const enums_1 = require("../../enums");
9
9
  const settingsObjects_1 = require("../../settingsObjects");
10
- const services_1 = require("../../services");
11
10
  const DeviceInfo_1 = require("../DeviceInfo");
12
11
  const utils_1 = require("../../utils");
13
- const logging_1 = require("../../logging");
14
- class TvDevice {
15
- constructor(name, roomName, ip, tvDeviceType) {
12
+ const RoomBaseDevice_1 = require("../RoomBaseDevice");
13
+ class TvDevice extends RoomBaseDevice_1.RoomBaseDevice {
14
+ constructor(name, roomName, ip, tvDeviceType, deviceType) {
15
+ const info = new DeviceInfo_1.DeviceInfo();
16
+ info.fullName = `TV ${name}`;
17
+ info.customName = `${roomName} ${name}`;
18
+ info.room = roomName;
19
+ const allDevicesKey = `tv-${roomName}-${name}`;
20
+ info.allDevicesKey = allDevicesKey;
21
+ super(info, deviceType);
16
22
  this.ip = ip;
17
23
  this.tvDeviceType = tvDeviceType;
18
24
  /** @inheritDoc */
@@ -21,17 +27,8 @@ class TvDevice {
21
27
  * @inheritDoc
22
28
  */
23
29
  this.deviceCapabilities = [enums_1.DeviceCapability.tv];
24
- this._info = new DeviceInfo_1.DeviceInfo();
25
- this._info.fullName = `TV ${name}`;
26
- this._info.customName = `${roomName} ${name}`;
27
- this._info.room = roomName;
28
- this._info.allDevicesKey = `tv-${roomName}-${name}`;
30
+ this.deviceCapabilities.push(enums_1.DeviceCapability.tv);
29
31
  utils_1.Utils.guardedInterval(this.automaticCheck, 60000, this, false);
30
- this.persistDeviceInfo();
31
- this.loadDeviceSettings();
32
- }
33
- get info() {
34
- return this._info;
35
32
  }
36
33
  get name() {
37
34
  return this.info.customName;
@@ -40,36 +37,15 @@ class TvDevice {
40
37
  var _a;
41
38
  return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `ac-${this.info.room}-${this.info.customName}`;
42
39
  }
43
- get customName() {
44
- return this.info.customName;
45
- }
46
40
  turnOffDueToMissingEnergy() {
47
41
  this.turnOff();
48
42
  }
49
- log(level, message, debugType = enums_1.LogDebugType.None) {
50
- var _a, _b;
51
- logging_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
52
- debugType: debugType,
53
- room: (_b = (_a = this.room) === null || _a === void 0 ? void 0 : _a.roomName) !== null && _b !== void 0 ? _b : '',
54
- deviceId: this.name,
55
- deviceName: this.name,
56
- });
57
- }
58
43
  automaticCheck() {
59
44
  // TODO: Implement automatic turn off
60
45
  }
61
- persistDeviceInfo() {
62
- utils_1.Utils.guardedTimeout(() => {
63
- var _a;
64
- (_a = services_1.Persistence.dbo) === null || _a === void 0 ? void 0 : _a.addDevice(this);
65
- }, 5000, this);
66
- }
67
- loadDeviceSettings() {
68
- this.settings.initializeFromDb(this);
69
- }
70
46
  toJSON() {
71
47
  // eslint-disable-next-line
72
- const result = lodash_1.default.omit(this, ['room']);
48
+ const result = lodash_1.default.omit(super.toJSON(), ['room']);
73
49
  result['on'] = this.on;
74
50
  return utils_1.Utils.jsonFilter(result);
75
51
  }
@@ -83,7 +83,7 @@ class VeluxShutter extends veluxDevice_1.VeluxDevice {
83
83
  if (!this.checkIoConnection(true)) {
84
84
  return;
85
85
  }
86
- this.log(enums_1.LogLevel.Debug, command.logMessage);
86
+ this.logCommand(command);
87
87
  if (this._window !== undefined) {
88
88
  if (this._window.griffeInPosition(enums_1.WindowPosition.open) > 0 && command.level < 100) {
89
89
  if (!command.skipOpenWarning) {
@@ -1,21 +1,13 @@
1
1
  import { iBatteryDevice, iEnergyManager, iExcessEnergyConsumer, iJsonOmitKeys } from '../../interfaces';
2
- import { DeviceCapability, DeviceType, LogDebugType, LogLevel } from '../../enums';
3
2
  import { VictronDeviceSettings } from '../../settingsObjects';
4
3
  import { Battery } from '../sharedFunctions';
5
- import { DeviceInfo } from '../DeviceInfo';
6
4
  import { VictronDeviceData, VictronMqttConnectionOptions, VictronMqttConsumer } from 'victron-mqtt-consumer';
7
- export declare class VictronDevice implements iEnergyManager, iBatteryDevice, iJsonOmitKeys {
8
- /** @inheritDoc */
9
- readonly jsonOmitKeys: string[];
10
- /** @inheritDoc */
11
- readonly deviceCapabilities: DeviceCapability[];
12
- /** @inheritDoc */
13
- deviceType: DeviceType;
5
+ import { BaseDevice } from '../BaseDevice';
6
+ export declare class VictronDevice extends BaseDevice implements iEnergyManager, iBatteryDevice, iJsonOmitKeys {
14
7
  /** @inheritDoc */
15
8
  readonly settings: VictronDeviceSettings;
16
9
  /** @inheritDoc */
17
10
  readonly battery: Battery;
18
- protected _info: DeviceInfo;
19
11
  private readonly _victronConsumer;
20
12
  private _excessEnergyConsumer;
21
13
  private blockDeviceChangeTime;
@@ -28,14 +20,12 @@ export declare class VictronDevice implements iEnergyManager, iBatteryDevice, iJ
28
20
  constructor(opts: VictronMqttConnectionOptions);
29
21
  /** @inheritDoc */
30
22
  get acBlocked(): boolean;
31
- get info(): DeviceInfo;
32
23
  /** @inheritDoc */
33
24
  get batteryLevel(): number;
34
25
  get victronConsumer(): VictronMqttConsumer;
35
26
  get data(): VictronDeviceData;
36
27
  get excessEnergy(): number;
37
28
  get name(): string;
38
- get customName(): string;
39
29
  get id(): string;
40
30
  get injectingWattage(): number;
41
31
  get drawingWattage(): number;
@@ -45,9 +35,6 @@ export declare class VictronDevice implements iEnergyManager, iBatteryDevice, iJ
45
35
  dispose(): void;
46
36
  getReport(): string;
47
37
  recalculatePowerSharing(): void;
48
- loadDeviceSettings(): void;
49
- log(level: LogLevel, message: string, debugType?: LogDebugType): void;
50
- persistDeviceInfo(): void;
51
38
  toJSON(): Partial<VictronDevice>;
52
39
  /**
53
40
  * Changes the grid set point of the Victron device, to the desired value.
@@ -9,20 +9,15 @@ const victron_mqtt_consumer_1 = require("victron-mqtt-consumer");
9
9
  const utils_1 = require("../../utils");
10
10
  const models_1 = require("../../models");
11
11
  const devices_1 = require("../devices");
12
- const logging_1 = require("../../logging");
13
12
  const services_1 = require("../../services");
14
- const sun_time_offsets_1 = require("../../models/sun-time-offsets");
15
- class VictronDevice {
13
+ const BaseDevice_1 = require("../BaseDevice");
14
+ class VictronDevice extends BaseDevice_1.BaseDevice {
16
15
  constructor(opts) {
17
- /** @inheritDoc */
18
- this.jsonOmitKeys = ['_victronConsumer', '_excessEnergyConsumer'];
19
- /** @inheritDoc */
20
- this.deviceCapabilities = [
21
- enums_1.DeviceCapability.energyManager,
22
- enums_1.DeviceCapability.batteryDriven,
23
- ];
24
- /** @inheritDoc */
25
- this.deviceType = enums_1.DeviceType.Victron;
16
+ const info = new DeviceInfo_1.DeviceInfo();
17
+ info.fullName = 'Victron Device';
18
+ info.customName = 'Victron';
19
+ info.allDevicesKey = 'victron';
20
+ super(info, enums_1.DeviceType.Victron);
26
21
  /** @inheritDoc */
27
22
  this.battery = new sharedFunctions_1.Battery(this);
28
23
  this._excessEnergyConsumer = [];
@@ -32,14 +27,10 @@ class VictronDevice {
32
27
  this._lastPersistenceCalculation = utils_1.Utils.nowMS();
33
28
  this._excessEnergy = 0;
34
29
  this.settings = new settingsObjects_1.VictronDeviceSettings();
35
- this._info = new DeviceInfo_1.DeviceInfo();
36
- this._info.fullName = 'Victron Device';
37
- this._info.customName = 'Victron';
38
- this._info.allDevicesKey = 'victron';
30
+ this.deviceCapabilities.push(...[enums_1.DeviceCapability.energyManager, enums_1.DeviceCapability.batteryDriven]);
31
+ this.jsonOmitKeys.push(...['_victronConsumer', '_excessEnergyConsumer']);
39
32
  devices_1.Devices.alLDevices['victron'] = this;
40
33
  devices_1.Devices.energymanager = this;
41
- this.persistDeviceInfo();
42
- utils_1.Utils.guardedTimeout(this.loadDeviceSettings, 4500, this);
43
34
  this._victronConsumer = new victron_mqtt_consumer_1.VictronMqttConsumer(opts);
44
35
  this._iCalculationInterval = utils_1.Utils.guardedInterval(() => {
45
36
  if (this.data.battery.soc) {
@@ -66,9 +57,6 @@ class VictronDevice {
66
57
  }
67
58
  return false;
68
59
  }
69
- get info() {
70
- return this._info;
71
- }
72
60
  /** @inheritDoc */
73
61
  get batteryLevel() {
74
62
  const level = this.data.battery.soc;
@@ -90,9 +78,6 @@ class VictronDevice {
90
78
  get name() {
91
79
  return this.info.customName;
92
80
  }
93
- get customName() {
94
- return this.info.customName;
95
- }
96
81
  get id() {
97
82
  var _a;
98
83
  return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `victron-${this.info.room}-${this.info.customName}`;
@@ -140,23 +125,6 @@ class VictronDevice {
140
125
  this.turnOffAdditionalConsumer();
141
126
  }
142
127
  }
143
- loadDeviceSettings() {
144
- this.settings.initializeFromDb(this);
145
- }
146
- log(level, message, debugType = enums_1.LogDebugType.None) {
147
- logging_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
148
- debugType: debugType,
149
- room: '',
150
- deviceId: this.name,
151
- deviceName: this.name,
152
- });
153
- }
154
- persistDeviceInfo() {
155
- utils_1.Utils.guardedTimeout(() => {
156
- var _a;
157
- (_a = services_1.Persistence.dbo) === null || _a === void 0 ? void 0 : _a.addDevice(this);
158
- }, 5000, this);
159
- }
160
128
  toJSON() {
161
129
  return {
162
130
  ...{
@@ -167,7 +135,7 @@ class VictronDevice {
167
135
  injectingWattage: this.injectingWattage,
168
136
  selfConsumingWattage: this.selfConsumingWattage,
169
137
  },
170
- ...utils_1.Utils.jsonFilter(this, this.jsonOmitKeys),
138
+ ...utils_1.Utils.jsonFilter(super.toJSON(), this.jsonOmitKeys),
171
139
  };
172
140
  }
173
141
  /**
@@ -187,7 +155,7 @@ class VictronDevice {
187
155
  // Step 1: Calculate battery need
188
156
  const hoursTilSunset = services_1.TimeCallbackService.hoursTilSunset();
189
157
  let neededBatteryWattage = 0;
190
- const timeOfDay = services_1.TimeCallbackService.dayType(new sun_time_offsets_1.SunTimeOffsets());
158
+ const timeOfDay = services_1.TimeCallbackService.dayType(new models_1.SunTimeOffsets());
191
159
  if (this.settings.hasBattery && timeOfDay !== enums_1.TimeOfDay.AfterSunset && timeOfDay !== enums_1.TimeOfDay.Night) {
192
160
  if (this.batteryLevel < 0) {
193
161
  this.log(enums_1.LogLevel.Debug, 'No battery data available from Victron device.');
@@ -72,7 +72,7 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
72
72
  if (sharedFunctions_1.LampUtils.canDimmerChangeBeSkipped(this, c)) {
73
73
  return;
74
74
  }
75
- this.log(enums_1.LogLevel.Debug, c.logMessage);
75
+ this.logCommand(c);
76
76
  if (c.on && c.brightness !== -1 && this.brightness < 10) {
77
77
  c.brightness = 10;
78
78
  }
@@ -126,7 +126,7 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
126
126
  }
127
127
  /** @inheritDoc */
128
128
  writeActuatorStateToDevice(c) {
129
- this.log(enums_1.LogLevel.Debug, c.logMessage, enums_1.LogDebugType.SetActuator);
129
+ this.logCommand(c, undefined, enums_1.LogDebugType.SetActuator);
130
130
  this.setState(this._onID, c.stateValue, undefined, (err) => {
131
131
  logging_1.ServerLogService.writeLog(enums_1.LogLevel.Error, `WLED schalten ergab Fehler: ${err}`);
132
132
  });
@@ -76,7 +76,7 @@ class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
76
76
  }
77
77
  /** @inheritDoc */
78
78
  writeActuatorStateToDevice(c) {
79
- this.log(enums_1.LogLevel.Debug, c.logMessage, enums_1.LogDebugType.SetActuator);
79
+ this.logCommand(c, undefined, enums_1.LogDebugType.SetActuator);
80
80
  this.setState(this._actuatorOnStateIdState, c.stateValue, undefined, (err) => {
81
81
  this.log(enums_1.LogLevel.Error, `Lampe schalten ergab Fehler: ${err}`);
82
82
  });
@@ -4,7 +4,6 @@ import { ShutterSettings } from '../../../settingsObjects';
4
4
  import { ShutterSetLevelCommand } from '../../../command';
5
5
  import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
6
6
  import { DeviceType } from '../../../enums';
7
- import { IoBrokerBaseDevice } from '../../IoBrokerBaseDevice';
8
7
  import { ShutterCalibration } from '../../../models';
9
8
  export declare class ZigbeeShutter extends ZigbeeDevice implements iShutter {
10
9
  /** @inheritDoc */
@@ -31,8 +30,6 @@ export declare class ZigbeeShutter extends ZigbeeDevice implements iShutter {
31
30
  update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverride?: boolean): void;
32
31
  /** @inheritDoc */
33
32
  setLevel(c: ShutterSetLevelCommand): void;
34
- /** @inheritDoc */
35
- toJSON(): Partial<IoBrokerBaseDevice>;
36
33
  protected setCurrentLevel(value: number, isInitial?: boolean): void;
37
34
  protected moveToPosition(pPosition: number): void;
38
35
  protected getAverageUp(): number;
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ZigbeeShutter = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
8
4
  const zigbeeDevice_1 = require("./zigbeeDevice");
9
5
  const settingsObjects_1 = require("../../../settingsObjects");
10
6
  const command_1 = require("../../../command");
@@ -25,6 +21,7 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
25
21
  this._shutterCalibrationData = new models_1.ShutterCalibration(this.info.fullID, 0, 0, 0, 0);
26
22
  this._currentLevel = -1;
27
23
  this.deviceCapabilities.push(enums_1.DeviceCapability.shutter);
24
+ this.jsonOmitKeys.push('_window');
28
25
  (_a = this.dbo) === null || _a === void 0 ? void 0 : _a.getShutterCalibration(this).then((calibrationData) => {
29
26
  this._shutterCalibrationData = calibrationData;
30
27
  this.log(enums_1.LogLevel.DeepTrace, 'ZigbeeShutter initialized with calibration data');
@@ -77,14 +74,14 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
77
74
  this._firstCommandRecieved = true;
78
75
  }
79
76
  else if (this._firstCommandRecieved && c.isInitial) {
80
- this.log(enums_1.LogLevel.Debug, `Skipped initial shutter to ${pPosition} as we recieved a command already`);
77
+ this.logCommand(c, `Skipped initial shutter to ${pPosition} as we recieved a command already`);
81
78
  return;
82
79
  }
83
80
  if (this.currentLevel === pPosition && !c.isForceAction) {
84
- this.log(enums_1.LogLevel.Debug, `Skip shutter command to Position ${pPosition} as this is the current one, commandLog: ${c.logMessage}`, enums_1.LogDebugType.SkipUnchangedRolloPosition);
81
+ this.logCommand(c, `Skip shutter command to Position ${pPosition} as this is the current one`, enums_1.LogDebugType.SkipUnchangedRolloPosition);
85
82
  return;
86
83
  }
87
- this.log(enums_1.LogLevel.Debug, c.logMessage);
84
+ this.logCommand(c);
88
85
  if (this._window !== undefined) {
89
86
  if (this._window.griffeInPosition(enums_1.WindowPosition.open) > 0 && pPosition < 100) {
90
87
  if (!c.skipOpenWarning) {
@@ -103,10 +100,6 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
103
100
  this.log(enums_1.LogLevel.Debug, `Move to position ${pPosition}`);
104
101
  this.moveToPosition(pPosition);
105
102
  }
106
- /** @inheritDoc */
107
- toJSON() {
108
- return lodash_1.default.omit(super.toJSON(), ['_window']);
109
- }
110
103
  setCurrentLevel(value, isInitial = false) {
111
104
  if (value !== this._setLevel && utils_1.Utils.nowMS() - this._setLevelTime < 60 * 10000) {
112
105
  value = this._setLevel;