hoffmation-base 0.1.41-4 → 0.1.41-7
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.
- package/lib/models/deviceSettings/shutterSettings.d.ts +6 -0
- package/lib/models/deviceSettings/shutterSettings.js +6 -0
- package/lib/models/rooms/RoomSettings/RoomSettings.js +1 -0
- package/lib/models/timeCallback.js +2 -2
- package/lib/server/devices/jsObject/jsObjectEnergyManager.d.ts +1 -0
- package/lib/server/devices/jsObject/jsObjectEnergyManager.js +8 -1
- package/lib/server/devices/zigbee/zigbeeIlluShutter.d.ts +0 -2
- package/lib/server/devices/zigbee/zigbeeIlluShutter.js +26 -24
- package/lib/server/devices/zigbee/zigbeeShutter.d.ts +5 -3
- package/lib/server/devices/zigbee/zigbeeShutter.js +30 -22
- package/lib/server/services/time-callback-service.d.ts +4 -4
- package/lib/server/services/time-callback-service.js +14 -12
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
|
@@ -2,4 +2,10 @@ import { DeviceSettings } from './deviceSettings';
|
|
|
2
2
|
export declare class ShutterSettings extends DeviceSettings {
|
|
3
3
|
msTilTop: number;
|
|
4
4
|
msTilBot: number;
|
|
5
|
+
/**
|
|
6
|
+
* Some shutter give no position feedback on their own, so by knowing the durations in either direction,
|
|
7
|
+
* we can programmatically trigger the callbacks.
|
|
8
|
+
* @type {boolean}
|
|
9
|
+
*/
|
|
10
|
+
triggerPositionUpdateByTime: boolean;
|
|
5
11
|
}
|
|
@@ -7,6 +7,12 @@ class ShutterSettings extends deviceSettings_1.DeviceSettings {
|
|
|
7
7
|
super(...arguments);
|
|
8
8
|
this.msTilTop = -1;
|
|
9
9
|
this.msTilBot = -1;
|
|
10
|
+
/**
|
|
11
|
+
* Some shutter give no position feedback on their own, so by knowing the durations in either direction,
|
|
12
|
+
* we can programmatically trigger the callbacks.
|
|
13
|
+
* @type {boolean}
|
|
14
|
+
*/
|
|
15
|
+
this.triggerPositionUpdateByTime = false;
|
|
10
16
|
}
|
|
11
17
|
}
|
|
12
18
|
exports.ShutterSettings = ShutterSettings;
|
|
@@ -42,7 +42,7 @@ class TimeCallback {
|
|
|
42
42
|
case TimeCallbackType.Sunrise:
|
|
43
43
|
let fixedSRDate = new Date(time_callback_service_1.TimeCallbackService.nextSunRise.getTime() + this.minuteOffset * 60 * 1000);
|
|
44
44
|
if (this.sunTimeOffset) {
|
|
45
|
-
const nextMinSR = this.sunTimeOffset.getNextMinimumSunrise();
|
|
45
|
+
const nextMinSR = this.sunTimeOffset.getNextMinimumSunrise(now);
|
|
46
46
|
if (nextMinSR > fixedSRDate && fixedSRDate.getDate() === nextMinSR.getDate()) {
|
|
47
47
|
fixedSRDate = nextMinSR;
|
|
48
48
|
}
|
|
@@ -56,7 +56,7 @@ class TimeCallback {
|
|
|
56
56
|
case TimeCallbackType.SunSet:
|
|
57
57
|
let fixedSSDate = new Date(time_callback_service_1.TimeCallbackService.nextSunSet.getTime() + this.minuteOffset * 60 * 1000);
|
|
58
58
|
if (this.sunTimeOffset) {
|
|
59
|
-
const nextMaxSS = this.sunTimeOffset.getNextMaximumSunset();
|
|
59
|
+
const nextMaxSS = this.sunTimeOffset.getNextMaximumSunset(now);
|
|
60
60
|
if (nextMaxSS < fixedSSDate && fixedSSDate.getDate() === nextMaxSS.getDate()) {
|
|
61
61
|
fixedSSDate = nextMaxSS;
|
|
62
62
|
}
|
|
@@ -33,6 +33,7 @@ export declare class JsObjectEnergyManager extends IoBrokerBaseDevice implements
|
|
|
33
33
|
private _currentProduction;
|
|
34
34
|
private _excessEnergyConsumerConsumption;
|
|
35
35
|
private _excessEnergyConsumer;
|
|
36
|
+
private _iCalculationInterval;
|
|
36
37
|
private _iDatabaseLoggerInterval;
|
|
37
38
|
private _lastPersistenceCalculation;
|
|
38
39
|
private _nextPersistEntry;
|
|
@@ -13,6 +13,7 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
13
13
|
this._currentProduction = -1;
|
|
14
14
|
this._excessEnergyConsumerConsumption = 0;
|
|
15
15
|
this._excessEnergyConsumer = [];
|
|
16
|
+
this._iCalculationInterval = null;
|
|
16
17
|
this._iDatabaseLoggerInterval = null;
|
|
17
18
|
this._lastPersistenceCalculation = services_1.Utils.nowMS();
|
|
18
19
|
this._powerValuePhaseA = -1;
|
|
@@ -22,6 +23,9 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
22
23
|
this._phaseBState = new iEnergyManager_1.PhaseState(0, 0);
|
|
23
24
|
this._phaseCState = new iEnergyManager_1.PhaseState(0, 0);
|
|
24
25
|
this.log(models_1.LogLevel.Info, `Creating Energy Manager Device`);
|
|
26
|
+
this._iCalculationInterval = services_1.Utils.guardedInterval(() => {
|
|
27
|
+
this.calculateExcessEnergy();
|
|
28
|
+
}, 5 * 1000, this);
|
|
25
29
|
this._iDatabaseLoggerInterval = services_1.Utils.guardedInterval(() => {
|
|
26
30
|
this.persist();
|
|
27
31
|
}, 15 * 60 * 1000, this);
|
|
@@ -84,6 +88,10 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
84
88
|
clearInterval(this._iDatabaseLoggerInterval);
|
|
85
89
|
this._iDatabaseLoggerInterval = null;
|
|
86
90
|
}
|
|
91
|
+
if (this._iCalculationInterval !== null) {
|
|
92
|
+
clearInterval(this._iCalculationInterval);
|
|
93
|
+
this._iCalculationInterval = null;
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
96
|
addExcessConsumer(device) {
|
|
89
97
|
this._excessEnergyConsumer.push(device);
|
|
@@ -109,7 +117,6 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
109
117
|
case 'CurrentProduction':
|
|
110
118
|
this.log(models_1.LogLevel.Trace, `Current Production Update to ${state.val}`);
|
|
111
119
|
this._currentProduction = state.val;
|
|
112
|
-
this.calculateExcessEnergy();
|
|
113
120
|
break;
|
|
114
121
|
}
|
|
115
122
|
}
|
|
@@ -5,8 +5,6 @@ export declare class ZigbeeIlluShutter extends ZigbeeShutter {
|
|
|
5
5
|
private _movementStateId;
|
|
6
6
|
private _movementState;
|
|
7
7
|
private _movementStartMs;
|
|
8
|
-
private _msTilTop;
|
|
9
|
-
private _msTilBot;
|
|
10
8
|
private _movementStartPos;
|
|
11
9
|
private _iMovementTimeout;
|
|
12
10
|
constructor(pInfo: DeviceInfo);
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZigbeeIlluShutter = void 0;
|
|
4
4
|
const zigbeeShutter_1 = require("./zigbeeShutter");
|
|
5
5
|
const deviceType_1 = require("../deviceType");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const models_1 = require("../../../models");
|
|
7
|
+
const services_1 = require("../../services");
|
|
8
8
|
var MovementState;
|
|
9
9
|
(function (MovementState) {
|
|
10
10
|
MovementState[MovementState["Down"] = 30] = "Down";
|
|
@@ -16,8 +16,6 @@ class ZigbeeIlluShutter extends zigbeeShutter_1.ZigbeeShutter {
|
|
|
16
16
|
super(pInfo, deviceType_1.DeviceType.ZigbeeIlluShutter);
|
|
17
17
|
this._movementState = MovementState.Stop;
|
|
18
18
|
this._movementStartMs = -1;
|
|
19
|
-
this._msTilTop = -1;
|
|
20
|
-
this._msTilBot = -1;
|
|
21
19
|
this._movementStartPos = -1;
|
|
22
20
|
this._movementStateId = `${this.info.fullID}.position`;
|
|
23
21
|
// this.presenceStateID = `${this.info.fullID}.1.${HmIpPraezenz.PRESENCE_DETECTION}`;
|
|
@@ -25,7 +23,7 @@ class ZigbeeIlluShutter extends zigbeeShutter_1.ZigbeeShutter {
|
|
|
25
23
|
update(idSplit, state, initial = false) {
|
|
26
24
|
switch (idSplit[3]) {
|
|
27
25
|
case 'position':
|
|
28
|
-
this.log(
|
|
26
|
+
this.log(models_1.LogLevel.Trace, `Shutter Update for ${this.info.customName} to "${state.val}"`);
|
|
29
27
|
this.processNewMovementState(state.val);
|
|
30
28
|
break;
|
|
31
29
|
}
|
|
@@ -33,12 +31,12 @@ class ZigbeeIlluShutter extends zigbeeShutter_1.ZigbeeShutter {
|
|
|
33
31
|
}
|
|
34
32
|
moveToPosition(targetPosition) {
|
|
35
33
|
if (this._movementState !== MovementState.Stop) {
|
|
36
|
-
this.log(
|
|
34
|
+
this.log(models_1.LogLevel.Info, `Delaying movement command for ${this.info.customName} as it is moving to prevent actuator damage`);
|
|
37
35
|
this.changeMovementState(MovementState.Stop);
|
|
38
36
|
if (this._iMovementTimeout !== undefined) {
|
|
39
37
|
clearTimeout(this._iMovementTimeout);
|
|
40
38
|
}
|
|
41
|
-
this._iMovementTimeout =
|
|
39
|
+
this._iMovementTimeout = services_1.Utils.guardedTimeout(() => {
|
|
42
40
|
this._iMovementTimeout = undefined;
|
|
43
41
|
this.moveToPosition(targetPosition);
|
|
44
42
|
}, 2000, this);
|
|
@@ -47,28 +45,34 @@ class ZigbeeIlluShutter extends zigbeeShutter_1.ZigbeeShutter {
|
|
|
47
45
|
this._movementStartPos = this._currentLevel;
|
|
48
46
|
if (targetPosition === 100) {
|
|
49
47
|
this.changeMovementState(MovementState.Up);
|
|
48
|
+
this.initializeMovementFinishTimeout(this.getAverageUp(), 100);
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
51
|
if (targetPosition === 0) {
|
|
53
52
|
this.changeMovementState(MovementState.Down);
|
|
53
|
+
this.initializeMovementFinishTimeout(this.getAverageUp(), 0);
|
|
54
|
+
services_1.Utils.guardedTimeout(() => {
|
|
55
|
+
this.changeMovementState(MovementState.Stop);
|
|
56
|
+
}, this.getAverageDown() + 1000, this);
|
|
54
57
|
return;
|
|
55
58
|
}
|
|
56
59
|
if (!this.isCalibrated()) {
|
|
57
|
-
this.log(
|
|
60
|
+
this.log(models_1.LogLevel.Alert, `Can't move to position "${targetPosition}" as it is not calibrated (Move it completly up, down, up first)`);
|
|
58
61
|
return;
|
|
59
62
|
}
|
|
60
63
|
const distance = Math.abs(this._currentLevel - targetPosition);
|
|
61
64
|
const direction = this._currentLevel > targetPosition ? MovementState.Down : MovementState.Up;
|
|
62
|
-
const duration = Math.round(distance / 100) * (this._currentLevel > targetPosition ? this.
|
|
65
|
+
const duration = Math.round(distance / 100) * (this._currentLevel > targetPosition ? this.getAverageDown() : this.getAverageUp());
|
|
63
66
|
this.changeMovementState(direction);
|
|
64
|
-
|
|
67
|
+
this.initializeMovementFinishTimeout(duration, targetPosition);
|
|
68
|
+
services_1.Utils.guardedTimeout(() => {
|
|
65
69
|
this.changeMovementState(MovementState.Stop);
|
|
66
70
|
}, duration, this);
|
|
67
71
|
}
|
|
68
72
|
changeMovementState(direction) {
|
|
69
|
-
this.log(
|
|
73
|
+
this.log(models_1.LogLevel.Debug, `Set new MovementState to "${MovementState[direction]}"`);
|
|
70
74
|
if (direction !== MovementState.Stop) {
|
|
71
|
-
this._movementStartMs =
|
|
75
|
+
this._movementStartMs = services_1.Utils.nowMS();
|
|
72
76
|
}
|
|
73
77
|
this.setState(this._movementStateId, direction, () => {
|
|
74
78
|
this._movementState = direction;
|
|
@@ -76,43 +80,41 @@ class ZigbeeIlluShutter extends zigbeeShutter_1.ZigbeeShutter {
|
|
|
76
80
|
}
|
|
77
81
|
processNewMovementState(val) {
|
|
78
82
|
const newState = val <= 30 ? MovementState.Down : val >= 70 ? MovementState.Up : MovementState.Stop;
|
|
79
|
-
this.log(
|
|
83
|
+
this.log(models_1.LogLevel.Trace, `New Movementstate "${MovementState[val]}"`);
|
|
80
84
|
if (newState !== MovementState.Stop) {
|
|
81
85
|
this._movementState = newState;
|
|
82
86
|
return;
|
|
83
87
|
}
|
|
84
|
-
const timePassed =
|
|
88
|
+
const timePassed = services_1.Utils.nowMS() - this._movementStartMs;
|
|
85
89
|
const oldState = this._movementState;
|
|
86
90
|
if (this._movementStartPos === 0 && oldState === MovementState.Up && this._setLevel === 100) {
|
|
87
|
-
this.
|
|
88
|
-
this.log(logLevel_1.LogLevel.Debug, `New Time-Until-Top measurement for ${this.info.customName}: ${timePassed}ms`);
|
|
91
|
+
this.log(models_1.LogLevel.Debug, `New Time-Until-Top measurement for ${this.info.customName}: ${timePassed}ms`);
|
|
89
92
|
this.currentLevel = this._setLevel;
|
|
90
93
|
this._shutterCalibrationData.counterUp++;
|
|
91
94
|
this._shutterCalibrationData.averageUp +=
|
|
92
|
-
(
|
|
95
|
+
(timePassed - this._shutterCalibrationData.averageUp) / this._shutterCalibrationData.counterUp;
|
|
93
96
|
this.persistCalibrationData();
|
|
94
|
-
this.log(
|
|
97
|
+
this.log(models_1.LogLevel.Trace, `New Measurment for shutter up (${this.getAverageUp()}ms), new Average: ${this._shutterCalibrationData.averageUp}`);
|
|
95
98
|
return;
|
|
96
99
|
}
|
|
97
100
|
if (this._movementStartPos === 100 && oldState === MovementState.Down && this._setLevel === 0) {
|
|
98
|
-
this.log(
|
|
99
|
-
this._msTilBot = timePassed;
|
|
101
|
+
this.log(models_1.LogLevel.Debug, `New Time-Until-Bottom measurement for ${this.info.customName}: ${timePassed}ms`);
|
|
100
102
|
this.currentLevel = this._setLevel;
|
|
101
103
|
this._shutterCalibrationData.counterDown++;
|
|
102
104
|
this._shutterCalibrationData.averageDown +=
|
|
103
|
-
(
|
|
105
|
+
(timePassed - this._shutterCalibrationData.averageDown) / this._shutterCalibrationData.counterDown;
|
|
104
106
|
this.persistCalibrationData();
|
|
105
|
-
this.log(
|
|
107
|
+
this.log(models_1.LogLevel.Trace, `New Measurment for shutter down (${this.getAverageDown()}ms), new Average: ${this._shutterCalibrationData.averageDown}`);
|
|
106
108
|
return;
|
|
107
109
|
}
|
|
108
110
|
if (!this.isCalibrated()) {
|
|
109
111
|
return;
|
|
110
112
|
}
|
|
111
113
|
if (oldState === MovementState.Down) {
|
|
112
|
-
this.currentLevel = Math.min(this._currentLevel - Math.round((timePassed * 100) / this.
|
|
114
|
+
this.currentLevel = Math.min(this._currentLevel - Math.round((timePassed * 100) / this.getAverageDown()), 0);
|
|
113
115
|
}
|
|
114
116
|
else if (oldState === MovementState.Up) {
|
|
115
|
-
this.currentLevel = Math.max(this._currentLevel + Math.round((timePassed * 100) / this.
|
|
117
|
+
this.currentLevel = Math.max(this._currentLevel + Math.round((timePassed * 100) / this.getAverageUp()), 100);
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
/// <reference types="iobroker" />
|
|
2
3
|
import { DeviceType } from '../deviceType';
|
|
3
4
|
import { DeviceInfo } from '../DeviceInfo';
|
|
5
|
+
import { ShutterCalibration, ShutterSettings } from '../../../models';
|
|
4
6
|
import { ZigbeeDevice } from './zigbeeDevice';
|
|
5
7
|
import { iShutter } from '../iShutter';
|
|
6
|
-
import { Fenster } from '../groups
|
|
8
|
+
import { Fenster } from '../groups';
|
|
7
9
|
import { IoBrokerBaseDevice } from '../IoBrokerBaseDevice';
|
|
8
|
-
import { ShutterSettings } from '../../../models/deviceSettings/shutterSettings';
|
|
9
|
-
import { ShutterCalibration } from '../../../models/persistence/ShutterCalibration';
|
|
10
10
|
export declare class ZigbeeShutter extends ZigbeeDevice implements iShutter {
|
|
11
11
|
settings: ShutterSettings;
|
|
12
|
+
protected _iMovementFinishTimeout: NodeJS.Timeout | null;
|
|
12
13
|
get currentLevel(): number;
|
|
13
14
|
set currentLevel(value: number);
|
|
14
15
|
get desiredFensterLevel(): number;
|
|
@@ -28,5 +29,6 @@ export declare class ZigbeeShutter extends ZigbeeDevice implements iShutter {
|
|
|
28
29
|
protected getAverageDown(): number;
|
|
29
30
|
protected isCalibrated(): boolean;
|
|
30
31
|
protected persistCalibrationData(): void;
|
|
32
|
+
protected initializeMovementFinishTimeout(duration: number, endPosition: number): void;
|
|
31
33
|
toJSON(): Partial<IoBrokerBaseDevice>;
|
|
32
34
|
}
|
|
@@ -4,29 +4,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ZigbeeShutter = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const services_1 = require("../../services");
|
|
8
|
+
const models_1 = require("../../../models");
|
|
9
9
|
const zigbeeDevice_1 = require("./zigbeeDevice");
|
|
10
|
-
const
|
|
10
|
+
const models_2 = require("../models");
|
|
11
11
|
const lodash_1 = __importDefault(require("lodash"));
|
|
12
|
-
const shutterSettings_1 = require("../../../models/deviceSettings/shutterSettings");
|
|
13
|
-
const ShutterCalibration_1 = require("../../../models/persistence/ShutterCalibration");
|
|
14
12
|
const index_1 = require("../../../index");
|
|
15
13
|
class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
|
|
16
14
|
constructor(pInfo, pType) {
|
|
17
15
|
super(pInfo, pType);
|
|
18
|
-
this.settings = new
|
|
16
|
+
this.settings = new models_1.ShutterSettings();
|
|
17
|
+
this._iMovementFinishTimeout = null;
|
|
19
18
|
this._currentLevel = -1;
|
|
20
19
|
this._firstCommandRecieved = false;
|
|
21
20
|
this._setLevel = -1;
|
|
22
21
|
this._setLevelTime = -1;
|
|
23
|
-
this._shutterCalibrationData = new
|
|
22
|
+
this._shutterCalibrationData = new models_1.ShutterCalibration(this.info.fullID, 0, 0, 0, 0);
|
|
24
23
|
index_1.dbo === null || index_1.dbo === void 0 ? void 0 : index_1.dbo.getShutterCalibration(this).then((calibrationData) => {
|
|
25
24
|
this._shutterCalibrationData = calibrationData;
|
|
26
|
-
this.log(
|
|
25
|
+
this.log(models_1.LogLevel.DeepTrace, `ZigbeeShutter initialized with calibration data`);
|
|
27
26
|
}).catch((err) => {
|
|
28
27
|
var _a;
|
|
29
|
-
this.log(
|
|
28
|
+
this.log(models_1.LogLevel.Warn, `Failed to initialize Calibration data, err ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : err}`);
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
get currentLevel() {
|
|
@@ -36,11 +35,11 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
36
35
|
return this._currentLevel;
|
|
37
36
|
}
|
|
38
37
|
set currentLevel(value) {
|
|
39
|
-
if (value !== this._setLevel &&
|
|
38
|
+
if (value !== this._setLevel && services_1.Utils.nowMS() - this._setLevelTime < 60 * 10000) {
|
|
40
39
|
value = this._setLevel;
|
|
41
40
|
}
|
|
42
41
|
if (value !== this._currentLevel && this._fenster) {
|
|
43
|
-
|
|
42
|
+
services_1.Utils.guardedNewThread(() => {
|
|
44
43
|
var _a;
|
|
45
44
|
(_a = this._fenster) === null || _a === void 0 ? void 0 : _a.rolloPositionChange(value);
|
|
46
45
|
}, this);
|
|
@@ -67,33 +66,33 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
67
66
|
this._firstCommandRecieved = true;
|
|
68
67
|
}
|
|
69
68
|
else if (this._firstCommandRecieved && initial) {
|
|
70
|
-
this.log(
|
|
69
|
+
this.log(models_1.LogLevel.Debug, `Skipped initial Rollo to ${pPosition} as we recieved a command already`);
|
|
71
70
|
return;
|
|
72
71
|
}
|
|
73
72
|
if (this.currentLevel === pPosition) {
|
|
74
|
-
this.log(
|
|
73
|
+
this.log(models_1.LogLevel.Debug, `Skip Rollo command to Position ${pPosition} as this is the current one`);
|
|
75
74
|
return;
|
|
76
75
|
}
|
|
77
76
|
if (this._fenster !== undefined) {
|
|
78
|
-
if (this._fenster.griffeInPosition(
|
|
77
|
+
if (this._fenster.griffeInPosition(models_2.FensterPosition.offen) > 0 && pPosition < 100) {
|
|
79
78
|
if (!skipOpenWarning) {
|
|
80
|
-
this.log(
|
|
79
|
+
this.log(models_1.LogLevel.Alert, `Fahre Rollo nicht runter, weil das Fenster offen ist!`);
|
|
81
80
|
}
|
|
82
81
|
return;
|
|
83
82
|
}
|
|
84
|
-
if (this._fenster.griffeInPosition(
|
|
83
|
+
if (this._fenster.griffeInPosition(models_2.FensterPosition.kipp) > 0 && pPosition < 50) {
|
|
85
84
|
pPosition = 50;
|
|
86
85
|
if (!skipOpenWarning) {
|
|
87
|
-
this.log(
|
|
86
|
+
this.log(models_1.LogLevel.Alert, `Fahre Rollo nicht runter, weil das Fenster auf Kipp ist!`);
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
this._setLevel = pPosition;
|
|
92
|
-
this.log(
|
|
91
|
+
this.log(models_1.LogLevel.Debug, `Move to position ${pPosition}`);
|
|
93
92
|
this.moveToPosition(pPosition);
|
|
94
93
|
}
|
|
95
94
|
moveToPosition(pPosition) {
|
|
96
|
-
this.log(
|
|
95
|
+
this.log(models_1.LogLevel.Error, `Implement own moveToPosition(${pPosition}) Function`);
|
|
97
96
|
}
|
|
98
97
|
getAverageUp() {
|
|
99
98
|
if (this._shutterCalibrationData.averageUp > 0) {
|
|
@@ -102,7 +101,7 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
102
101
|
if (this.settings.msTilTop > 0) {
|
|
103
102
|
return this.settings.msTilTop;
|
|
104
103
|
}
|
|
105
|
-
return
|
|
104
|
+
return 30000;
|
|
106
105
|
}
|
|
107
106
|
getAverageDown() {
|
|
108
107
|
if (this._shutterCalibrationData.averageDown > 0) {
|
|
@@ -111,15 +110,24 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
111
110
|
if (this.settings.msTilBot > 0) {
|
|
112
111
|
return this.settings.msTilBot;
|
|
113
112
|
}
|
|
114
|
-
return
|
|
113
|
+
return 30000;
|
|
115
114
|
}
|
|
116
115
|
isCalibrated() {
|
|
117
116
|
return this.getAverageDown() > 0 && this.getAverageUp() > 0;
|
|
118
117
|
}
|
|
119
118
|
persistCalibrationData() {
|
|
120
|
-
this.log(
|
|
119
|
+
this.log(models_1.LogLevel.Trace, `Persiting Calibration Data. Average Up: ${this._shutterCalibrationData.averageUp}, Down: ${this._shutterCalibrationData.averageDown}`);
|
|
121
120
|
index_1.dbo === null || index_1.dbo === void 0 ? void 0 : index_1.dbo.persistShutterCalibration(this._shutterCalibrationData);
|
|
122
121
|
}
|
|
122
|
+
initializeMovementFinishTimeout(duration, endPosition) {
|
|
123
|
+
if (this._iMovementFinishTimeout !== null) {
|
|
124
|
+
clearTimeout(this._iMovementFinishTimeout);
|
|
125
|
+
}
|
|
126
|
+
this._iMovementFinishTimeout = services_1.Utils.guardedTimeout(() => {
|
|
127
|
+
this.currentLevel = endPosition;
|
|
128
|
+
this._iMovementFinishTimeout = null;
|
|
129
|
+
}, duration, this);
|
|
130
|
+
}
|
|
123
131
|
toJSON() {
|
|
124
132
|
return lodash_1.default.omit(super.toJSON(), ['_fenster']);
|
|
125
133
|
}
|
|
@@ -13,8 +13,8 @@ export declare class SunTimeOffsets {
|
|
|
13
13
|
maximumHours: number;
|
|
14
14
|
maximumMinutes: number;
|
|
15
15
|
constructor(sunrise?: number, sunset?: number, minimumHours?: number, minimumMinutes?: number, maximumHours?: number, maximumMinutes?: number);
|
|
16
|
-
getNextMinimumSunrise(): Date;
|
|
17
|
-
getNextMaximumSunset(): Date;
|
|
16
|
+
getNextMinimumSunrise(date?: Date): Date;
|
|
17
|
+
getNextMaximumSunset(date?: Date): Date;
|
|
18
18
|
}
|
|
19
19
|
export declare class TimeCallbackService {
|
|
20
20
|
private static _todaySunRise;
|
|
@@ -34,6 +34,6 @@ export declare class TimeCallbackService {
|
|
|
34
34
|
static performCheck(): void;
|
|
35
35
|
static recalcSunTimes(): void;
|
|
36
36
|
static removeCallback(pCallback: TimeCallback): void;
|
|
37
|
-
static updateSunRise(pDay?: Date): void;
|
|
38
|
-
static updateSunSet(pDay?: Date): void;
|
|
37
|
+
static updateSunRise(pDay?: Date, lat?: number, long?: number): void;
|
|
38
|
+
static updateSunSet(pDay?: Date, lat?: number, long?: number): void;
|
|
39
39
|
}
|
|
@@ -24,19 +24,21 @@ class SunTimeOffsets {
|
|
|
24
24
|
this.maximumHours = maximumHours;
|
|
25
25
|
this.maximumMinutes = maximumMinutes;
|
|
26
26
|
}
|
|
27
|
-
getNextMinimumSunrise() {
|
|
28
|
-
const
|
|
29
|
-
|
|
27
|
+
getNextMinimumSunrise(date = new Date()) {
|
|
28
|
+
const dateCopy = new Date(date);
|
|
29
|
+
const today = new Date(dateCopy.setHours(this.minimumHours, this.minimumMinutes, 0, 0));
|
|
30
|
+
if (today > date) {
|
|
30
31
|
return today;
|
|
31
32
|
}
|
|
32
|
-
return new Date(today.
|
|
33
|
+
return new Date(today.setDate(today.getDate() + 1));
|
|
33
34
|
}
|
|
34
|
-
getNextMaximumSunset() {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
getNextMaximumSunset(date = new Date()) {
|
|
36
|
+
const dateCopy = new Date(date);
|
|
37
|
+
const today = new Date(dateCopy.setHours(this.maximumHours, this.maximumMinutes, 0, 0));
|
|
38
|
+
if (today > date) {
|
|
37
39
|
return today;
|
|
38
40
|
}
|
|
39
|
-
return new Date(today.
|
|
41
|
+
return new Date(today.setDate(today.getDate() + 1));
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
exports.SunTimeOffsets = SunTimeOffsets;
|
|
@@ -170,11 +172,11 @@ Nächster Sonnenuntergang um ${TimeCallbackService._nextSunSet.toLocaleTimeStrin
|
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
174
|
}
|
|
173
|
-
static updateSunRise(pDay = new Date()) {
|
|
174
|
-
TimeCallbackService._nextSunRise = (0, sunrise_sunset_js_1.getSunrise)(
|
|
175
|
+
static updateSunRise(pDay = new Date(), lat = 51.529556852253826, long = 7.097266042276687) {
|
|
176
|
+
TimeCallbackService._nextSunRise = (0, sunrise_sunset_js_1.getSunrise)(lat, long, pDay);
|
|
175
177
|
}
|
|
176
|
-
static updateSunSet(pDay = new Date()) {
|
|
177
|
-
TimeCallbackService._nextSunSet = (0, sunrise_sunset_js_1.getSunset)(
|
|
178
|
+
static updateSunSet(pDay = new Date(), lat = 51.529556852253826, long = 7.097266042276687) {
|
|
179
|
+
TimeCallbackService._nextSunSet = (0, sunrise_sunset_js_1.getSunset)(lat, long, pDay);
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
182
|
exports.TimeCallbackService = TimeCallbackService;
|