hoffmation-base 3.2.9 → 3.2.10-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 (31) hide show
  1. package/lib/command/ShutterSetLevelCommand.d.ts +7 -0
  2. package/lib/devices/groups/Window.d.ts +1 -2
  3. package/lib/devices/groups/Window.js +17 -14
  4. package/lib/devices/groups/windowGroup.d.ts +1 -0
  5. package/lib/devices/groups/windowGroup.js +32 -14
  6. package/lib/devices/hmIPDevices/hmIpRoll.d.ts +12 -2
  7. package/lib/devices/hmIPDevices/hmIpRoll.js +17 -38
  8. package/lib/devices/sharedFunctions/index.d.ts +1 -0
  9. package/lib/devices/sharedFunctions/index.js +1 -0
  10. package/lib/devices/sharedFunctions/shutterUtils.d.ts +10 -0
  11. package/lib/devices/sharedFunctions/shutterUtils.js +79 -0
  12. package/lib/devices/velux/veluxShutter.d.ts +14 -4
  13. package/lib/devices/velux/veluxShutter.js +17 -38
  14. package/lib/devices/zigbee/BaseDevices/zigbeeShutter.d.ts +17 -3
  15. package/lib/devices/zigbee/BaseDevices/zigbeeShutter.js +23 -32
  16. package/lib/devices/zigbee/zigbeeIkeaShutter.d.ts +1 -1
  17. package/lib/devices/zigbee/zigbeeIkeaShutter.js +1 -1
  18. package/lib/devices/zigbee/zigbeeIlluShutter.d.ts +1 -1
  19. package/lib/devices/zigbee/zigbeeIlluShutter.js +2 -2
  20. package/lib/devices/zigbee/zigbeeUbisysShutter.d.ts +1 -1
  21. package/lib/devices/zigbee/zigbeeUbisysShutter.js +1 -1
  22. package/lib/interfaces/baseDevices/iShutter.d.ts +20 -2
  23. package/lib/interfaces/deviceSettings/iDeviceSettings.d.ts +2 -2
  24. package/lib/interfaces/groups/iWindow.d.ts +1 -1
  25. package/lib/services/RoomBase.js +4 -3
  26. package/lib/services/ShutterService.d.ts +1 -3
  27. package/lib/services/ShutterService.js +4 -8
  28. package/lib/services/weather/weather-service.js +6 -5
  29. package/lib/settingsObjects/deviceSettings/deviceSettings.d.ts +2 -2
  30. package/lib/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +1 -1
@@ -8,6 +8,8 @@ const enums_1 = require("../../../enums");
8
8
  const utils_1 = require("../../../utils");
9
9
  const action_1 = require("../../../action");
10
10
  const models_1 = require("../../../models");
11
+ const services_1 = require("../../../services");
12
+ const sharedFunctions_1 = require("../../sharedFunctions");
11
13
  class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
12
14
  constructor(pInfo, pType) {
13
15
  var _a, _b;
@@ -15,13 +17,19 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
15
17
  /** @inheritDoc */
16
18
  this.settings = new settingsObjects_1.ShutterSettings();
17
19
  this._iMovementFinishTimeout = null;
18
- this._firstCommandRecieved = false;
20
+ /** @inheritDoc */
21
+ this.firstCommandRecieved = false;
19
22
  this._setLevel = -1;
20
23
  this._setLevelTime = -1;
21
24
  this._shutterCalibrationData = new models_1.ShutterCalibration(this.info.fullID, 0, 0, 0, 0);
22
25
  this._currentLevel = -1;
26
+ this._targetAutomaticValue = 0;
27
+ /** @inheritDoc */
28
+ this.baseAutomaticLevel = 0;
23
29
  this.deviceCapabilities.push(enums_1.DeviceCapability.shutter);
24
30
  this.jsonOmitKeys.push('_window');
31
+ // Initialize blockAutomationHandler for iTemporaryDisableAutomatic
32
+ this.blockAutomationHandler = new services_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
25
33
  (_a = this.dbo) === null || _a === void 0 ? void 0 : _a.getShutterCalibration(this).then((calibrationData) => {
26
34
  this._shutterCalibrationData = calibrationData;
27
35
  this.log(enums_1.LogLevel.DeepTrace, 'ZigbeeShutter initialized with calibration data');
@@ -37,6 +45,10 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
37
45
  });
38
46
  }
