hoffmation-base 3.2.9 → 3.2.10-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/command/ShutterSetLevelCommand.d.ts +7 -0
- package/lib/devices/groups/Window.d.ts +1 -2
- package/lib/devices/groups/Window.js +17 -14
- package/lib/devices/groups/windowGroup.d.ts +1 -0
- package/lib/devices/groups/windowGroup.js +32 -14
- package/lib/devices/hmIPDevices/hmIpRoll.d.ts +12 -2
- package/lib/devices/hmIPDevices/hmIpRoll.js +17 -38
- package/lib/devices/sharedFunctions/index.d.ts +1 -0
- package/lib/devices/sharedFunctions/index.js +1 -0
- package/lib/devices/sharedFunctions/shutterUtils.d.ts +10 -0
- package/lib/devices/sharedFunctions/shutterUtils.js +79 -0
- package/lib/devices/velux/veluxShutter.d.ts +14 -4
- package/lib/devices/velux/veluxShutter.js +17 -38
- package/lib/devices/zigbee/BaseDevices/zigbeeShutter.d.ts +16 -3
- package/lib/devices/zigbee/BaseDevices/zigbeeShutter.js +20 -32
- package/lib/devices/zigbee/zigbeeIkeaShutter.d.ts +1 -1
- package/lib/devices/zigbee/zigbeeIkeaShutter.js +1 -1
- package/lib/devices/zigbee/zigbeeIlluShutter.d.ts +1 -1
- package/lib/devices/zigbee/zigbeeIlluShutter.js +2 -2
- package/lib/devices/zigbee/zigbeeUbisysShutter.d.ts +1 -1
- package/lib/devices/zigbee/zigbeeUbisysShutter.js +1 -1
- package/lib/interfaces/baseDevices/iShutter.d.ts +20 -2
- package/lib/interfaces/deviceSettings/iDeviceSettings.d.ts +2 -2
- package/lib/interfaces/groups/iWindow.d.ts +1 -1
- package/lib/services/RoomBase.js +4 -3
- package/lib/services/ShutterService.d.ts +1 -3
- package/lib/services/ShutterService.js +4 -8
- package/lib/services/weather/weather-service.js +6 -5
- package/lib/settingsObjects/deviceSettings/deviceSettings.d.ts +2 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { BaseCommand } from './baseCommand';
|
|
2
2
|
import { CommandSource, CommandType } from '../enums';
|
|
3
3
|
import { iBaseCommand } from './iBaseCommand';
|
|
4
|
+
import { BlockAutomaticCommand } from './blockAutomaticCommand';
|
|
4
5
|
export declare class ShutterSetLevelCommand extends BaseCommand {
|
|
5
6
|
readonly level: number;
|
|
6
7
|
readonly skipOpenWarning: boolean;
|
|
7
8
|
/** @inheritDoc */
|
|
8
9
|
type: CommandType;
|
|
10
|
+
/**
|
|
11
|
+
* The command to disable automatic actions for a specific duration.
|
|
12
|
+
* Null = no automatic actions will be disabled.
|
|
13
|
+
* Undefined = use device or global default
|
|
14
|
+
*/
|
|
15
|
+
disableAutomaticCommand: BlockAutomaticCommand | null | undefined;
|
|
9
16
|
/**
|
|
10
17
|
* Command to set the level of a shutter
|
|
11
18
|
* @param source - The source of the command
|
|
@@ -9,7 +9,6 @@ export declare class Window extends BaseGroup implements iWindow {
|
|
|
9
9
|
readonly vibrationIds: string[];
|
|
10
10
|
readonly shutterIds: string[];
|
|
11
11
|
readonly magnetIds: string[];
|
|
12
|
-
private _desiredPosition;
|
|
13
12
|
/**
|
|
14
13
|
* The desired shutter level for the window
|
|
15
14
|
* @returns {number} The level (0 closed, 100 open)
|
|
@@ -33,7 +32,7 @@ export declare class Window extends BaseGroup implements iWindow {
|
|
|
33
32
|
setDesiredPosition(c: WindowSetDesiredPositionCommand): void;
|
|
34
33
|
getHandle(): iHandle[];
|
|
35
34
|
getMagnetContact(): ZigbeeMagnetContact[];
|
|
36
|
-
getShutter(): iShutter
|
|
35
|
+
getShutter(): iShutter;
|
|
37
36
|
getVibration(): iVibrationSensor[];
|
|
38
37
|
griffeInPosition(pPosition: WindowPosition): number;
|
|
39
38
|
initialize(): void;
|
|
@@ -13,16 +13,14 @@ class Window extends base_group_1.BaseGroup {
|
|
|
13
13
|
* @returns {number} The level (0 closed, 100 open)
|
|
14
14
|
*/
|
|
15
15
|
get desiredPosition() {
|
|
16
|
-
return this.
|
|
16
|
+
return this.getShutter().baseAutomaticLevel;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Checks if any shutter is down (0%)
|
|
20
20
|
* @returns {boolean} true if any shutter is down
|
|
21
21
|
*/
|
|
22
22
|
get anyShutterDown() {
|
|
23
|
-
return this.getShutter().
|
|
24
|
-
return s.currentLevel === 0;
|
|
25
|
-
});
|
|
23
|
+
return this.getShutter().currentLevel === 0;
|
|
26
24
|
}
|
|
27
25
|
constructor(roomName, handleIds = [], vibrationIds = [], shutterIds = [], magnetIds = []) {
|
|
28
26
|
super(roomName, enums_1.GroupType.Window);
|
|
@@ -30,7 +28,6 @@ class Window extends base_group_1.BaseGroup {
|
|
|
30
28
|
this.vibrationIds = vibrationIds;
|
|
31
29
|
this.shutterIds = shutterIds;
|
|
32
30
|
this.magnetIds = magnetIds;
|
|
33
|
-
this._desiredPosition = 0;
|
|
34
31
|
this.deviceCluster.deviceMap.set(enums_1.DeviceClusterType.Handle, new device_list_1.DeviceList(handleIds));
|
|
35
32
|
this.deviceCluster.deviceMap.set(enums_1.DeviceClusterType.Vibration, new device_list_1.DeviceList(vibrationIds));
|
|
36
33
|
this.deviceCluster.deviceMap.set(enums_1.DeviceClusterType.Shutter, new device_list_1.DeviceList(shutterIds));
|
|
@@ -50,8 +47,11 @@ class Window extends base_group_1.BaseGroup {
|
|
|
50
47
|
* @param c - The command to execute
|
|
51
48
|
*/
|
|
52
49
|
setDesiredPosition(c) {
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const shutter = this.getShutter();
|
|
51
|
+
if (!shutter) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
shutter.setLevel(new command_1.ShutterSetLevelCommand(c, c.position));
|
|
55
55
|
}
|
|
56
56
|
getHandle() {
|
|
57
57
|
return this.deviceCluster.getDevicesByType(enums_1.DeviceClusterType.Handle);
|
|
@@ -60,7 +60,7 @@ class Window extends base_group_1.BaseGroup {
|
|
|
60
60
|
return this.deviceCluster.getIoBrokerDevicesByType(enums_1.DeviceClusterType.MagnetContact);
|
|
61
61
|
}
|
|
62
62
|
getShutter() {
|
|
63
|
-
return this.deviceCluster.getDevicesByType(enums_1.DeviceClusterType.Shutter);
|
|
63
|
+
return this.deviceCluster.getDevicesByType(enums_1.DeviceClusterType.Shutter)[0];
|
|
64
64
|
}
|
|
65
65
|
getVibration() {
|
|
66
66
|
return this.deviceCluster.getDevicesByType(enums_1.DeviceClusterType.Vibration);
|
|
@@ -77,6 +77,7 @@ class Window extends base_group_1.BaseGroup {
|
|
|
77
77
|
initialize() {
|
|
78
78
|
this.getHandle().forEach((griff) => {
|
|
79
79
|
griff.addKippCallback((kipp) => {
|
|
80
|
+
var _a;
|
|
80
81
|
if (!(kipp && this.griffeInPosition(enums_1.WindowPosition.open) === 0)) {
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
@@ -84,14 +85,14 @@ class Window extends base_group_1.BaseGroup {
|
|
|
84
85
|
element.vibrationBlockedByHandle = true;
|
|
85
86
|
});
|
|
86
87
|
const timeOfDay = services_1.TimeCallbackService.dayType(this.getRoom().settings.rolloOffset);
|
|
87
|
-
|
|
88
|
+
(_a = this.getShutter()) === null || _a === void 0 ? void 0 : _a.setLevel(new command_1.ShutterSetLevelCommand(enums_1.CommandSource.Force, services_1.TimeCallbackService.darkOutsideOrNight(timeOfDay) ? 50 : 100, 'Window ajar by handle'));
|
|
88
89
|
});
|
|
89
90
|
griff.addOffenCallback((offen) => {
|
|
90
91
|
if (offen) {
|
|
91
92
|
this.getVibration().forEach((element) => {
|
|
92
93
|
element.vibrationBlockedByHandle = true;
|
|
93
94
|
});
|
|
94
|
-
|
|
95
|
+
this.getShutter().setLevel(new command_1.ShutterSetLevelCommand(enums_1.CommandSource.Force, 100, 'Window opened by handle'));
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
98
|
});
|
|
@@ -113,22 +114,24 @@ class Window extends base_group_1.BaseGroup {
|
|
|
113
114
|
});
|
|
114
115
|
});
|
|
115
116
|
utils_1.Utils.guardedTimeout(() => {
|
|
116
|
-
this.getShutter()
|
|
117
|
+
const shutter = this.getShutter();
|
|
118
|
+
if (shutter) {
|
|
117
119
|
shutter.window = this;
|
|
118
|
-
}
|
|
120
|
+
}
|
|
119
121
|
this.getHandle().forEach((g) => {
|
|
120
122
|
g.window = this;
|
|
121
123
|
});
|
|
122
124
|
}, 5, this);
|
|
123
125
|
}
|
|
124
126
|
rolloPositionChange(action) {
|
|
125
|
-
this.log(enums_1.LogLevel.Debug, `Rollo Position Change in ${this.roomName}: ${action.reasonTrace}`, action.newPosition == this.
|
|
127
|
+
this.log(enums_1.LogLevel.Debug, `Rollo Position Change in ${this.roomName}: ${action.reasonTrace}`, action.newPosition == this.desiredPosition ? enums_1.LogDebugType.None : enums_1.LogDebugType.ShutterPositionChange);
|
|
126
128
|
if (action.newPosition === 0 || action.newPosition === 100) {
|
|
127
129
|
this.getRoom().setLightTimeBased(new command_1.RoomSetLightTimeBasedCommand(action, true));
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
restoreDesiredPosition(c) {
|
|
131
|
-
|
|
133
|
+
var _a;
|
|
134
|
+
(_a = this.getShutter()) === null || _a === void 0 ? void 0 : _a.blockAutomationHandler.liftAutomaticBlock(new command_1.BlockAutomaticLiftBlockCommand(c, 'Window restore desired position', true));
|
|
132
135
|
}
|
|
133
136
|
addHandleChangeCallback(cb) {
|
|
134
137
|
this.getHandle().forEach((griff) => {
|
|
@@ -42,5 +42,6 @@ export declare class WindowGroup extends BaseGroup implements iWindowGroup {
|
|
|
42
42
|
changeVibrationMotionBlock(block: boolean): void;
|
|
43
43
|
sunsetDown(c: ShutterSunsetDownCommand): void;
|
|
44
44
|
reconfigureSunsetShutterCallback(): void;
|
|
45
|
+
private setWindowShutterBaseAutomaticLevel;
|
|
45
46
|
reconfigureSunriseShutterCallback(): void;
|
|
46
47
|
}
|
|
@@ -6,7 +6,6 @@ const services_1 = require("../../services");
|
|
|
6
6
|
const enums_1 = require("../../enums");
|
|
7
7
|
const device_list_1 = require("../device-list");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
|
-
const weather_1 = require("../../services/weather");
|
|
10
9
|
const models_1 = require("../../models");
|
|
11
10
|
const base_group_1 = require("./base-group");
|
|
12
11
|
class WindowGroup extends base_group_1.BaseGroup {
|
|
@@ -84,31 +83,33 @@ class WindowGroup extends base_group_1.BaseGroup {
|
|
|
84
83
|
const timeOfDay = services_1.TimeCallbackService.dayType(room.settings.rolloOffset);
|
|
85
84
|
const darkOutside = services_1.TimeCallbackService.darkOutsideOrNight(timeOfDay);
|
|
86
85
|
this.windows.forEach((f) => {
|
|
87
|
-
var _a, _b, _c, _d, _e, _f;
|
|
88
|
-
const shutterSettings = (
|
|
86
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
87
|
+
const shutterSettings = (_a = f.getShutter()) === null || _a === void 0 ? void 0 : _a.settings;
|
|
89
88
|
if (!shutterSettings) {
|
|
90
89
|
return;
|
|
91
90
|
}
|
|
91
|
+
const shutter = f.getShutter();
|
|
92
|
+
if (!shutter || shutter.blockAutomationHandler.automaticBlockActive) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
92
95
|
if (darkOutside) {
|
|
93
96
|
f.restoreDesiredPosition(new command_1.WindowRestoreDesiredPositionCommand(c, "It's dark outside."));
|
|
94
97
|
return;
|
|
95
98
|
}
|
|
96
|
-
|
|
97
|
-
if (desiredPos > 0) {
|
|
98
|
-
desiredPos = weather_1.WeatherService.weatherRolloPosition(desiredPos, (_d = (_c = room.HeatGroup) === null || _c === void 0 ? void 0 : _c.desiredTemp) !== null && _d !== void 0 ? _d : -99, (_f = (_e = room.HeatGroup) === null || _e === void 0 ? void 0 : _e.temperature) !== null && _f !== void 0 ? _f : -99, this.log.bind(this), shutterSettings);
|
|
99
|
-
}
|
|
100
|
-
if (f.griffeInPosition(enums_1.WindowPosition.open) > 0 && desiredPos < 100) {
|
|
99
|
+
if (f.griffeInPosition(enums_1.WindowPosition.open) > 0 || f.griffeInPosition(enums_1.WindowPosition.tilted) > 0) {
|
|
101
100
|
return;
|
|
102
101
|
}
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
let desiredPos = f.desiredPosition;
|
|
103
|
+
if (desiredPos > 0) {
|
|
104
|
+
desiredPos = services_1.WeatherService.weatherRolloPosition((_c = (_b = f.getShutter()) === null || _b === void 0 ? void 0 : _b.baseAutomaticLevel) !== null && _c !== void 0 ? _c : 0, (_e = (_d = room.HeatGroup) === null || _d === void 0 ? void 0 : _d.desiredTemp) !== null && _e !== void 0 ? _e : -99, (_g = (_f = room.HeatGroup) === null || _f === void 0 ? void 0 : _f.temperature) !== null && _g !== void 0 ? _g : -99, this.log.bind(this), shutterSettings);
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
(_h = f.getShutter()) === null || _h === void 0 ? void 0 : _h.setLevel(new command_1.ShutterSetLevelCommand(c, desiredPos, '', true));
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
sunriseUp(c) {
|
|
110
|
+
this.setWindowShutterBaseAutomaticLevel(100);
|
|
110
111
|
this.windows.forEach((w) => {
|
|
111
|
-
if (!this.getRoom().settings.sonnenAufgangRollos || w.getShutter()
|
|
112
|
+
if (!this.getRoom().settings.sonnenAufgangRollos || w.getShutter() === undefined) {
|
|
112
113
|
return;
|
|
113
114
|
}
|
|
114
115
|
w.setDesiredPosition(new command_1.WindowSetDesiredPositionCommand(c, 100));
|
|
@@ -139,7 +140,14 @@ class WindowGroup extends base_group_1.BaseGroup {
|
|
|
139
140
|
});
|
|
140
141
|
}
|
|
141
142
|
sunsetDown(c) {
|
|
142
|
-
this.
|
|
143
|
+
this.windows.forEach((w) => {
|
|
144
|
+
const shutter = w.getShutter();
|
|
145
|
+
if (!shutter) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
shutter.baseAutomaticLevel = 0;
|
|
149
|
+
w.setDesiredPosition(new command_1.WindowSetDesiredPositionCommand(c, 0));
|
|
150
|
+
});
|
|
143
151
|
const room = this.getRoom();
|
|
144
152
|
room.setLightTimeBased(new command_1.RoomSetLightTimeBasedCommand(c, true, 'sunsetDown'));
|
|
145
153
|
}
|
|
@@ -158,7 +166,7 @@ class WindowGroup extends base_group_1.BaseGroup {
|
|
|
158
166
|
this.sunsetShutterCallback.sunTimeOffset = room.settings.rolloOffset;
|
|
159
167
|
if (room.settings.sonnenUntergangRolloAdditionalOffsetPerCloudiness > 0) {
|
|
160
168
|
this.sunsetShutterCallback.cloudOffset =
|
|
161
|
-
|
|
169
|
+
services_1.WeatherService.getCurrentCloudiness() * room.settings.sonnenUntergangRolloAdditionalOffsetPerCloudiness;
|
|
162
170
|
}
|
|
163
171
|
this.sunsetShutterCallback.recalcNextToDo(new Date());
|
|
164
172
|
}
|
|
@@ -169,12 +177,22 @@ class WindowGroup extends base_group_1.BaseGroup {
|
|
|
169
177
|
}, room.settings.rolloOffset.sunset);
|
|
170
178
|
if (services_1.TimeCallbackService.darkOutsideOrNight(services_1.TimeCallbackService.dayType(room.settings.rolloOffset))) {
|
|
171
179
|
utils_1.Utils.guardedTimeout(() => {
|
|
180
|
+
this.setWindowShutterBaseAutomaticLevel(0);
|
|
172
181
|
this.setDesiredPosition(new command_1.WindowSetDesiredPositionCommand(enums_1.CommandSource.Initial, 0, 'It is dark outside'));
|
|
173
182
|
}, 60000, this);
|
|
174
183
|
}
|
|
175
184
|
services_1.TimeCallbackService.addCallback(this.sunsetShutterCallback);
|
|
176
185
|
}
|
|
177
186
|
}
|
|
187
|
+
setWindowShutterBaseAutomaticLevel(level) {
|
|
188
|
+
this.windows.forEach((f) => {
|
|
189
|
+
const shutter = f.getShutter();
|
|
190
|
+
if (!shutter) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
shutter.baseAutomaticLevel = level;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
178
196
|
reconfigureSunriseShutterCallback() {
|
|
179
197
|
const room = this.getRoom();
|
|
180
198
|
if (!room.settings.sonnenAufgangRollos || !room.settings.rolloOffset) {
|
|
@@ -2,12 +2,20 @@ import { HmIPDevice } from './hmIpDevice';
|
|
|
2
2
|
import { iShutter, iWindow } from '../../interfaces';
|
|
3
3
|
import { ShutterSettings } from '../../settingsObjects';
|
|
4
4
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
5
|
-
import { ShutterSetLevelCommand } from '../../command';
|
|
5
|
+
import { RestoreTargetAutomaticValueCommand, ShutterSetLevelCommand } from '../../command';
|
|
6
|
+
import { BlockAutomaticHandler } from '../../services';
|
|
6
7
|
export declare class HmIpRoll extends HmIPDevice implements iShutter {
|
|
7
8
|
/** @inheritDoc */
|
|
8
9
|
settings: ShutterSettings;
|
|
10
|
+
/** @inheritDoc */
|
|
11
|
+
firstCommandRecieved: boolean;
|
|
12
|
+
/** @inheritDoc */
|
|
13
|
+
targetAutomaticValue: number;
|
|
14
|
+
/** @inheritDoc */
|
|
15
|
+
blockAutomationHandler: BlockAutomaticHandler;
|
|
16
|
+
/** @inheritDoc */
|
|
17
|
+
baseAutomaticLevel: number;
|
|
9
18
|
private _setLevelSwitchID;
|
|
10
|
-
private _firstCommandRecieved;
|
|
11
19
|
private _setLevel;
|
|
12
20
|
private _setLevelTime;
|
|
13
21
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
@@ -22,4 +30,6 @@ export declare class HmIpRoll extends HmIPDevice implements iShutter {
|
|
|
22
30
|
persist(): void;
|
|
23
31
|
private setCurrentLevel;
|
|
24
32
|
setLevel(command: ShutterSetLevelCommand): void;
|
|
33
|
+
writePositionStateToDevice(pPosition: number): void;
|
|
34
|
+
restoreTargetAutomaticValue(command: RestoreTargetAutomaticValueCommand): void;
|
|
25
35
|
}
|
|
@@ -7,19 +7,27 @@ const enums_1 = require("../../enums");
|
|
|
7
7
|
const command_1 = require("../../command");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
9
|
const action_1 = require("../../action");
|
|
10
|
+
const services_1 = require("../../services");
|
|
11
|
+
const sharedFunctions_1 = require("../sharedFunctions");
|
|
10
12
|
class HmIpRoll extends hmIpDevice_1.HmIPDevice {
|
|
11
13
|
constructor(pInfo) {
|
|
12
14
|
var _a;
|
|
13
15
|
super(pInfo, enums_1.DeviceType.HmIpRoll);
|
|
14
16
|
/** @inheritDoc */
|
|
15
17
|
this.settings = new settingsObjects_1.ShutterSettings();
|
|
16
|
-
|
|
18
|
+
/** @inheritDoc */
|
|
19
|
+
this.firstCommandRecieved = false;
|
|
20
|
+
/** @inheritDoc */
|
|
21
|
+
this.targetAutomaticValue = 0;
|
|
22
|
+
/** @inheritDoc */
|
|
23
|
+
this.baseAutomaticLevel = 0;
|
|
17
24
|
this._setLevel = -1;
|
|
18
25
|
this._setLevelTime = -1;
|
|
19
26
|
this._currentLevel = -1;
|
|
20
27
|
this.jsonOmitKeys.push('_window');
|
|
21
28
|
this.deviceCapabilities.push(enums_1.DeviceCapability.shutter);
|
|
22
29
|
this._setLevelSwitchID = `${this.info.fullID}.4.LEVEL`;
|
|
30
|
+
this.blockAutomationHandler = new services_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
|
|
23
31
|
(_a = this.dbo) === null || _a === void 0 ? void 0 : _a.getLastDesiredPosition(this).then((val) => {
|
|
24
32
|
var _a;
|
|
25
33
|
if (val.desiredPosition === -1) {
|
|
@@ -76,43 +84,14 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
|
|
|
76
84
|
this._currentLevel = value;
|
|
77
85
|
}
|
|
78
86
|
setLevel(command) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (this.currentLevel === targetLevel && !command.isForceAction) {
|
|
88
|
-
this.logCommand(command, `Skip Rollo command to Position ${targetLevel} as this is the current one`, enums_1.LogDebugType.SkipUnchangedRolloPosition);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (this._setLevelSwitchID === '') {
|
|
92
|
-
this.log(enums_1.LogLevel.Error, 'Keine Switch ID bekannt.');
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (!this.checkIoConnection(true)) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
this.logCommand(command);
|
|
99
|
-
if (this._window !== undefined) {
|
|
100
|
-
if (this._window.griffeInPosition(enums_1.WindowPosition.open) > 0 && command.level < 100) {
|
|
101
|
-
if (!command.skipOpenWarning) {
|
|
102
|
-
this.log(enums_1.LogLevel.Alert, 'Not closing the shutter, as the window is open!');
|
|
103
|
-
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (this._window.griffeInPosition(enums_1.WindowPosition.tilted) > 0 && targetLevel < 50) {
|
|
107
|
-
targetLevel = 50;
|
|
108
|
-
if (!command.skipOpenWarning) {
|
|
109
|
-
this.log(enums_1.LogLevel.Alert, 'Not closing the shutter, as the window is half open!');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
this._setLevel = targetLevel;
|
|
114
|
-
this.log(enums_1.LogLevel.Debug, `Fahre Rollo auf Position ${targetLevel}`);
|
|
115
|
-
this.setState(this._setLevelSwitchID, targetLevel);
|
|
87
|
+
sharedFunctions_1.ShutterUtils.setLevel(this, command);
|
|
88
|
+
}
|
|
89
|
+
writePositionStateToDevice(pPosition) {
|
|
90
|
+
this._setLevel = pPosition;
|
|
91
|
+
this.setState(this._setLevelSwitchID, pPosition);
|
|
92
|
+
}
|
|
93
|
+
restoreTargetAutomaticValue(command) {
|
|
94
|
+
this.setLevel(new command_1.ShutterSetLevelCommand(command, this.targetAutomaticValue));
|
|
116
95
|
}
|
|
117
96
|
}
|
|
118
97
|
exports.HmIpRoll = HmIpRoll;
|
|
@@ -18,4 +18,5 @@ __exportStar(require("./battery"), exports);
|
|
|
18
18
|
__exportStar(require("./handleSensor"), exports);
|
|
19
19
|
__exportStar(require("./humiditySensor"), exports);
|
|
20
20
|
__exportStar(require("./lampUtils"), exports);
|
|
21
|
+
__exportStar(require("./shutterUtils"), exports);
|
|
21
22
|
__exportStar(require("./temperatureSensor"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ShutterSetLevelCommand } from '../../command';
|
|
2
|
+
import { iShutter } from '../../interfaces';
|
|
3
|
+
export declare class ShutterUtils {
|
|
4
|
+
/**
|
|
5
|
+
* Handles setting the shutter level with all checks (block automation, window open, etc)
|
|
6
|
+
* @param device - The shutter
|
|
7
|
+
* @param c - The command
|
|
8
|
+
*/
|
|
9
|
+
static setLevel(device: iShutter, c: ShutterSetLevelCommand): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShutterUtils = void 0;
|
|
4
|
+
const enums_1 = require("../../enums");
|
|
5
|
+
const services_1 = require("../../services");
|
|
6
|
+
class ShutterUtils {
|
|
7
|
+
/**
|
|
8
|
+
* Handles setting the shutter level with all checks (block automation, window open, etc)
|
|
9
|
+
* @param device - The shutter
|
|
10
|
+
* @param c - The command
|
|
11
|
+
*/
|
|
12
|
+
static setLevel(device, c) {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
14
|
+
if (!c.isForceAction) {
|
|
15
|
+
// Set the target automatic value
|
|
16
|
+
device.targetAutomaticValue = c.level;
|
|
17
|
+
}
|
|
18
|
+
// Respect block automation
|
|
19
|
+
if (!c.isForceAction && device.blockAutomationHandler.automaticBlockActive) {
|
|
20
|
+
device.logCommand(c, `Skip shutter command to Position ${c.level} as automation is blocked until ${new Date(device.blockAutomationHandler.automaticBlockedUntil).toLocaleTimeString('de-DE')}`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (c.isManual &&
|
|
24
|
+
c.level > 0 &&
|
|
25
|
+
device.baseAutomaticLevel === 0 &&
|
|
26
|
+
!((_b = (_a = device.room) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.sonnenAufgangRollos) &&
|
|
27
|
+
((_d = (_c = device.room) === null || _c === void 0 ? void 0 : _c.settings) === null || _d === void 0 ? void 0 : _d.rolloOffset) &&
|
|
28
|
+
![enums_1.TimeOfDay.Night, enums_1.TimeOfDay.AfterSunset].includes(services_1.TimeCallbackService.dayType(device.room.settings.rolloOffset))) {
|
|
29
|
+
// First manual up command of the day on a window with no automatic up.
|
|
30
|
+
device.baseAutomaticLevel = 100;
|
|
31
|
+
}
|
|
32
|
+
else if (c.isManual &&
|
|
33
|
+
c.level === 0 &&
|
|
34
|
+
device.baseAutomaticLevel === 100 &&
|
|
35
|
+
!((_f = (_e = device.room) === null || _e === void 0 ? void 0 : _e.settings) === null || _f === void 0 ? void 0 : _f.sonnenUntergangRollos) &&
|
|
36
|
+
((_h = (_g = device.room) === null || _g === void 0 ? void 0 : _g.settings) === null || _h === void 0 ? void 0 : _h.rolloOffset) &&
|
|
37
|
+
[enums_1.TimeOfDay.Night, enums_1.TimeOfDay.AfterSunset].includes(services_1.TimeCallbackService.dayType(device.room.settings.rolloOffset))) {
|
|
38
|
+
// First manual down command of the day on a window with no automatic up.
|
|
39
|
+
device.baseAutomaticLevel = 0;
|
|
40
|
+
}
|
|
41
|
+
let pPosition = c.level;
|
|
42
|
+
if (!device.firstCommandRecieved && !c.isInitial) {
|
|
43
|
+
device.firstCommandRecieved = true;
|
|
44
|
+
}
|
|
45
|
+
else if (device.firstCommandRecieved && c.isInitial) {
|
|
46
|
+
device.logCommand(c, `Skipped initial shutter to ${pPosition} as we recieved a command already`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (device.currentLevel === pPosition && !c.isForceAction) {
|
|
50
|
+
device.logCommand(c, `Skip shutter command to Position ${pPosition} as this is the current one`, enums_1.LogDebugType.SkipUnchangedRolloPosition);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (c.disableAutomaticCommand === undefined && c.isForceAction) {
|
|
54
|
+
c.disableAutomaticCommand = device.settings.buildBlockAutomaticCommand(c);
|
|
55
|
+
}
|
|
56
|
+
if (c.disableAutomaticCommand) {
|
|
57
|
+
device.blockAutomationHandler.disableAutomatic(c.disableAutomaticCommand);
|
|
58
|
+
}
|
|
59
|
+
device.logCommand(c);
|
|
60
|
+
if (device.window !== undefined) {
|
|
61
|
+
if (device.window.griffeInPosition(enums_1.WindowPosition.open) > 0 && pPosition < 100) {
|
|
62
|
+
if (!c.skipOpenWarning) {
|
|
63
|
+
device.log(enums_1.LogLevel.Alert, 'Not closing the shutter, as the window is open!');
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (device.window.griffeInPosition(enums_1.WindowPosition.tilted) > 0 && pPosition < 50) {
|
|
68
|
+
pPosition = 50;
|
|
69
|
+
if (!c.skipOpenWarning) {
|
|
70
|
+
device.log(enums_1.LogLevel.Alert, 'Not closing the shutter, as the window is half open!');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Set the level and move
|
|
75
|
+
device.log(enums_1.LogLevel.Debug, `Move to position ${pPosition}`);
|
|
76
|
+
device.writePositionStateToDevice(pPosition);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.ShutterUtils = ShutterUtils;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { VeluxDevice } from './veluxDevice';
|
|
2
|
-
import { iShutter, iWindow } from '../../interfaces';
|
|
2
|
+
import { iShutter, iTemporaryDisableAutomatic, iWindow } from '../../interfaces';
|
|
3
3
|
import { ShutterSettings } from '../../settingsObjects';
|
|
4
4
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
5
|
-
import { ShutterSetLevelCommand } from '../../command';
|
|
6
|
-
|
|
5
|
+
import { RestoreTargetAutomaticValueCommand, ShutterSetLevelCommand } from '../../command';
|
|
6
|
+
import { BlockAutomaticHandler } from '../../services';
|
|
7
|
+
export declare class VeluxShutter extends VeluxDevice implements iShutter, iTemporaryDisableAutomatic {
|
|
7
8
|
/** @inheritDoc */
|
|
8
9
|
settings: ShutterSettings;
|
|
9
10
|
private readonly _setLevelSwitchID;
|
|
10
|
-
|
|
11
|
+
/** @inheritDoc */
|
|
12
|
+
firstCommandRecieved: boolean;
|
|
13
|
+
/** @inheritDoc */
|
|
14
|
+
targetAutomaticValue: number;
|
|
15
|
+
/** @inheritDoc */
|
|
16
|
+
baseAutomaticLevel: number;
|
|
11
17
|
private _setLevel;
|
|
12
18
|
private _setLevelTime;
|
|
13
19
|
private _currentLevel;
|
|
14
20
|
private _window?;
|
|
21
|
+
/** @inheritDoc */
|
|
22
|
+
blockAutomationHandler: BlockAutomaticHandler;
|
|
15
23
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
16
24
|
get currentLevel(): number;
|
|
17
25
|
get window(): iWindow | undefined;
|
|
@@ -21,5 +29,7 @@ export declare class VeluxShutter extends VeluxDevice implements iShutter {
|
|
|
21
29
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
22
30
|
persist(): void;
|
|
23
31
|
setLevel(command: ShutterSetLevelCommand): void;
|
|
32
|
+
writePositionStateToDevice(pPosition: number): void;
|
|
33
|
+
restoreTargetAutomaticValue(command: RestoreTargetAutomaticValueCommand): void;
|
|
24
34
|
private setCurrentLevel;
|
|
25
35
|
}
|
|
@@ -7,19 +7,27 @@ const enums_1 = require("../../enums");
|
|
|
7
7
|
const action_1 = require("../../action");
|
|
8
8
|
const command_1 = require("../../command");
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
|
+
const sharedFunctions_1 = require("../sharedFunctions");
|
|
11
|
+
const services_1 = require("../../services");
|
|
10
12
|
class VeluxShutter extends veluxDevice_1.VeluxDevice {
|
|
11
13
|
constructor(pInfo) {
|
|
12
14
|
var _a;
|
|
13
15
|
super(pInfo, enums_1.DeviceType.VeluxShutter);
|
|
14
16
|
/** @inheritDoc */
|
|
15
17
|
this.settings = new settingsObjects_1.ShutterSettings();
|
|
16
|
-
|
|
18
|
+
/** @inheritDoc */
|
|
19
|
+
this.firstCommandRecieved = false;
|
|
20
|
+
/** @inheritDoc */
|
|
21
|
+
this.targetAutomaticValue = 0;
|
|
22
|
+
/** @inheritDoc */
|
|
23
|
+
this.baseAutomaticLevel = 0;
|
|
17
24
|
this._setLevel = -1;
|
|
18
25
|
this._setLevelTime = -1;
|
|
19
26
|
this._currentLevel = -1;
|
|
20
27
|
this.jsonOmitKeys.push('_window');
|
|
21
28
|
this.deviceCapabilities.push(enums_1.DeviceCapability.shutter);
|
|
22
29
|
this._setLevelSwitchID = `${this.info.fullID}.targetPosition`;
|
|
30
|
+
this.blockAutomationHandler = new services_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
|
|
23
31
|
(_a = this.dbo) === null || _a === void 0 ? void 0 : _a.getLastDesiredPosition(this).then((val) => {
|
|
24
32
|
var _a;
|
|
25
33
|
if (val.desiredPosition === -1) {
|
|
@@ -61,44 +69,15 @@ class VeluxShutter extends veluxDevice_1.VeluxDevice {
|
|
|
61
69
|
(_a = this.dbo) === null || _a === void 0 ? void 0 : _a.persistShutter(this);
|
|
62
70
|
}
|
|
63
71
|
setLevel(command) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (this._firstCommandRecieved && command.isInitial) {
|
|
69
|
-
this.log(enums_1.LogLevel.Debug, `Skipped initial Rollo to ${targetLevel} as we recieved a command already`);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (this.currentLevel === targetLevel && !command.isForceAction) {
|
|
73
|
-
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);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (this._setLevelSwitchID === '') {
|
|
77
|
-
this.log(enums_1.LogLevel.Error, 'Keine Switch ID bekannt.');
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (!this.checkIoConnection(true)) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
this.logCommand(command);
|
|
84
|
-
if (this._window !== undefined) {
|
|
85
|
-
if (this._window.griffeInPosition(enums_1.WindowPosition.open) > 0 && command.level < 100) {
|
|
86
|
-
if (!command.skipOpenWarning) {
|
|
87
|
-
this.log(enums_1.LogLevel.Alert, 'Not closing the shutter, as the window is open!');
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (this._window.griffeInPosition(enums_1.WindowPosition.tilted) > 0 && targetLevel < 50) {
|
|
92
|
-
targetLevel = 50;
|
|
93
|
-
if (!command.skipOpenWarning) {
|
|
94
|
-
this.log(enums_1.LogLevel.Alert, 'Not closing the shutter, as the window is half open!');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
this._setLevel = targetLevel;
|
|
99
|
-
this.log(enums_1.LogLevel.Debug, `Fahre Rollo auf Position ${targetLevel}`);
|
|
72
|
+
sharedFunctions_1.ShutterUtils.setLevel(this, command);
|
|
73
|
+
}
|
|
74
|
+
writePositionStateToDevice(pPosition) {
|
|
75
|
+
this._setLevel = pPosition;
|
|
100
76
|
// Level is inverted for Velux Adapter (100 = 0, 0 = 100, 25 = 75, etc.)
|
|
101
|
-
this.setState(this._setLevelSwitchID, Math.abs(
|
|
77
|
+
this.setState(this._setLevelSwitchID, Math.abs(pPosition - 100));
|
|
78
|
+
}
|
|
79
|
+
restoreTargetAutomaticValue(command) {
|
|
80
|
+
this.setLevel(new command_1.ShutterSetLevelCommand(command, this.targetAutomaticValue));
|
|
102
81
|
}
|
|
103
82
|
setCurrentLevel(value, initial = false) {
|
|
104
83
|
let correctedValue = Math.abs(value - 100);
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { ZigbeeDevice } from './zigbeeDevice';
|
|
2
2
|
import { iShutter, iWindow } from '../../../interfaces';
|
|
3
3
|
import { ShutterSettings } from '../../../settingsObjects';
|
|
4
|
-
import { ShutterSetLevelCommand } from '../../../command';
|
|
4
|
+
import { RestoreTargetAutomaticValueCommand, ShutterSetLevelCommand } from '../../../command';
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
6
6
|
import { DeviceType } from '../../../enums';
|
|
7
7
|
import { ShutterCalibration } from '../../../models';
|
|
8
|
+
import { BlockAutomaticHandler } from '../../../services';
|
|
8
9
|
export declare class ZigbeeShutter extends ZigbeeDevice implements iShutter {
|
|
9
10
|
/** @inheritDoc */
|
|
10
11
|
settings: ShutterSettings;
|
|
11
12
|
protected _iMovementFinishTimeout: NodeJS.Timeout | null;
|
|
12
|
-
|
|
13
|
+
/** @inheritDoc */
|
|
14
|
+
firstCommandRecieved: boolean;
|
|
13
15
|
protected _setLevel: number;
|
|
14
16
|
protected _setLevelTime: number;
|
|
15
17
|
protected _shutterCalibrationData: ShutterCalibration;
|
|
16
18
|
protected _currentLevel: number;
|
|
17
19
|
protected _window?: iWindow;
|
|
20
|
+
/** Implements iTemporaryDisableAutomatic */
|
|
21
|
+
readonly blockAutomationHandler: BlockAutomaticHandler;
|
|
22
|
+
/** @inheritDoc */
|
|
23
|
+
targetAutomaticValue: number;
|
|
24
|
+
/** @inheritDoc */
|
|
25
|
+
baseAutomaticLevel: number;
|
|
18
26
|
constructor(pInfo: IoBrokerDeviceInfo, pType: DeviceType);
|
|
19
27
|
/** @inheritDoc */
|
|
20
28
|
get currentLevel(): number;
|
|
@@ -31,10 +39,15 @@ export declare class ZigbeeShutter extends ZigbeeDevice implements iShutter {
|
|
|
31
39
|
/** @inheritDoc */
|
|
32
40
|
setLevel(c: ShutterSetLevelCommand): void;
|
|
33
41
|
protected setCurrentLevel(value: number, isInitial?: boolean): void;
|
|
34
|
-
|
|
42
|
+
writePositionStateToDevice(pPosition: number): void;
|
|
35
43
|
protected getAverageUp(): number;
|
|
36
44
|
protected getAverageDown(): number;
|
|
37
45
|
protected isCalibrated(): boolean;
|
|
38
46
|
protected persistCalibrationData(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Restores the automatic value/state of the device
|
|
49
|
+
* @param command - The command to restore the automatic value/state
|
|
50
|
+
*/
|
|
51
|
+
restoreTargetAutomaticValue(command: RestoreTargetAutomaticValueCommand): void;
|
|
39
52
|
protected initializeMovementFinishTimeout(duration: number, endPosition: number): void;
|
|
40
53
|
}
|