hoffmation-base 3.0.0-alpha.81 → 3.0.0-alpha.83
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.
|
@@ -100,23 +100,25 @@ class VeluxShutter extends veluxDevice_1.VeluxDevice {
|
|
|
100
100
|
}
|
|
101
101
|
this._setLevel = targetLevel;
|
|
102
102
|
this.log(models_2.LogLevel.Debug, `Fahre Rollo auf Position ${targetLevel}`);
|
|
103
|
-
|
|
103
|
+
// Level is inverted for Velux Adapter (100 = 0, 0 = 100, 25 = 75, etc.)
|
|
104
|
+
this.setState(this._setLevelSwitchID, Math.abs(targetLevel - 100));
|
|
104
105
|
}
|
|
105
106
|
toJSON() {
|
|
106
107
|
return lodash_1.default.omit(super.toJSON(), ['_window']);
|
|
107
108
|
}
|
|
108
109
|
setCurrentLevel(value, initial = false) {
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
let correctedValue = Math.abs(value - 100);
|
|
111
|
+
if (correctedValue !== this._setLevel && services_1.Utils.nowMS() - this._setLevelTime < 60 * 10000) {
|
|
112
|
+
correctedValue = this._setLevel;
|
|
111
113
|
}
|
|
112
|
-
if (
|
|
114
|
+
if (correctedValue !== this._currentLevel && this._window && !initial) {
|
|
113
115
|
services_1.Utils.guardedNewThread(() => {
|
|
114
116
|
var _a;
|
|
115
|
-
(_a = this._window) === null || _a === void 0 ? void 0 : _a.rolloPositionChange(new models_2.ShutterPositionChangedAction(this,
|
|
117
|
+
(_a = this._window) === null || _a === void 0 ? void 0 : _a.rolloPositionChange(new models_2.ShutterPositionChangedAction(this, correctedValue));
|
|
116
118
|
}, this);
|
|
117
119
|
this.persist();
|
|
118
120
|
}
|
|
119
|
-
this._currentLevel =
|
|
121
|
+
this._currentLevel = correctedValue;
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
exports.VeluxShutter = VeluxShutter;
|
|
@@ -29,6 +29,7 @@ export declare class OwnGoveeDevice implements iLedRgbCct, iTemporaryDisableAuto
|
|
|
29
29
|
private _color;
|
|
30
30
|
private _colortemp;
|
|
31
31
|
private _room;
|
|
32
|
+
protected _lastPersist: number;
|
|
32
33
|
constructor(deviceId: string, ownDeviceName: string, roomName: string);
|
|
33
34
|
get color(): string;
|
|
34
35
|
get colortemp(): number;
|
|
@@ -36,6 +36,7 @@ class OwnGoveeDevice {
|
|
|
36
36
|
this._color = '#fcba32';
|
|
37
37
|
this._colortemp = 500;
|
|
38
38
|
this._room = undefined;
|
|
39
|
+
this._lastPersist = 0;
|
|
39
40
|
this.deviceId = deviceId;
|
|
40
41
|
this._info = new devices_1.DeviceInfo();
|
|
41
42
|
this._info.fullName = `Govee ${roomName} ${ownDeviceName}`;
|
|
@@ -147,7 +148,12 @@ class OwnGoveeDevice {
|
|
|
147
148
|
}
|
|
148
149
|
persist() {
|
|
149
150
|
var _a;
|
|
151
|
+
const now = utils_1.Utils.nowMS();
|
|
152
|
+
if (this._lastPersist + 1000 > now) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
150
155
|
(_a = utils_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistActuator(this);
|
|
156
|
+
this._lastPersist = now;
|
|
151
157
|
}
|
|
152
158
|
toggleActuator(c) {
|
|
153
159
|
const setActuatorCommand = models_1.ActuatorSetStateCommand.byActuatorAndToggleCommand(this, c);
|
|
@@ -168,10 +174,18 @@ class OwnGoveeDevice {
|
|
|
168
174
|
}
|
|
169
175
|
update(data) {
|
|
170
176
|
this.queuedValue = null;
|
|
177
|
+
const anyChanged = this._actuatorOn !== data.actuatorOn ||
|
|
178
|
+
this.brightness !== data.brightness ||
|
|
179
|
+
this._color !== data.hexColor ||
|
|
180
|
+
this._colortemp !== data.colortemp;
|
|
181
|
+
if (!anyChanged) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
171
184
|
this._actuatorOn = data.actuatorOn;
|
|
172
185
|
this.brightness = data.brightness;
|
|
173
186
|
this._color = data.hexColor;
|
|
174
187
|
this._colortemp = data.colortemp;
|
|
188
|
+
this.persist();
|
|
175
189
|
}
|
|
176
190
|
setBrightness(brightness, cb) {
|
|
177
191
|
govee_service_1.GooveeService.sendCommand(this, `brightness/${brightness}`).then((result) => {
|