hoffmation-base 3.2.0 → 3.2.1-alpha.0

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 +4 -19
  44. package/lib/devices/dachs/dachsTemperatureSensor.js +11 -37
  45. package/lib/devices/espresense/detectedBluetoothDevice.d.ts +5 -11
  46. package/lib/devices/espresense/detectedBluetoothDevice.js +15 -17
  47. package/lib/devices/espresense/espresenseDevice.d.ts +3 -19
  48. package/lib/devices/espresense/espresenseDevice.js +11 -45
  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
@@ -1,31 +1,18 @@
1
- import { iRoomBase, iTemperatureCollector } from '../../interfaces';
1
+ import { iTemperatureCollector } from '../../interfaces';
2
2
  import { DeviceSettings } from '../../settingsObjects';
3
- import { DeviceCapability, DeviceType, LogDebugType, LogLevel } from '../../enums';
4
3
  import { TemperatureSensor } from '../sharedFunctions';
5
- import { DeviceInfo } from '../DeviceInfo';
6
- import { OwnSonosDevice } from '../../services';
7
4
  import { TemperatureSensorChangeAction } from '../../action';
8
- export declare class DachsTemperatureSensor implements iTemperatureCollector {
5
+ import { RoomBaseDevice } from '../RoomBaseDevice';
6
+ export declare class DachsTemperatureSensor extends RoomBaseDevice implements iTemperatureCollector {
9
7
  /** @inheritDoc */
10
8
  settings: DeviceSettings | undefined;
11
9
  /** @inheritDoc */
12
- readonly deviceType: DeviceType;
13
- /** @inheritDoc */
14
- readonly deviceCapabilities: DeviceCapability[];
15
- /** @inheritDoc */
16
10
  temperatureSensor: TemperatureSensor;
17
- protected _info: DeviceInfo;
18
11
  constructor(roomName: string, shortKey: string, longKey: string);
19
12
  /** @inheritDoc */
20
- get customName(): string;
21
- /** @inheritDoc */
22
- get info(): DeviceInfo;
23
- /** @inheritDoc */
24
13
  get id(): string;
25
14
  get name(): string;
26
15
  /** @inheritDoc */
27
- get room(): iRoomBase | undefined;
28
- /** @inheritDoc */
29
16
  get roomTemperature(): number;
30
17
  /** @inheritDoc */
31
18
  set roomTemperature(value: number);
@@ -39,9 +26,7 @@ export declare class DachsTemperatureSensor implements iTemperatureCollector {
39
26
  /** @inheritDoc */
40
27
  onTemperaturChange(newTemperatur: number): void;
41
28
  /** @inheritDoc */
42
- log(level: LogLevel, message: string, debugType?: LogDebugType): void;
43
- /** @inheritDoc */
44
- toJSON(): Partial<OwnSonosDevice>;
29
+ toJSON(): Partial<DachsTemperatureSensor>;
45
30
  /** @inheritDoc */
46
31
  persistDeviceInfo(): void;
47
32
  /** @inheritDoc */
@@ -10,37 +10,24 @@ const sharedFunctions_1 = require("../sharedFunctions");
10
10
  const DeviceInfo_1 = require("../DeviceInfo");
11
11
  const devices_1 = require("../devices");
12
12
  const utils_1 = require("../../utils");
13
- const api_1 = require("../../api");
14
- const logging_1 = require("../../logging");
15
13
  const services_1 = require("../../services");
16
- class DachsTemperatureSensor {
14
+ const RoomBaseDevice_1 = require("../RoomBaseDevice");
15
+ class DachsTemperatureSensor extends RoomBaseDevice_1.RoomBaseDevice {
17
16
  constructor(roomName, shortKey, longKey) {
17
+ const info = new DeviceInfo_1.DeviceInfo();
18
+ info.fullName = longKey;
19
+ info.customName = `${longKey} ${roomName}`;
20
+ const allDevicesKey = `dachs-${shortKey}-${roomName}`;
21
+ info.allDevicesKey = allDevicesKey;
22
+ info.room = roomName;
23
+ super(info, enums_1.DeviceType.DachsWarmWaterTemperature);
18
24
  /** @inheritDoc */
19
25
  this.settings = undefined;
20
26
  /** @inheritDoc */
21
- this.deviceType = enums_1.DeviceType.DachsWarmWaterTemperature;
22
- /** @inheritDoc */
23
- this.deviceCapabilities = [];
24
- /** @inheritDoc */
25
27
  this.temperatureSensor = new sharedFunctions_1.TemperatureSensor(this);
26
28
  this.deviceCapabilities.push(enums_1.DeviceCapability.temperatureSensor);
27
- this._info = new DeviceInfo_1.DeviceInfo();
28
- this._info.fullName = longKey;
29
- this._info.customName = `${longKey} ${roomName}`;
30
- this._info.allDevicesKey = `dachs-${shortKey}-${roomName}`;
31
- this._info.room = roomName;
32
- devices_1.Devices.alLDevices[this._info.allDevicesKey] = this;
29
+ devices_1.Devices.alLDevices[allDevicesKey] = this;
33
30
  devices_1.Devices.temperatureWarmWater = this;
34
- this.persistDeviceInfo();
35
- utils_1.Utils.guardedTimeout(this.loadDeviceSettings, 4500, this);
36
- }
37
- /** @inheritDoc */
38
- get customName() {
39
- return this.info.customName;
40
- }
41
- /** @inheritDoc */
42
- get info() {
43
- return this._info;
44
31
  }
45
32
  /** @inheritDoc */
46
33
  get id() {
@@ -51,10 +38,6 @@ class DachsTemperatureSensor {
51
38
  return this.info.customName;
52
39
  }
53
40
  /** @inheritDoc */
54
- get room() {
55
- return api_1.API.getRoom(this.info.room);
56
- }
57
- /** @inheritDoc */
58
41
  get roomTemperature() {
59
42
  return this.temperatureSensor.roomTemperature;
60
43
  }
@@ -82,17 +65,8 @@ class DachsTemperatureSensor {
82
65
  this.roomTemperature = newTemperatur;
83
66
  }
84
67
  /** @inheritDoc */
85
- log(level, message, debugType = enums_1.LogDebugType.None) {
86
- logging_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
87
- debugType: debugType,
88
- deviceId: this.name,
89
- room: this._info.room,
90
- deviceName: this.name,
91
- });
92
- }
93
- /** @inheritDoc */
94
68
  toJSON() {
95
- return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['room', 'client', 'config', '_influxClient']));
69
+ return utils_1.Utils.jsonFilter(lodash_1.default.omit(super.toJSON(), ['room', 'client', 'config', '_influxClient']));
96
70
  }
97
71
  /** @inheritDoc */
98
72
  persistDeviceInfo() {
@@ -1,22 +1,16 @@
1
- import { DeviceCapability, DeviceType, LogDebugType, LogLevel } from '../../enums';
1
+ import { LogDebugType, LogLevel } from '../../enums';
2
2
  import { iBaseDevice, iBluetoothTrackingSettings } from '../../interfaces';
3
- import { DeviceInfo } from '../DeviceInfo';
4
3
  import { TrackedDistanceData } from './trackedDistanceData';
5
4
  import { iBluetoothDetector } from '../../interfaces/baseDevices/iBluetoothDetector';
6
- export declare class DetectedBluetoothDevice implements iBaseDevice {
7
- id: string;
5
+ import { BaseDevice } from '../BaseDevice';
6
+ export declare class DetectedBluetoothDevice extends BaseDevice {
7
+ trackedDeviceId: string;
8
8
  /** @inheritDoc */
9
9
  settings: undefined;
10
10
  /**
11
11
  * A Map matching the distances to the trackers identified by {@link iBluetoothDetector.id}
12
12
  */
13
13
  distanceMap: Map<string, TrackedDistanceData>;
14
- /** @inheritDoc */
15
- readonly deviceCapabilities: DeviceCapability[];
16
- /** @inheritDoc */
17
- deviceType: DeviceType;
18
- /** @inheritDoc */
19
- info: DeviceInfo;
20
14
  /**
21
15
  * The last room the device was guessed to be in {@link iRoomBase.roomName}
22
16
  */
@@ -25,7 +19,7 @@ export declare class DetectedBluetoothDevice implements iBaseDevice {
25
19
  * If the device is currently present
26
20
  */
27
21
  present: boolean;
28
- constructor(id: string, settings?: iBluetoothTrackingSettings);
22
+ constructor(trackedDeviceId: string, settings?: iBluetoothTrackingSettings);
29
23
  get customName(): string;
30
24
  get name(): string;
31
25
  updateDistance(tracker: iBluetoothDetector, distance: number): void;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DetectedBluetoothDevice = void 0;
4
4
  const enums_1 = require("../../enums");
5
- const DeviceInfo_1 = require("../DeviceInfo");
6
5
  const devices_1 = require("../devices");
7
6
  const trackedDistanceData_1 = require("./trackedDistanceData");
8
7
  const logging_1 = require("../../logging");
@@ -12,21 +11,25 @@ const api_1 = require("../../api");
12
11
  const trilaterationPointDistance_1 = require("./trilaterationPointDistance");
13
12
  const trilateration_1 = require("./trilateration");
14
13
  const settings_service_1 = require("../../settings-service");
15
- class DetectedBluetoothDevice {
16
- constructor(id, settings) {
17
- this.id = id;
14
+ const BaseDevice_1 = require("../BaseDevice");
15
+ const DeviceInfo_1 = require("../DeviceInfo");
16
+ class DetectedBluetoothDevice extends BaseDevice_1.BaseDevice {
17
+ constructor(trackedDeviceId, settings) {
18
+ if (settings === undefined) {
19
+ return;
20
+ }
21
+ const info = new DeviceInfo_1.DeviceInfo();
22
+ info.customName = settings.customName;
23
+ const allDevicesKey = DetectedBluetoothDevice.deviceKeyBySettings(settings);
24
+ info.allDevicesKey = allDevicesKey;
25
+ super(info, enums_1.DeviceType.TrackableDevice);
26
+ this.trackedDeviceId = trackedDeviceId;
18
27
  /** @inheritDoc */
19
28
  this.settings = undefined;
20
29
  /**
21
30
  * A Map matching the distances to the trackers identified by {@link iBluetoothDetector.id}
22
31
  */
23
32
  this.distanceMap = new Map();
24
- /** @inheritDoc */
25
- this.deviceCapabilities = [enums_1.DeviceCapability.trackableDevice];
26
- /** @inheritDoc */
27
- this.deviceType = enums_1.DeviceType.TrackableDevice;
28
- /** @inheritDoc */
29
- this.info = new DeviceInfo_1.DeviceInfo();
30
33
  /**
31
34
  * The last room the device was guessed to be in {@link iRoomBase.roomName}
32
35
  */
@@ -35,13 +38,8 @@ class DetectedBluetoothDevice {
35
38
  * If the device is currently present
36
39
  */
37
40
  this.present = false;
38
- if (settings === undefined) {
39
- return;
40
- }
41
- this.info.customName = settings.customName;
42
- this.info.allDevicesKey = DetectedBluetoothDevice.deviceKeyBySettings(settings);
43
41
  if (settings.activeTracking) {
44
- devices_1.Devices.alLDevices[this.info.allDevicesKey] = this;
42
+ devices_1.Devices.alLDevices[allDevicesKey] = this;
45
43
  this.persistDeviceInfo();
46
44
  this.loadDeviceSettings();
47
45
  }
@@ -51,7 +49,7 @@ class DetectedBluetoothDevice {
51
49
  }
52
50
  get name() {
53
51
  var _a;
54
- return (_a = this.info.customName) !== null && _a !== void 0 ? _a : `Unknown ${this.id}`;
52
+ return (_a = this.info.customName) !== null && _a !== void 0 ? _a : `Unknown ${this.trackedDeviceId}`;
55
53
  }
56
54
  updateDistance(tracker, distance) {
57
55
  var _a;
@@ -1,17 +1,12 @@
1
- import { iRoomBase, iRoomDevice, iTrilaterationBasePoint } from '../../interfaces';
1
+ import { iRoomDevice, iTrilaterationBasePoint } from '../../interfaces';
2
2
  import { iBluetoothDetector } from '../../interfaces/baseDevices/iBluetoothDetector';
3
- import { DeviceCapability, DeviceType, LogDebugType, LogLevel } from '../../enums';
4
3
  import { ProximityCallback } from './proximityCallback';
5
- import { DeviceInfo } from '../DeviceInfo';
6
- export declare class EspresenseDevice implements iRoomDevice, iBluetoothDetector {
4
+ import { RoomBaseDevice } from '../RoomBaseDevice';
5
+ export declare class EspresenseDevice extends RoomBaseDevice implements iBluetoothDetector {
7
6
  /** @inheritDoc */
8
7
  readonly position: iTrilaterationBasePoint;
9
8
  /** @inheritDoc */
10
9
  settings: undefined;
11
- /** @inheritDoc */
12
- readonly deviceCapabilities: DeviceCapability[];
13
- /** @inheritDoc */
14
- deviceType: DeviceType;
15
10
  /**
16
11
  * The name of this device
17
12
  */
@@ -28,15 +23,8 @@ export declare class EspresenseDevice implements iRoomDevice, iBluetoothDetector
28
23
  */
29
24
  constructor(name: string, roomName: string, x: number, y: number, z: number);
30
25
  /** @inheritDoc */
31
- get customName(): string;
32
- protected _info: DeviceInfo;
33
- /** @inheritDoc */
34
- get info(): DeviceInfo;
35
- /** @inheritDoc */
36
26
  get id(): string;
37
27
  /** @inheritDoc */
38
- get room(): iRoomBase | undefined;
39
- /** @inheritDoc */
40
28
  distanceOfDevice(deviceName: string, maxAge?: number): number | undefined;
41
29
  /** @inheritDoc */
42
30
  isDevicePresent(deviceName: string, maxDistance: number, maxAge?: number): boolean;
@@ -47,12 +35,8 @@ export declare class EspresenseDevice implements iRoomDevice, iBluetoothDetector
47
35
  */
48
36
  update(devName: string, state: ioBroker.State): void;
49
37
  /** @inheritDoc */
50
- log(level: LogLevel, message: string, debugType?: LogDebugType): void;
51
- /** @inheritDoc */
52
38
  toJSON(): Partial<iRoomDevice>;
53
39
  /** @inheritDoc */
54
- persistDeviceInfo(): void;
55
- /** @inheritDoc */
56
40
  loadDeviceSettings(): void;
57
41
  /** @inheritDoc */
58
42
  addProximityCallback(cb: ProximityCallback): void;
@@ -8,11 +8,9 @@ const DeviceInfo_1 = require("../DeviceInfo");
8
8
  const devices_1 = require("../devices");
9
9
  const espresenseCoordinator_1 = require("./espresenseCoordinator");
10
10
  const trilateration_1 = require("./trilateration");
11
- const services_1 = require("../../services");
12
- const api_1 = require("../../api");
13
- const logging_1 = require("../../logging");
14
11
  const utils_1 = require("../../utils");
15
- class EspresenseDevice {
12
+ const RoomBaseDevice_1 = require("../RoomBaseDevice");
13
+ class EspresenseDevice extends RoomBaseDevice_1.RoomBaseDevice {
16
14
  /**
17
15
  * Creates a new instance of the EspresenseDevice class
18
16
  * @param name - The desired name of the device
@@ -22,45 +20,30 @@ class EspresenseDevice {
22
20
  * @param z - The z coordinate of the device in the house
23
21
  */
24
22
  constructor(name, roomName, x, y, z) {
23
+ const info = new DeviceInfo_1.DeviceInfo();
24
+ info.fullName = `Espresense ${roomName} ${name}`;
25
+ info.customName = `Espresense ${name}`;
26
+ info.room = roomName;
27
+ const allDevicesKey = `espresense-${roomName}-${name}`;
28
+ info.allDevicesKey = allDevicesKey;
29
+ super(info, enums_1.DeviceType.Espresense);
25
30
  /** @inheritDoc */
26
31
  this.settings = undefined;
27
- /** @inheritDoc */
28
- this.deviceCapabilities = [enums_1.DeviceCapability.bluetoothDetector];
29
- /** @inheritDoc */
30
- this.deviceType = enums_1.DeviceType.Espresense;
31
32
  this.deviceMap = new Map();
32
33
  this.proximityCallbackMap = new Map();
34
+ this.deviceCapabilities.push(enums_1.DeviceCapability.bluetoothDetector);
33
35
  this.position = new trilaterationBasePoint_1.TrilaterationBasePoint(x, y, z, roomName);
34
36
  this.name = name;
35
- this._info = new DeviceInfo_1.DeviceInfo();
36
- this._info.fullName = `Espresense ${roomName} ${name}`;
37
- this._info.customName = `Espresense ${name}`;
38
- this._info.room = roomName;
39
- this._info.allDevicesKey = `espresense-${roomName}-${name}`;
40
- devices_1.Devices.alLDevices[this._info.allDevicesKey] = this;
37
+ devices_1.Devices.alLDevices[allDevicesKey] = this;
41
38
  espresenseCoordinator_1.EspresenseCoordinator.addDevice(this, name);
42
- this.persistDeviceInfo();
43
- this.loadDeviceSettings();
44
39
  trilateration_1.Trilateration.basePoints.push(this.position);
45
40
  }
46
41
  /** @inheritDoc */
47
- get customName() {
48
- return this.info.customName;
49
- }
50
- /** @inheritDoc */
51
- get info() {
52
- return this._info;
53
- }
54
- /** @inheritDoc */
55
42
  get id() {
56
43
  var _a;
57
44
  return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `espresense-${this.info.room}-${this.info.customName}`;
58
45
  }
59
46
  /** @inheritDoc */
60
- get room() {
61
- return api_1.API.getRoom(this.info.room);
62
- }
63
- /** @inheritDoc */
64
47
  distanceOfDevice(deviceName, maxAge = 60) {
65
48
  var _a;
66
49
  for (const dev of this.deviceMap.values()) {
@@ -124,27 +107,10 @@ class EspresenseDevice {
124
107
  }
125
108
  }
126
109
  /** @inheritDoc */
127
- log(level, message, debugType = enums_1.LogDebugType.None) {
128
- var _a, _b;
129
- logging_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
130
- debugType: debugType,
131
- room: (_b = (_a = this.room) === null || _a === void 0 ? void 0 : _a.roomName) !== null && _b !== void 0 ? _b : '',
132
- deviceId: this.name,
133
- deviceName: this.name,
134
- });
135
- }
136
- /** @inheritDoc */
137
110
  toJSON() {
138
111
  return utils_1.Utils.jsonFilter(this);
139
112
  }
140
113
  /** @inheritDoc */
141
- persistDeviceInfo() {
142
- utils_1.Utils.guardedTimeout(() => {
143
- var _a;
144
- (_a = services_1.Persistence.dbo) === null || _a === void 0 ? void 0 : _a.addDevice(this);
145
- }, 5000, this);
146
- }
147
- /** @inheritDoc */
148
114
  loadDeviceSettings() {
149
115
  // Nothing
150
116
  }
@@ -1,21 +1,17 @@
1
1
  import { ActuatorSetStateCommand, ActuatorToggleCommand, ActuatorWriteStateToDeviceCommand, LampSetTimeBasedCommand, LampToggleLightCommand, LedSetLightCommand, RestoreTargetAutomaticValueCommand } from '../../command';
2
- import { DeviceCapability, DeviceType, LogDebugType, LogLevel } from '../../enums';
3
2
  import { iLedRgbCct } from '../../interfaces/baseDevices/iLedRgbCct';
4
- import { GoveeDeviceData, iRoomBase, iTemporaryDisableAutomatic } from '../../interfaces';
5
- import { DeviceInfo, LedSettings } from '../index';
6
- import { BlockAutomaticHandler } from '../../services/blockAutomaticHandler';
7
- export declare class OwnGoveeDevice implements iLedRgbCct, iTemporaryDisableAutomatic {
3
+ import { GoveeDeviceData, iTemporaryDisableAutomatic } from '../../interfaces';
4
+ import { BlockAutomaticHandler } from '../../services';
5
+ import { RoomBaseDevice } from '../RoomBaseDevice';
6
+ import { LedSettings } from '../../settingsObjects';
7
+ export declare class OwnGoveeDevice extends RoomBaseDevice implements iLedRgbCct, iTemporaryDisableAutomatic {
8
8
  /** @inheritDoc */
9
9
  settings: LedSettings;
10
- /** @inheritDoc */
11
- readonly deviceType: DeviceType;
12
10
  /**
13
11
  * The id of the device
14
12
  */
15
13
  readonly deviceId: string;
16
14
  /** @inheritDoc */
17
- readonly deviceCapabilities: DeviceCapability[];
18
- /** @inheritDoc */
19
15
  readonly blockAutomationHandler: BlockAutomaticHandler;
20
16
  /** @inheritDoc */
21
17
  queuedValue: boolean | null;
@@ -23,25 +19,16 @@ export declare class OwnGoveeDevice implements iLedRgbCct, iTemporaryDisableAuto
23
19
  brightness: number;
24
20
  /** @inheritDoc */
25
21
  targetAutomaticState: boolean;
26
- protected _info: DeviceInfo;
27
22
  private _actuatorOn;
28
23
  private _color;
29
24
  private _colortemp;
30
- private _room;
31
25
  protected _lastPersist: number;
32
26
  constructor(deviceId: string, ownDeviceName: string, roomName: string);
33
27
  get color(): string;
34
28
  get colortemp(): number;
35
- get room(): iRoomBase;
36
- get customName(): string;
37
29
  get actuatorOn(): boolean;
38
- get info(): DeviceInfo;
39
30
  get id(): string;
40
31
  get name(): string;
41
- log(level: LogLevel, message: string, debugType?: LogDebugType): void;
42
- toJSON(): Partial<OwnGoveeDevice>;
43
- persistDeviceInfo(): void;
44
- loadDeviceSettings(): void;
45
32
  /** @inheritDoc */
46
33
  setTimeBased(c: LampSetTimeBasedCommand): void;
47
34
  /** @inheritDoc */
@@ -1,32 +1,27 @@
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.OwnGoveeDevice = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
8
4
  const command_1 = require("../../command");
9
5
  const enums_1 = require("../../enums");
10
- const index_1 = require("../index");
11
- const blockAutomaticHandler_1 = require("../../services/blockAutomaticHandler");
6
+ const services_1 = require("../../services");
12
7
  const utils_1 = require("../../utils");
13
- const api_1 = require("../../api");
14
- const logging_1 = require("../../logging");
15
- const dbo_1 = require("../../services/dbo");
16
8
  const govee_service_1 = require("./govee-service");
17
- class OwnGoveeDevice {
9
+ const RoomBaseDevice_1 = require("../RoomBaseDevice");
10
+ const settingsObjects_1 = require("../../settingsObjects");
11
+ const DeviceInfo_1 = require("../DeviceInfo");
12
+ const devices_1 = require("../devices");
13
+ const sharedFunctions_1 = require("../sharedFunctions");
14
+ class OwnGoveeDevice extends RoomBaseDevice_1.RoomBaseDevice {
18
15
  constructor(deviceId, ownDeviceName, roomName) {
16
+ const info = new DeviceInfo_1.DeviceInfo();
17
+ info.fullName = `Govee ${roomName} ${ownDeviceName}`;
18
+ info.customName = `Govee ${ownDeviceName}`;
19
+ info.room = roomName;
20
+ const allDevicesKey = `govee-${roomName}-${deviceId}`;
21
+ info.allDevicesKey = allDevicesKey;
22
+ super(info, enums_1.DeviceType.GoveeLed);
19
23
  /** @inheritDoc */
20
- this.settings = new index_1.LedSettings();
21
- /** @inheritDoc */
22
- this.deviceType = enums_1.DeviceType.GoveeLed;
23
- /** @inheritDoc */
24
- this.deviceCapabilities = [
25
- enums_1.DeviceCapability.ledLamp,
26
- enums_1.DeviceCapability.lamp,
27
- enums_1.DeviceCapability.dimmablelamp,
28
- enums_1.DeviceCapability.blockAutomatic,
29
- ];
24
+ this.settings = new settingsObjects_1.LedSettings();
30
25
  /** @inheritDoc */
31
26
  this.queuedValue = null;
32
27
  /** @inheritDoc */
@@ -36,18 +31,17 @@ class OwnGoveeDevice {
36
31
  this._actuatorOn = false;
37
32
  this._color = '#fcba32';
38
33
  this._colortemp = 500;
39
- this._room = undefined;
40
34
  this._lastPersist = 0;
35
+ this.jsonOmitKeys.push('device');
41
36
  this.deviceId = deviceId;
42
- this._info = new index_1.DeviceInfo();
43
- this._info.fullName = `Govee ${roomName} ${ownDeviceName}`;
44
- this._info.customName = `Govee ${ownDeviceName}`;
45
- this._info.room = roomName;
46
- this._info.allDevicesKey = `govee-${roomName}-${deviceId}`;
47
- index_1.Devices.alLDevices[`govee-${roomName}-${deviceId}`] = this;
48
- this.persistDeviceInfo();
49
- this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
50
- utils_1.Utils.guardedTimeout(this.loadDeviceSettings, 4800, this);
37
+ this.deviceCapabilities.push(...[
38
+ enums_1.DeviceCapability.ledLamp,
39
+ enums_1.DeviceCapability.lamp,
40
+ enums_1.DeviceCapability.dimmablelamp,
41
+ enums_1.DeviceCapability.blockAutomatic,
42
+ ]);
43
+ devices_1.Devices.alLDevices[allDevicesKey] = this;
44
+ this.blockAutomationHandler = new services_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
51
45
  }
52
46
  get color() {
53
47
  return this._color;
@@ -55,21 +49,9 @@ class OwnGoveeDevice {
55
49
  get colortemp() {
56
50
  return this._colortemp;
57
51
  }
58
- get room() {
59
- if (this._room === undefined) {
60
- this._room = utils_1.Utils.guard(api_1.API.getRoom(this.info.room));
61
- }
62
- return this._room;
63
- }
64
- get customName() {
65
- return this.info.customName;
66
- }
67
52
  get actuatorOn() {
68
53
  return this._actuatorOn;
69
54
  }
70
- get info() {
71
- return this._info;
72
- }
73
55
  get id() {
74
56
  var _a;
75
57
  return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `govee-${this.info.room}-${this.info.customName}`;
@@ -77,27 +59,6 @@ class OwnGoveeDevice {
77
59
  get name() {
78
60
  return this.info.customName;
79
61
  }
80
- log(level, message, debugType = enums_1.LogDebugType.None) {
81
- var _a, _b;
82
- logging_1.ServerLogService.writeLog(level, message, {
83
- debugType: debugType,
84
- room: (_b = (_a = this._room) === null || _a === void 0 ? void 0 : _a.roomName) !== null && _b !== void 0 ? _b : '',
85
- deviceId: this.name,
86
- deviceName: this.name,
87
- });
88
- }
89
- toJSON() {
90
- return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['room', 'device']));
91
- }
92
- persistDeviceInfo() {
93
- utils_1.Utils.guardedTimeout(() => {
94
- var _a;
95
- (_a = dbo_1.Persistence.dbo) === null || _a === void 0 ? void 0 : _a.addDevice(this);
96
- }, 5000, this);
97
- }
98
- loadDeviceSettings() {
99
- this.settings.initializeFromDb(this);
100
- }
101
62
  /** @inheritDoc */
102
63
  setTimeBased(c) {
103
64
  this.setLight(this.settings.buildLedSetLightCommand(c));
@@ -115,15 +76,15 @@ class OwnGoveeDevice {
115
76
  this.setColor(c.color);
116
77
  }
117
78
  }
118
- const dontBlock = index_1.LampUtils.checkUnBlock(this, c);
119
- if (index_1.LampUtils.checkBlockActive(this, c)) {
79
+ const dontBlock = sharedFunctions_1.LampUtils.checkUnBlock(this, c);
80
+ if (sharedFunctions_1.LampUtils.checkBlockActive(this, c)) {
120
81
  return;
121
82
  }
122
83
  if (c.isAutomaticAction) {
123
84
  // Preserve the target state for the automatic handler, as
124
85
  this.targetAutomaticState = c.on;
125
86
  }
126
- if (index_1.LampUtils.canDimmerChangeBeSkipped(this, c)) {
87
+ if (sharedFunctions_1.LampUtils.canDimmerChangeBeSkipped(this, c)) {
127
88
  return;
128
89
  }
129
90
  if (c.brightness > -1 && c.on) {
@@ -153,7 +114,7 @@ class OwnGoveeDevice {
153
114
  if (this._lastPersist + 1000 > now) {
154
115
  return;
155
116
  }
156
- (_a = dbo_1.Persistence.dbo) === null || _a === void 0 ? void 0 : _a.persistActuator(this);
117
+ (_a = services_1.Persistence.dbo) === null || _a === void 0 ? void 0 : _a.persistActuator(this);
157
118
  this._lastPersist = now;
158
119
  }
159
120
  toggleActuator(c) {
@@ -162,10 +123,10 @@ class OwnGoveeDevice {
162
123
  return setActuatorCommand.on;
163
124
  }
164
125
  toggleLight(c) {
165
- return index_1.LampUtils.toggleLight(this, c);
126
+ return sharedFunctions_1.LampUtils.toggleLight(this, c);
166
127
  }
167
128
  writeActuatorStateToDevice(c) {
168
- this.log(enums_1.LogLevel.Debug, c.logMessage, enums_1.LogDebugType.SetActuator);
129
+ this.logCommand(c, undefined, enums_1.LogDebugType.SetActuator);
169
130
  if (c.stateValue) {
170
131
  this.turnOn();
171
132
  }
@@ -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; } });