hoffmation-base 3.0.0-alpha.82 → 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.
|
@@ -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) => {
|