hoffmation-base 0.1.41-1 → 0.1.41-10
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/device-cluster.d.ts +1 -1
- package/lib/server/devices/device-cluster.js +3 -2
- package/lib/server/devices/deviceType.d.ts +1 -0
- package/lib/server/devices/deviceType.js +1 -0
- package/lib/server/devices/devices.d.ts +4 -5
- package/lib/server/devices/devices.js +78 -102
- package/lib/server/devices/groups/lampenGroup.d.ts +2 -3
- package/lib/server/devices/groups/lampenGroup.js +2 -2
- package/lib/server/devices/iEnergyManager.d.ts +16 -0
- package/lib/server/devices/iEnergyManager.js +28 -0
- package/lib/server/devices/jsObject/jsObjectEnergyManager.d.ts +36 -24
- package/lib/server/devices/jsObject/jsObjectEnergyManager.js +72 -31
- package/lib/server/devices/zigbee/index.d.ts +1 -0
- package/lib/server/devices/zigbee/index.js +1 -0
- 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/devices/zigbee/zigbeeUbisysShutter.d.ts +9 -0
- package/lib/server/devices/zigbee/zigbeeUbisysShutter.js +26 -0
- package/lib/server/services/ShutterService.d.ts +1 -2
- package/lib/server/services/ShutterService.js +6 -5
- package/lib/server/services/calendar/m/303/274ll-service.d.ts +4 -4
- package/lib/server/services/calendar/m/303/274ll-service.js +18 -14
- package/lib/server/services/dbo/postgreSqlPersist.d.ts +9 -9
- package/lib/server/services/dbo/postgreSqlPersist.js +13 -13
- package/lib/server/services/room-service/room-service.d.ts +4 -5
- package/lib/server/services/room-service/room-service.js +29 -30
- 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,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsObjectEnergyManager = void 0;
|
|
4
4
|
const IoBrokerBaseDevice_1 = require("../IoBrokerBaseDevice");
|
|
5
|
+
const iEnergyManager_1 = require("../iEnergyManager");
|
|
5
6
|
const deviceType_1 = require("../deviceType");
|
|
6
7
|
const models_1 = require("../../../models");
|
|
7
8
|
const services_1 = require("../../services");
|
|
@@ -9,59 +10,88 @@ const index_1 = require("../../../index");
|
|
|
9
10
|
class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
10
11
|
constructor(info) {
|
|
11
12
|
super(info, deviceType_1.DeviceType.JsEnergyManager);
|
|
12
|
-
this._currentProduction = -1;
|
|
13
|
-
this._excessEnergy = -1;
|
|
14
|
-
this._excessEnergyConsumerConsumption = 0;
|
|
15
13
|
this._excessEnergyConsumer = [];
|
|
14
|
+
this._iCalculationInterval = null;
|
|
16
15
|
this._iDatabaseLoggerInterval = null;
|
|
17
16
|
this._lastPersistenceCalculation = services_1.Utils.nowMS();
|
|
17
|
+
this._powerValuePhaseA = -1;
|
|
18
|
+
this._powerValuePhaseB = -1;
|
|
19
|
+
this._powerValuePhaseC = -1;
|
|
20
|
+
this._currentProduction = -1;
|
|
21
|
+
this._excessEnergyConsumerConsumption = 0;
|
|
22
|
+
this._phaseAState = new iEnergyManager_1.PhaseState(0, 0);
|
|
23
|
+
this._phaseBState = new iEnergyManager_1.PhaseState(0, 0);
|
|
24
|
+
this._phaseCState = new iEnergyManager_1.PhaseState(0, 0);
|
|
18
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);
|
|
19
29
|
this._iDatabaseLoggerInterval = services_1.Utils.guardedInterval(() => {
|
|
20
30
|
this.persist();
|
|
21
31
|
}, 15 * 60 * 1000, this);
|
|
22
32
|
this._nextPersistEntry = new index_1.EnergyCalculation(services_1.Utils.nowMS());
|
|
23
33
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* ________________________________________
|
|
27
|
-
* | ExcessEnergy | 500W | -500W | -500W |
|
|
28
|
-
* | Production | 1500W | 500W | 0W |
|
|
29
|
-
* _______________________________________
|
|
30
|
-
* | Consumption | 1000W | 1000W | 500W |
|
|
31
|
-
* | Injecting | 500W | 0W | 0W |
|
|
32
|
-
* | drawing | 0W | 500W | 500W |
|
|
33
|
-
* | selfConsume | 1000W | 500W | 0W |
|
|
34
|
-
* ________________________________________
|
|
35
|
-
**/
|
|
36
|
-
get excessEnergyConsumerConsumption() {
|
|
37
|
-
return this._excessEnergyConsumerConsumption;
|
|
38
|
-
}
|
|
39
|
-
get excessEnergy() {
|
|
40
|
-
return this._excessEnergy;
|
|
34
|
+
get currentProduction() {
|
|
35
|
+
return this._currentProduction;
|
|
41
36
|
}
|
|
42
37
|
get baseConsumption() {
|
|
43
38
|
return this.totalConsumption - this._excessEnergyConsumerConsumption;
|
|
44
39
|
}
|
|
45
40
|
get totalConsumption() {
|
|
46
|
-
return this.
|
|
41
|
+
return (this.phaseAState.totalConsumptionWattage +
|
|
42
|
+
this.phaseBState.totalConsumptionWattage +
|
|
43
|
+
this.phaseCState.totalConsumptionWattage);
|
|
47
44
|
}
|
|
48
45
|
get injectingWattage() {
|
|
49
|
-
return
|
|
46
|
+
return this.phaseAState.injectingWattage + this.phaseBState.injectingWattage + this.phaseCState.injectingWattage;
|
|
50
47
|
}
|
|
51
48
|
get drawingWattage() {
|
|
52
|
-
return
|
|
49
|
+
return this.phaseAState.drawingWattage + this.phaseBState.drawingWattage + this.phaseCState.drawingWattage;
|
|
53
50
|
}
|
|
54
51
|
get selfConsumingWattage() {
|
|
55
|
-
return
|
|
52
|
+
return (this.phaseAState.selfConsumingWattage +
|
|
53
|
+
this.phaseBState.selfConsumingWattage +
|
|
54
|
+
this.phaseCState.selfConsumingWattage);
|
|
56
55
|
}
|
|
57
|
-
get
|
|
58
|
-
return this.
|
|
56
|
+
get excessEnergy() {
|
|
57
|
+
return this._powerValuePhaseA + this._powerValuePhaseB + this._powerValuePhaseC;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Example:
|
|
61
|
+
* ________________________________________
|
|
62
|
+
* | ExcessEnergyA | 200W | 200W | -500W |
|
|
63
|
+
* | ExcessEnergyB | 300W | 300W | -200W |
|
|
64
|
+
* | ExcessEnergyC | 100W | -100W | -300W |
|
|
65
|
+
* | Production P | 500W | 500W | 0W |
|
|
66
|
+
* | Production | 1500W | 1500W | 0W |
|
|
67
|
+
* ________________________________________
|
|
68
|
+
* | Consumption | 900W | 1100W | 1000W |
|
|
69
|
+
* | Injecting | 600W | 500W | 0W |
|
|
70
|
+
* | drawing | 0W | 100W | 1000W |
|
|
71
|
+
* | selfConsume | 900W | 1000W | 0W |
|
|
72
|
+
* ________________________________________
|
|
73
|
+
**/
|
|
74
|
+
get excessEnergyConsumerConsumption() {
|
|
75
|
+
return this._excessEnergyConsumerConsumption;
|
|
76
|
+
}
|
|
77
|
+
get phaseAState() {
|
|
78
|
+
return this._phaseAState;
|
|
79
|
+
}
|
|
80
|
+
get phaseBState() {
|
|
81
|
+
return this._phaseBState;
|
|
82
|
+
}
|
|
83
|
+
get phaseCState() {
|
|
84
|
+
return this._phaseCState;
|
|
59
85
|
}
|
|
60
86
|
cleanup() {
|
|
61
87
|
if (this._iDatabaseLoggerInterval !== null) {
|
|
62
88
|
clearInterval(this._iDatabaseLoggerInterval);
|
|
63
89
|
this._iDatabaseLoggerInterval = null;
|
|
64
90
|
}
|
|
91
|
+
if (this._iCalculationInterval !== null) {
|
|
92
|
+
clearInterval(this._iCalculationInterval);
|
|
93
|
+
this._iCalculationInterval = null;
|
|
94
|
+
}
|
|
65
95
|
}
|
|
66
96
|
addExcessConsumer(device) {
|
|
67
97
|
this._excessEnergyConsumer.push(device);
|
|
@@ -72,9 +102,17 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
72
102
|
update(idSplit, state, initial, pOverride = false) {
|
|
73
103
|
this.log(models_1.LogLevel.DeepTrace, `EnergyManager: ${initial ? 'Initial ' : ''} update: ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}, override: ${pOverride}`);
|
|
74
104
|
switch (idSplit[3]) {
|
|
75
|
-
case '
|
|
76
|
-
this.log(models_1.LogLevel.Trace, `Current excess
|
|
77
|
-
this.
|
|
105
|
+
case 'CurrentExcessEnergyPhaseA':
|
|
106
|
+
this.log(models_1.LogLevel.Trace, `Current excess energyA update to ${state.val}`);
|
|
107
|
+
this._powerValuePhaseA = state.val;
|
|
108
|
+
break;
|
|
109
|
+
case 'CurrentExcessEnergyPhaseB':
|
|
110
|
+
this.log(models_1.LogLevel.Trace, `Current excess energyB update to ${state.val}`);
|
|
111
|
+
this._powerValuePhaseB = state.val;
|
|
112
|
+
break;
|
|
113
|
+
case 'CurrentExcessEnergyPhaseC':
|
|
114
|
+
this.log(models_1.LogLevel.Trace, `Current excess energyC update to ${state.val}`);
|
|
115
|
+
this._powerValuePhaseC = state.val;
|
|
78
116
|
break;
|
|
79
117
|
case 'CurrentProduction':
|
|
80
118
|
this.log(models_1.LogLevel.Trace, `Current Production Update to ${state.val}`);
|
|
@@ -82,8 +120,11 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
82
120
|
break;
|
|
83
121
|
}
|
|
84
122
|
}
|
|
85
|
-
|
|
86
|
-
this.
|
|
123
|
+
calculateExcessEnergy() {
|
|
124
|
+
const phaseProduction = this._currentProduction / 3.0;
|
|
125
|
+
this._phaseAState = new iEnergyManager_1.PhaseState(this._powerValuePhaseA, phaseProduction);
|
|
126
|
+
this._phaseBState = new iEnergyManager_1.PhaseState(this._powerValuePhaseB, phaseProduction);
|
|
127
|
+
this._phaseCState = new iEnergyManager_1.PhaseState(this._powerValuePhaseC, phaseProduction);
|
|
87
128
|
this.calculatePersistenceValues();
|
|
88
129
|
this.recalculatePowerSharing();
|
|
89
130
|
}
|
|
@@ -36,3 +36,4 @@ __exportStar(require("./zigbeeSMaBiTMagnetContact"), exports);
|
|
|
36
36
|
__exportStar(require("./zigbeeSonoffMotion"), exports);
|
|
37
37
|
__exportStar(require("./zigbeeSonoffTemp"), exports);
|
|
38
38
|
__exportStar(require("./zigbeeSwitch"), exports);
|
|
39
|
+
__exportStar(require("./zigbeeUbisysShutter"), exports);
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="iobroker" />
|
|
2
|
+
import { ZigbeeShutter } from './zigbeeShutter';
|
|
3
|
+
import { DeviceInfo } from '../DeviceInfo';
|
|
4
|
+
export declare class ZigbeeUbisysShutter extends ZigbeeShutter {
|
|
5
|
+
private _positionStateId;
|
|
6
|
+
constructor(pInfo: DeviceInfo);
|
|
7
|
+
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
8
|
+
protected moveToPosition(pPosition: number): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZigbeeUbisysShutter = void 0;
|
|
4
|
+
const zigbeeShutter_1 = require("./zigbeeShutter");
|
|
5
|
+
const deviceType_1 = require("../deviceType");
|
|
6
|
+
const models_1 = require("../../../models");
|
|
7
|
+
class ZigbeeUbisysShutter extends zigbeeShutter_1.ZigbeeShutter {
|
|
8
|
+
constructor(pInfo) {
|
|
9
|
+
super(pInfo, deviceType_1.DeviceType.ZigbeeUbisysShutter);
|
|
10
|
+
this._positionStateId = `${this.info.fullID}.position`;
|
|
11
|
+
// this.presenceStateID = `${this.info.fullID}.1.${HmIpPraezenz.PRESENCE_DETECTION}`;
|
|
12
|
+
}
|
|
13
|
+
update(idSplit, state, initial = false) {
|
|
14
|
+
switch (idSplit[3]) {
|
|
15
|
+
case 'position':
|
|
16
|
+
this.log(models_1.LogLevel.Trace, `Shutter Update for ${this.info.customName} to "${state.val}"`);
|
|
17
|
+
this.currentLevel = state.val;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
super.update(idSplit, state, initial, true);
|
|
21
|
+
}
|
|
22
|
+
moveToPosition(pPosition) {
|
|
23
|
+
this.setState(this._positionStateId, pPosition);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.ZigbeeUbisysShutter = ZigbeeUbisysShutter;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { iShutter } from '../devices
|
|
2
|
-
import { Fenster } from '../devices/groups/Fenster';
|
|
1
|
+
import { Fenster, iShutter } from '../devices';
|
|
3
2
|
export declare class ShutterService {
|
|
4
3
|
static anyRolloDown(rollo: iShutter[]): boolean;
|
|
5
4
|
static getRolladenPosition(): string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ShutterService = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const api_service_1 = require("./api/api-service");
|
|
4
|
+
const devices_1 = require("../devices");
|
|
5
|
+
const api_1 = require("./api");
|
|
7
6
|
class ShutterService {
|
|
8
7
|
static anyRolloDown(rollo) {
|
|
9
8
|
for (let i = 0; i < rollo.length; i++) {
|
|
@@ -24,7 +23,7 @@ class ShutterService {
|
|
|
24
23
|
}
|
|
25
24
|
response.push(`\nDie nächsten Zeiten zum Hochfahren:`);
|
|
26
25
|
const down = [`\nDie nächsten Zeiten zum Runterfahren:`];
|
|
27
|
-
for (const r of
|
|
26
|
+
for (const r of api_1.API.getRooms().values()) {
|
|
28
27
|
if (!r.FensterGroup) {
|
|
29
28
|
continue;
|
|
30
29
|
}
|
|
@@ -43,7 +42,9 @@ class ShutterService {
|
|
|
43
42
|
const rollos = [];
|
|
44
43
|
for (const dID in devices_1.Devices.alLDevices) {
|
|
45
44
|
const d = devices_1.Devices.alLDevices[dID];
|
|
46
|
-
if (d.deviceType ===
|
|
45
|
+
if (d.deviceType === devices_1.DeviceType.HmIpRoll ||
|
|
46
|
+
d.deviceType === devices_1.DeviceType.ZigbeeIlluShutter ||
|
|
47
|
+
d.deviceType === devices_1.DeviceType.ZigbeeUbisysShutter) {
|
|
47
48
|
rollos.push(d);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TimeCallback } from '../../../models
|
|
2
|
-
import { iMuellSettings } from '../../config
|
|
3
|
-
import { OwnSonosDevice } from '../Sonos
|
|
1
|
+
import { TimeCallback } from '../../../models';
|
|
2
|
+
import { iMuellSettings } from '../../config';
|
|
3
|
+
import { OwnSonosDevice } from '../Sonos';
|
|
4
4
|
import { MuellTonne } from './muell-tonne';
|
|
5
5
|
export declare class MuellService {
|
|
6
6
|
static alleTonnen: Array<{
|
|
@@ -13,11 +13,11 @@ export declare class MuellService {
|
|
|
13
13
|
static brauneTonne: MuellTonne;
|
|
14
14
|
static updateTimeCallback: TimeCallback;
|
|
15
15
|
static checkTimeCallback: TimeCallback;
|
|
16
|
+
static months: string[];
|
|
16
17
|
private static lastCheck;
|
|
17
18
|
private static _calendarURL;
|
|
18
19
|
private static _active;
|
|
19
20
|
private static defaultSonosDevice;
|
|
20
|
-
static months: string[];
|
|
21
21
|
static intialize(config: iMuellSettings, defaultSonosDevice: OwnSonosDevice | undefined): void;
|
|
22
22
|
static updateCalendar(checkAfterwards?: boolean): void;
|
|
23
23
|
static checkAll(pRetries?: number): void;
|