39
47
  /** @inheritDoc */
48
+ get targetAutomaticValue() {
49
+ return this._targetAutomaticValue;
50
+ }
51
+ /** @inheritDoc */
40
52
  get currentLevel() {
41
53
  if (this._setLevel !== -1 && this._currentLevel !== this._setLevel) {
42
54
  return this._setLevel;
@@ -69,36 +81,7 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
69
81
  }
70
82
  /** @inheritDoc */
71
83
  setLevel(c) {
72
- let pPosition = c.level;
73
- if (!this._firstCommandRecieved && !c.isInitial) {
74
- this._firstCommandRecieved = true;
75
- }
76
- else if (this._firstCommandRecieved && c.isInitial) {
77
- this.logCommand(c, `Skipped initial shutter to ${pPosition} as we recieved a command already`);
78
- return;
79
- }
80
- if (this.currentLevel === pPosition && !c.isForceAction) {
81
- this.logCommand(c, `Skip shutter command to Position ${pPosition} as this is the current one`, enums_1.LogDebugType.SkipUnchangedRolloPosition);
82
- return;
83
- }
84
- this.logCommand(c);
85
- if (this._window !== undefined) {
86
- if (this._window.griffeInPosition(enums_1.WindowPosition.open) > 0 && pPosition < 100) {
87
- if (!c.skipOpenWarning) {
88
- this.log(enums_1.LogLevel.Alert, 'Not closing the shutter, as the window is open!');
89
- }
90
- return;
91
- }
92
- if (this._window.griffeInPosition(enums_1.WindowPosition.tilted) > 0 && pPosition < 50) {
93
- pPosition = 50;
94
- if (!c.skipOpenWarning) {
95
- this.log(enums_1.LogLevel.Alert, 'Not closing the shutter, as the window is half open!');
96
- }
97
- }
98
- }
99
- this._setLevel = pPosition;
100
- this.log(enums_1.LogLevel.Debug, `Move to position ${pPosition}`);
101
- this.moveToPosition(pPosition);
84
+ sharedFunctions_1.ShutterUtils.setLevel(this, c);
102
85
  }
103
86
  setCurrentLevel(value, isInitial = false) {
104
87
  if (value !== this._setLevel && utils_1.Utils.nowMS() - this._setLevelTime < 60 * 10000) {
@@ -113,7 +96,8 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
113
96
  }
114
97
  this._currentLevel = value;
115
98
  }
116
- moveToPosition(pPosition) {
99
+ writePositionStateToDevice(pPosition) {
100
+ this._setLevel = pPosition;
117
101
  this.log(enums_1.LogLevel.Error, `Implement own moveToPosition(${pPosition}) Function`);
118
102
  }
119
103
  getAverageUp() {
@@ -142,6 +126,13 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
142
126
  this.log(enums_1.LogLevel.Trace, `Persiting Calibration Data. Average Up: ${this._shutterCalibrationData.averageUp}, Down: ${this._shutterCalibrationData.averageDown}`);
143
127
  (_a = this.dbo) === null || _a === void 0 ? void 0 : _a.persistShutterCalibration(this._shutterCalibrationData);
144
128
  }
129
+ /**
130
+ * Restores the automatic value/state of the device
131
+ * @param command - The command to restore the automatic value/state
132
+ */
133
+ restoreTargetAutomaticValue(command) {
134
+ this.setLevel(new command_1.ShutterSetLevelCommand(command, this._targetAutomaticValue));
135
+ }
145
136
  initializeMovementFinishTimeout(duration, endPosition) {
146
137
  if (this._iMovementFinishTimeout !== null) {
147
138
  clearTimeout(this._iMovementFinishTimeout);
@@ -5,5 +5,5 @@ export declare class ZigbeeIkeaShutter extends ZigbeeShutter {
5
5
  constructor(pInfo: IoBrokerDeviceInfo);
6
6
  /** @inheritDoc */
7
7
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
8
- protected moveToPosition(pPosition: number): void;
8
+ writePositionStateToDevice(pPosition: number): void;
9
9
  }
@@ -19,7 +19,7 @@ class ZigbeeIkeaShutter extends BaseDevices_1.ZigbeeShutter {
19
19
  }
20
20
  super.update(idSplit, state, initial, true);
21
21
  }
22
- moveToPosition(pPosition) {
22
+ writePositionStateToDevice(pPosition) {
23
23
  this.setState(this._positionStateId, pPosition);
24
24
  }
25
25
  }
@@ -9,7 +9,7 @@ export declare class ZigbeeIlluShutter extends ZigbeeShutter {
9
9
  constructor(pInfo: IoBrokerDeviceInfo);
10
10
  /** @inheritDoc */
11
11
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
12
- protected moveToPosition(targetPosition: number): void;
12
+ writePositionStateToDevice(targetPosition: number): void;
13
13
  private changeMovementState;
14
14
  private processNewMovementState;
15
15
  }
@@ -28,7 +28,7 @@ class ZigbeeIlluShutter extends BaseDevices_1.ZigbeeShutter {
28
28
  }
29
29
  super.update(idSplit, state, initial, true);
30
30
  }
31
- moveToPosition(targetPosition) {
31
+ writePositionStateToDevice(targetPosition) {
32
32
  if (this._movementState !== MovementState.Stop) {
33
33
  this.log(enums_1.LogLevel.Info, `Delaying movement command for ${this.info.customName} as it is moving to prevent actuator damage`);
34
34
  this.changeMovementState(MovementState.Stop);
@@ -37,7 +37,7 @@ class ZigbeeIlluShutter extends BaseDevices_1.ZigbeeShutter {
37
37
  }
38
38
  this._iMovementTimeout = utils_1.Utils.guardedTimeout(() => {
39
39
  this._iMovementTimeout = undefined;
40
- this.moveToPosition(targetPosition);
40
+ this.writePositionStateToDevice(targetPosition);
41
41
  }, 2000, this);
42
42
  return;
43
43
  }
@@ -5,5 +5,5 @@ export declare class ZigbeeUbisysShutter extends ZigbeeShutter {
5
5
  constructor(pInfo: IoBrokerDeviceInfo);
6
6
  /** @inheritDoc */
7
7
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
8
- protected moveToPosition(pPosition: number): void;
8
+ writePositionStateToDevice(pPosition: number): void;
9
9
  }
@@ -19,7 +19,7 @@ class ZigbeeUbisysShutter extends BaseDevices_1.ZigbeeShutter {
19
19
  }
20
20
  super.update(idSplit, state, initial, true);
21
21
  }
22
- moveToPosition(pPosition) {
22
+ writePositionStateToDevice(pPosition) {
23
23
  this.setState(this._positionStateId, pPosition);
24
24
  }
25
25
  }
@@ -1,4 +1,5 @@
1
1
  import { iRoomDevice } from './iRoomDevice';
2
+ import { iTemporaryDisableAutomatic } from './iTemporaryDisableAutomatic';
2
3
  import { ShutterSetLevelCommand } from '../../command';
3
4
  import { iWindow } from '../groups';
4
5
  import { iShutterSettings } from '../settings/iShutterSettings';
@@ -7,7 +8,11 @@ import { iShutterSettings } from '../settings/iShutterSettings';
7
8
  *
8
9
  * For devices with {@link DeviceCapability.shutter} capability.
9
10
  */
10
- export interface iShutter extends iRoomDevice {
11
+ export interface iShutter extends iRoomDevice, iTemporaryDisableAutomatic {
12
+ /**
13
+ * Whether the first command has been received
14
+ */
15
+ firstCommandRecieved: boolean;
11
16
  /**
12
17
  * The settings for the shutter
13
18
  */
@@ -16,14 +21,22 @@ export interface iShutter extends iRoomDevice {
16
21
  * The current level of the shutter (0 = closed, 100 = open)
17
22
  */
18
23
  readonly currentLevel: number;
24
+ /**
25
+ * The target level of the shutter (0 = closed, 100 = open)
26
+ */
27
+ targetAutomaticValue: number;
19
28
  /**
20
29
  * The desired level of the shutter for this window (this might be different from the current level due to the desired level being set by the user)
21
30
  */
22
- desiredWindowShutterLevel: number;
31
+ readonly desiredWindowShutterLevel: number;
23
32
  /**
24
33
  * The window this shutter is located within
25
34
  */
26
35
  window: iWindow | undefined;
36
+ /**
37
+ * The base automation level (e.g., 0 = closed at night, 100 = open at day)
38
+ */
39
+ baseAutomaticLevel: number;
27
40
  /**
28
41
  * Persists the current information of the shutter to the database
29
42
  */
@@ -33,4 +46,9 @@ export interface iShutter extends iRoomDevice {
33
46
  * @param command - The command to execute
34
47
  */
35
48
  setLevel(command: ShutterSetLevelCommand): void;
49
+ /**
50
+ * Moves the shutter to a specific position
51
+ * @param pPosition
52
+ */
53
+ writePositionStateToDevice(pPosition: number): void;
36
54
  }
@@ -1,5 +1,5 @@
1
1
  import { iBlockAutomaticSettings, iExcessEnergyConsumerSettings, iObjectSettings } from '../settings';
2
- import { ActuatorSetStateCommand, BlockAutomaticCommand } from '../../command';
2
+ import { BlockAutomaticCommand, iBaseCommand } from '../../command';
3
3
  /**
4
4
  *
5
5
  */
@@ -27,5 +27,5 @@ export interface iDeviceSettings extends iObjectSettings {
27
27
  /**
28
28
  *
29
29
  */
30
- buildBlockAutomaticCommand(c: ActuatorSetStateCommand): BlockAutomaticCommand | null | undefined;
30
+ buildBlockAutomaticCommand(c: iBaseCommand): BlockAutomaticCommand | null | undefined;
31
31
  }
@@ -51,7 +51,7 @@ export interface iWindow extends iBaseGroup {
51
51
  /**
52
52
  *
53
53
  */
54
- getShutter(): iShutter[];
54
+ getShutter(): iShutter | undefined;
55
55
  /**
56
56
  *
57
57
  */
@@ -13,7 +13,6 @@ const enums_1 = require("../enums");
13
13
  const logging_1 = require("../logging");
14
14
  const dbo_1 = require("./dbo");
15
15
  const time_callback_service_1 = require("./time-callback-service");
16
- const ShutterService_1 = require("./ShutterService");
17
16
  const models_1 = require("../models");
18
17
  class RoomBase {
19
18
  constructor(groupMap, roomName, etage = 99, startPoint, endPoint) {
@@ -141,7 +140,8 @@ class RoomBase {
141
140
  if (timeOfDay === enums_1.TimeOfDay.Daylight &&
142
141
  ((this.settings.lightIfNoWindows && (!this.WindowGroup || this.WindowGroup.windows.length === 0)) ||
143
142
  ((_a = this.WindowGroup) === null || _a === void 0 ? void 0 : _a.windows.some((f) => {
144
- return ShutterService_1.ShutterService.anyRolloDown(f.getShutter());
143
+ var _a;
144
+ return ((_a = f.getShutter()) === null || _a === void 0 ? void 0 : _a.currentLevel) === 0;
145
145
  })))) {
146
146
  timeOfDay = utils_1.Utils.nowTime().hours > 16 ? enums_1.TimeOfDay.AfterSunset : enums_1.TimeOfDay.BeforeSunrise;
147
147
  }
@@ -158,7 +158,8 @@ class RoomBase {
158
158
  : time_callback_service_1.TimeCallbackService.dayType(this.settings.lampOffset);
159
159
  if (timeOfDay === enums_1.TimeOfDay.Daylight &&
160
160
  ((_a = this.WindowGroup) === null || _a === void 0 ? void 0 : _a.windows.some((f) => {
161
- return ShutterService_1.ShutterService.anyRolloDown(f.getShutter());
161
+ var _a;
162
+ return ((_a = f.getShutter()) === null || _a === void 0 ? void 0 : _a.currentLevel) === 0;
162
163
  }))) {
163
164
  timeOfDay = enums_1.TimeOfDay.AfterSunset;
164
165
  }
@@ -1,8 +1,6 @@
1
- import { iShutter, iWindow } from '../interfaces';
2
- import { ShutterSetLevelCommand } from '../command';
1
+ import { iShutter } from '../interfaces';
3
2
  export declare class ShutterService {
4
3
  static anyRolloDown(rollo: iShutter[]): boolean;
5
4
  static getRolladenPosition(): string;
6
5
  static getAllRollos(): iShutter[];
7
- static windowAllToPosition(f: iWindow, c: ShutterSetLevelCommand): void;
8
6
  }
@@ -14,6 +14,7 @@ class ShutterService {
14
14
  return false;
15
15
  }
16
16
  static getRolladenPosition() {
17
+ var _a, _b, _c, _d, _e;
17
18
  const rollos = ShutterService.getAllRollos();
18
19
  rollos.sort((a, b) => {
19
20
  return b.currentLevel - a.currentLevel;
@@ -29,13 +30,13 @@ class ShutterService {
29
30
  continue;
30
31
  }
31
32
  for (const f of r.WindowGroup.windows) {
32
- f.getShutter().forEach((shutter) => {
33
- var _a, _b, _c, _d, _e;
33
+ const shutter = f.getShutter();
34
+ if (shutter) {
34
35
  response.push(`Shutter: "${shutter.info.customName}"\t${((_a = shutter.room) === null || _a === void 0 ? void 0 : _a.settings.sonnenAufgangRollos) === true
35
36
  ? (_c = (_b = r.sunriseShutterCallback) === null || _b === void 0 ? void 0 : _b.nextToDo) === null || _c === void 0 ? void 0 : _c.toLocaleTimeString()
36
37
  : 'Sunrise Shutter up inactive'}`);
37
38
  down.push(`Shutter: "${shutter.info.customName}"\t${(_e = (_d = r.sunsetShutterCallback) === null || _d === void 0 ? void 0 : _d.nextToDo) === null || _e === void 0 ? void 0 : _e.toLocaleTimeString('de-DE')}`);
38
- });
39
+ }
39
40
  }
40
41
  }
41
42
  response.push(down.join('\n'));
@@ -54,10 +55,5 @@ class ShutterService {
54
55
  }
55
56
  return rollos;
56
57
  }
57
- static windowAllToPosition(f, c) {
58
- f.getShutter().forEach((s) => {
59
- s.setLevel(c);
60
- });
61
- }
62
58
  }
63
59
  exports.ShutterService = ShutterService;
@@ -147,21 +147,22 @@ class WeatherService {
147
147
  }
148
148
  static weatherRolloPosition(normalPos, desiredTemperatur, currentTemperatur, logger, shutterSettings) {
149
149
  let result = normalPos;
150
- if (currentTemperatur < desiredTemperatur) {
150
+ if (currentTemperatur < desiredTemperatur && currentTemperatur < shutterSettings.heatReductionThreshold) {
151
151
  logger(enums_1.LogLevel.Trace, 'RolloWeatherPosition: Room needs to heat up anyways.');
152
152
  return result;
153
153
  }
154
- else if (normalPos < 30) {
154
+ else if (normalPos < shutterSettings.heatReductionPosition) {
155
155
  logger(enums_1.LogLevel.Trace, 'RolloWeatherPosition: Shutter should be down anyways.');
156
156
  return result;
157
157
  }
158
+ else if (this.willOutsideBeWarmer(shutterSettings.heatReductionThreshold, logger) &&
159
+ currentTemperatur > shutterSettings.heatReductionDirectionThreshold) {
160
+ result = shutterSettings.heatReductionPosition;
161
+ }
158
162
  else if (this.hoursTilSunset() < 1) {
159
163
  logger(enums_1.LogLevel.Trace, "RolloWeatherPosition: It's close to or after todays sunset");
160
164
  return result;
161
165
  }
162
- else if (this.willOutsideBeWarmer(shutterSettings.heatReductionThreshold, logger)) {
163
- result = shutterSettings.heatReductionPosition;
164
- }
165
166
  else if (shutterSettings.direction !== undefined &&
166
167
  !utils_1.Utils.degreeInBetween(shutterSettings.direction - 50, shutterSettings.direction + 50, this.sunDirection)) {
167
168
  logger(enums_1.LogLevel.Trace, 'RolloWeatherPosition: Sun is facing a different direction');
@@ -1,8 +1,8 @@
1
1
  import { iBlockAutomaticSettings, iDeviceSettings, iExcessEnergyConsumerSettings } from '../../interfaces';
2
2
  import { ObjectSettings } from '../objectSettings';
3
- import { ActuatorSetStateCommand, BlockAutomaticCommand } from '../../command';
3
+ import { BlockAutomaticCommand, iBaseCommand } from '../../command';
4
4
  export declare abstract class DeviceSettings extends ObjectSettings implements iDeviceSettings {
5
- buildBlockAutomaticCommand(c: ActuatorSetStateCommand): BlockAutomaticCommand | null | undefined;
5
+ buildBlockAutomaticCommand(c: iBaseCommand): BlockAutomaticCommand | null | undefined;
6
6
  /**
7
7
  * Any device could be an energy consumer, so we have to provide the settings for it
8
8
  * @default undefined