@marcel2215/homebridge-supla-plugin 2.1.8 → 2.1.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/config.schema.json +88 -0
- package/dist/Accesories/ActionTriggerAccessory.d.ts.map +1 -1
- package/dist/Accesories/ActionTriggerAccessory.js +6 -11
- package/dist/Accesories/ActionTriggerAccessory.js.map +1 -1
- package/dist/Accesories/AirQualityAccessory.d.ts.map +1 -1
- package/dist/Accesories/AirQualityAccessory.js +10 -14
- package/dist/Accesories/AirQualityAccessory.js.map +1 -1
- package/dist/Accesories/ContactSensorAccessory.d.ts.map +1 -1
- package/dist/Accesories/ContactSensorAccessory.js +11 -15
- package/dist/Accesories/ContactSensorAccessory.js.map +1 -1
- package/dist/Accesories/DimmerAccessory.d.ts +2 -0
- package/dist/Accesories/DimmerAccessory.d.ts.map +1 -1
- package/dist/Accesories/DimmerAccessory.js +30 -26
- package/dist/Accesories/DimmerAccessory.js.map +1 -1
- package/dist/Accesories/DimmerRgbLightAccessory.d.ts.map +1 -1
- package/dist/Accesories/DimmerRgbLightAccessory.js +33 -43
- package/dist/Accesories/DimmerRgbLightAccessory.js.map +1 -1
- package/dist/Accesories/DoorAccessory.d.ts.map +1 -1
- package/dist/Accesories/DoorAccessory.js +13 -18
- package/dist/Accesories/DoorAccessory.js.map +1 -1
- package/dist/Accesories/ElectricityMeterAccessory.js +16 -24
- package/dist/Accesories/ElectricityMeterAccessory.js.map +1 -1
- package/dist/Accesories/FacadeBlindAccessory.d.ts +15 -0
- package/dist/Accesories/FacadeBlindAccessory.d.ts.map +1 -1
- package/dist/Accesories/FacadeBlindAccessory.js +235 -57
- package/dist/Accesories/FacadeBlindAccessory.js.map +1 -1
- package/dist/Accesories/GarageDoorOpenerAccesory.d.ts +2 -0
- package/dist/Accesories/GarageDoorOpenerAccesory.d.ts.map +1 -1
- package/dist/Accesories/GarageDoorOpenerAccesory.js +23 -16
- package/dist/Accesories/GarageDoorOpenerAccesory.js.map +1 -1
- package/dist/Accesories/GateAccessory.d.ts +21 -0
- package/dist/Accesories/GateAccessory.d.ts.map +1 -0
- package/dist/Accesories/GateAccessory.js +98 -0
- package/dist/Accesories/GateAccessory.js.map +1 -0
- package/dist/Accesories/GateLockAccessory.d.ts +19 -0
- package/dist/Accesories/GateLockAccessory.d.ts.map +1 -0
- package/dist/Accesories/GateLockAccessory.js +101 -0
- package/dist/Accesories/GateLockAccessory.js.map +1 -0
- package/dist/Accesories/LeakSensorAccessory.d.ts.map +1 -1
- package/dist/Accesories/LeakSensorAccessory.js +11 -15
- package/dist/Accesories/LeakSensorAccessory.js.map +1 -1
- package/dist/Accesories/LightBulbAccesory.d.ts +2 -0
- package/dist/Accesories/LightBulbAccesory.d.ts.map +1 -1
- package/dist/Accesories/LightBulbAccesory.js +24 -19
- package/dist/Accesories/LightBulbAccesory.js.map +1 -1
- package/dist/Accesories/PressureAccessory.d.ts.map +1 -1
- package/dist/Accesories/PressureAccessory.js +10 -14
- package/dist/Accesories/PressureAccessory.js.map +1 -1
- package/dist/Accesories/RGBLightBulbAccesory.d.ts.map +1 -1
- package/dist/Accesories/RGBLightBulbAccesory.js +21 -29
- package/dist/Accesories/RGBLightBulbAccesory.js.map +1 -1
- package/dist/Accesories/RollerShutterAccessory.d.ts +10 -0
- package/dist/Accesories/RollerShutterAccessory.d.ts.map +1 -1
- package/dist/Accesories/RollerShutterAccessory.js +203 -50
- package/dist/Accesories/RollerShutterAccessory.js.map +1 -1
- package/dist/Accesories/SwitchAccessory.d.ts +2 -0
- package/dist/Accesories/SwitchAccessory.d.ts.map +1 -1
- package/dist/Accesories/SwitchAccessory.js +23 -18
- package/dist/Accesories/SwitchAccessory.js.map +1 -1
- package/dist/Accesories/TemperatureAccessory.d.ts.map +1 -1
- package/dist/Accesories/TemperatureAccessory.js +10 -14
- package/dist/Accesories/TemperatureAccessory.js.map +1 -1
- package/dist/Accesories/TemperatureHumidityAccessory.d.ts.map +1 -1
- package/dist/Accesories/TemperatureHumidityAccessory.js +18 -23
- package/dist/Accesories/TemperatureHumidityAccessory.js.map +1 -1
- package/dist/Accesories/ThermostatAccessory.d.ts.map +1 -1
- package/dist/Accesories/ThermostatAccessory.js +40 -48
- package/dist/Accesories/ThermostatAccessory.js.map +1 -1
- package/dist/Accesories/ValveAccessory.d.ts.map +1 -1
- package/dist/Accesories/ValveAccessory.js +20 -25
- package/dist/Accesories/ValveAccessory.js.map +1 -1
- package/dist/Accesories/WicketAccesory.d.ts.map +1 -1
- package/dist/Accesories/WicketAccesory.js +5 -8
- package/dist/Accesories/WicketAccesory.js.map +1 -1
- package/dist/Heplers/SuplaMqttClient.d.ts +7 -1
- package/dist/Heplers/SuplaMqttClient.d.ts.map +1 -1
- package/dist/Heplers/SuplaMqttClient.js +148 -49
- package/dist/Heplers/SuplaMqttClient.js.map +1 -1
- package/dist/Heplers/SuplaMqttClientContext.d.ts +4 -1
- package/dist/Heplers/SuplaMqttClientContext.d.ts.map +1 -1
- package/dist/Heplers/SuplaMqttClientContext.js +4 -1
- package/dist/Heplers/SuplaMqttClientContext.js.map +1 -1
- package/dist/platform.d.ts +58 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +523 -10
- package/dist/platform.js.map +1 -1
- package/package.json +1 -1
|
@@ -29,23 +29,18 @@ class DoorAccessory {
|
|
|
29
29
|
.onSet(this.handleTargetPositionSet.bind(this));
|
|
30
30
|
this.service.getCharacteristic(this.platform.Characteristic.PositionState)
|
|
31
31
|
.onGet(this.handlePositionStateGet.bind(this));
|
|
32
|
-
this.platform.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (topic === `${this.context.topic}/state/connected`) {
|
|
45
|
-
this.connected = message.toString() === 'true';
|
|
46
|
-
this.service.updateCharacteristic(this.platform.Characteristic.StatusFault, this.connected ? 0 : 1);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
32
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/hi`, (message) => {
|
|
33
|
+
this.hi = this.platform.parseBoolean(message.toString());
|
|
34
|
+
this.updatePositionsFromState();
|
|
35
|
+
}, this.accessory.UUID);
|
|
36
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/partial_hi`, (message) => {
|
|
37
|
+
this.partialHi = this.platform.parseBoolean(message.toString());
|
|
38
|
+
this.updatePositionsFromState();
|
|
39
|
+
}, this.accessory.UUID);
|
|
40
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/connected`, (message) => {
|
|
41
|
+
this.connected = this.platform.parseBoolean(message.toString());
|
|
42
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusFault, this.connected ? 0 : 1);
|
|
43
|
+
}, this.accessory.UUID);
|
|
49
44
|
}
|
|
50
45
|
async handleCurrentPositionGet() {
|
|
51
46
|
return this.currentPosition;
|
|
@@ -69,7 +64,7 @@ class DoorAccessory {
|
|
|
69
64
|
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, this.positionState);
|
|
70
65
|
const action = this.targetPosition <= 10 ? 'close' : 'open';
|
|
71
66
|
this.platform.log.debug(`Publishing ${this.context.topic}/execute_action = ${action}`);
|
|
72
|
-
this.platform.
|
|
67
|
+
this.platform.publishCommand(`${this.context.topic}/execute_action`, action);
|
|
73
68
|
}
|
|
74
69
|
async handlePositionStateGet() {
|
|
75
70
|
return this.positionState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DoorAccessory.js","sourceRoot":"","sources":["../../src/Accesories/DoorAccessory.ts"],"names":[],"mappings":";;;AAIA,MAAa,aAAa;IASxB,YACmB,QAAuB,EACvB,SAA4B,EAC5B,OAA4B;QAF5B,aAAQ,GAAR,QAAQ,CAAe;QACvB,cAAS,GAAT,SAAS,CAAmB;QAC5B,YAAO,GAAP,OAAO,CAAqB;QAVvC,oBAAe,GAAG,C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AI,CAAC,eAAe,GAAG,CAAC,CAAC;SAC1B;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE;YACzB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;SAC3B;aAAM;YACL,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;SAC5B;QACD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC;QACxE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACtG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACpG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACpG,CAAC;IAEO,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;QACnD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;CACF;AApHD,sCAoHC"}
|
|
@@ -28,30 +28,22 @@ class ElectricityMeterAccessory {
|
|
|
28
28
|
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
29
29
|
this.service.getCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel)
|
|
30
30
|
.onGet(this.handleValueGet.bind(this));
|
|
31
|
-
this.platform.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (Number.isNaN(value)) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (metricIndex <= this.selectedMetricIndex) {
|
|
51
|
-
this.selectedMetricIndex = metricIndex;
|
|
52
|
-
this.value = this.clamp(value, 0.0001, 100000);
|
|
53
|
-
this.service.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.value);
|
|
54
|
-
}
|
|
31
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/connected`, (message) => {
|
|
32
|
+
this.connected = this.platform.parseBoolean(message.toString());
|
|
33
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusFault, this.connected ? 0 : 1);
|
|
34
|
+
}, this.accessory.UUID);
|
|
35
|
+
this.metricPriority.forEach((key, metricIndex) => {
|
|
36
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/${key}`, (message) => {
|
|
37
|
+
const value = parseFloat(message.toString());
|
|
38
|
+
if (Number.isNaN(value)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (metricIndex <= this.selectedMetricIndex) {
|
|
42
|
+
this.selectedMetricIndex = metricIndex;
|
|
43
|
+
this.value = this.clamp(value, 0.0001, 100000);
|
|
44
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.value);
|
|
45
|
+
}
|
|
46
|
+
}, this.accessory.UUID);
|
|
55
47
|
});
|
|
56
48
|
}
|
|
57
49
|
async handleValueGet() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElectricityMeterAccessory.js","sourceRoot":"","sources":["../../src/Accesories/ElectricityMeterAccessory.ts"],"names":[],"mappings":";;;AAIA,MAAa,yBAAyB;IAiBpC,YACmB,QAAuB,EACvB,SAA4B,EAC5B,OAA4B;QAF5B,aAAQ,GAAR,QAAQ,CAAe;QACvB,cAAS,GAAT,SAAS,CAAmB;QAC5B,YA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EO,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;QACnD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;CACF;AA1ED,8DA0EC"}
|
|
@@ -14,19 +14,34 @@ export declare class FacadeBlindAccessory {
|
|
|
14
14
|
private connected;
|
|
15
15
|
private stopTimer?;
|
|
16
16
|
private hasReceivedPosition;
|
|
17
|
+
private hasReceivedTilt;
|
|
17
18
|
private pendingTargetPosition?;
|
|
18
19
|
private pendingTargetExpiresAt;
|
|
19
20
|
private pendingTargetTimer?;
|
|
21
|
+
private motionStopTimer?;
|
|
22
|
+
private lastRawPosition?;
|
|
23
|
+
private jammed;
|
|
24
|
+
private lastTiltCommandAt;
|
|
20
25
|
constructor(platform: SuplaPlatform, accessory: PlatformAccessory, context: SuplaChannelContext);
|
|
21
26
|
handleCurrentPositionGet(): Promise<CharacteristicValue>;
|
|
22
27
|
handleTargetPositionGet(): Promise<CharacteristicValue>;
|
|
23
28
|
handleTargetPositionSet(value: CharacteristicValue): Promise<void>;
|
|
29
|
+
handleHoldPositionSet(value: CharacteristicValue): Promise<void>;
|
|
30
|
+
private applyShutUpdate;
|
|
24
31
|
private schedulePendingTimeout;
|
|
25
32
|
private clearPendingTarget;
|
|
33
|
+
private clearStopTimer;
|
|
34
|
+
private scheduleMotionStopTimer;
|
|
35
|
+
private clearMotionStopTimer;
|
|
36
|
+
private disposeTimers;
|
|
37
|
+
private setJammed;
|
|
38
|
+
private updateConnection;
|
|
26
39
|
handlePositionStateGet(): Promise<CharacteristicValue>;
|
|
27
40
|
handleCurrentTiltGet(): Promise<CharacteristicValue>;
|
|
28
41
|
handleTargetTiltGet(): Promise<CharacteristicValue>;
|
|
29
42
|
handleTargetTiltSet(value: CharacteristicValue): Promise<void>;
|
|
43
|
+
private assertPositionAvailable;
|
|
44
|
+
private assertTiltAvailable;
|
|
30
45
|
private toPosition;
|
|
31
46
|
private toShut;
|
|
32
47
|
private toTiltAngle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FacadeBlindAccessory.d.ts","sourceRoot":"","sources":["../../src/Accesories/FacadeBlindAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,qBAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"FacadeBlindAccessory.d.ts","sourceRoot":"","sources":["../../src/Accesories/FacadeBlindAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,qBAAa,oBAAoB;IAoB7B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IArB1B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,aAAa,CAAsD;IAC3E,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,SAAS,CAAC,CAAiB;IACnC,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,qBAAqB,CAAC,CAAS;IACvC,OAAO,CAAC,sBAAsB,CAAK;IACnC,OAAO,CAAC,kBAAkB,CAAC,CAAiB;IAC5C,OAAO,CAAC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argetExpiresAt = 0;
|
|
18
|
+
this.jammed = false;
|
|
19
|
+
this.lastTiltCommandAt = 0;
|
|
17
20
|
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
18
21
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Supla')
|
|
19
22
|
.setCharacteristic(this.platform.Characteristic.Model, 'FacadeBlind');
|
|
@@ -23,6 +26,7 @@ class FacadeBlindAccessory {
|
|
|
23
26
|
this.service.getCharacteristic(this.platform.Characteristic.CurrentPosition)
|
|
24
27
|
.onGet(this.handleCurrentPositionGet.bind(this));
|
|
25
28
|
this.service.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
29
|
+
.setProps({ minValue: 0, maxValue: 100, minStep: 1 })
|
|
26
30
|
.onGet(this.handleTargetPositionGet.bind(this))
|
|
27
31
|
.onSet(this.handleTargetPositionSet.bind(this));
|
|
28
32
|
this.service.getCharacteristic(this.platform.Characteristic.PositionState)
|
|
@@ -30,68 +34,59 @@ class FacadeBlindAccessory {
|
|
|
30
34
|
this.service.getCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle)
|
|
31
35
|
.onGet(this.handleCurrentTiltGet.bind(this));
|
|
32
36
|
this.service.getCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle)
|
|
37
|
+
.setProps({ minValue: -90, maxValue: 90, minStep: 1 })
|
|
33
38
|
.onGet(this.handleTargetTiltGet.bind(this))
|
|
34
39
|
.onSet(this.handleTargetTiltSet.bind(this));
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
this.platform.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!this.hasReceivedPosition) {
|
|
46
|
-
this.hasReceivedPosition = true;
|
|
47
|
-
this.clearPendingTarget(false);
|
|
48
|
-
this.targetPosition = this.currentPosition;
|
|
49
|
-
}
|
|
50
|
-
else if (this.pendingTargetPosition !== undefined) {
|
|
51
|
-
const reached = Math.abs(this.pendingTargetPosition - this.currentPosition) <= 1;
|
|
52
|
-
const expired = this.pendingTargetExpiresAt > 0 && now > this.pendingTargetExpiresAt;
|
|
53
|
-
if (reached || expired) {
|
|
54
|
-
this.clearPendingTarget(false);
|
|
55
|
-
this.targetPosition = this.currentPosition;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
this.schedulePendingTimeout(this.pendingTargetPosition, this.currentPosition);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.targetPosition = this.currentPosition;
|
|
63
|
-
}
|
|
64
|
-
this.service.updateCharacteristic(this.platform.Characteristic.CurrentPosition, this.currentPosition);
|
|
65
|
-
this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.targetPosition);
|
|
66
|
-
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, this.positionState);
|
|
67
|
-
}
|
|
40
|
+
this.service.getCharacteristic(this.platform.Characteristic.HoldPosition)
|
|
41
|
+
.onSet(this.handleHoldPositionSet.bind(this));
|
|
42
|
+
this.service.setCharacteristic(this.platform.Characteristic.StatusJammed, 0);
|
|
43
|
+
this.platform.registerOwnerCleanup(this.accessory.UUID, () => {
|
|
44
|
+
this.disposeTimers();
|
|
45
|
+
});
|
|
46
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/shut`, (message) => {
|
|
47
|
+
const value = parseFloat(message.toString());
|
|
48
|
+
if (!Number.isNaN(value)) {
|
|
49
|
+
this.applyShutUpdate(value);
|
|
68
50
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
}, this.accessory.UUID);
|
|
52
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/tilt`, (message) => {
|
|
53
|
+
const value = parseFloat(message.toString());
|
|
54
|
+
if (!Number.isNaN(value)) {
|
|
55
|
+
const previousTilt = this.currentTiltAngle;
|
|
56
|
+
const previousTarget = this.targetTiltAngle;
|
|
57
|
+
this.currentTiltAngle = Math.round(this.toTiltAngle(value));
|
|
58
|
+
this.hasReceivedTilt = true;
|
|
59
|
+
const now = Date.now();
|
|
60
|
+
const targetDelta = Math.abs(this.targetTiltAngle - this.currentTiltAngle);
|
|
61
|
+
const commandStale = this.lastTiltCommandAt === 0 || (now - this.lastTiltCommandAt) > 3000;
|
|
62
|
+
if (targetDelta <= 2 || commandStale) {
|
|
63
|
+
this.targetTiltAngle = this.currentTiltAngle;
|
|
64
|
+
}
|
|
65
|
+
if (this.currentTiltAngle !== previousTilt) {
|
|
76
66
|
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle, this.currentTiltAngle);
|
|
67
|
+
}
|
|
68
|
+
if (this.targetTiltAngle !== previousTarget) {
|
|
77
69
|
this.service.updateCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle, this.targetTiltAngle);
|
|
78
70
|
}
|
|
79
71
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
72
|
+
}, this.accessory.UUID);
|
|
73
|
+
this.platform.registerMqttHandler(`${this.context.topic}/state/connected`, (message) => {
|
|
74
|
+
this.updateConnection(this.platform.parseBoolean(message.toString()));
|
|
75
|
+
}, this.accessory.UUID);
|
|
85
76
|
}
|
|
86
77
|
async handleCurrentPositionGet() {
|
|
78
|
+
this.assertPositionAvailable();
|
|
87
79
|
return this.currentPosition;
|
|
88
80
|
}
|
|
89
81
|
async handleTargetPositionGet() {
|
|
82
|
+
this.assertPositionAvailable();
|
|
90
83
|
return this.targetPosition;
|
|
91
84
|
}
|
|
92
85
|
async handleTargetPositionSet(value) {
|
|
93
86
|
const target = value;
|
|
94
|
-
this.
|
|
87
|
+
this.setJammed(false);
|
|
88
|
+
this.clearMotionStopTimer();
|
|
89
|
+
this.targetPosition = Math.round(this.clamp(target, 0, 100));
|
|
95
90
|
if (this.targetPosition > this.currentPosition) {
|
|
96
91
|
this.positionState = this.platform.Characteristic.PositionState.INCREASING;
|
|
97
92
|
}
|
|
@@ -103,6 +98,11 @@ class FacadeBlindAccessory {
|
|
|
103
98
|
}
|
|
104
99
|
this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.targetPosition);
|
|
105
100
|
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, this.positionState);
|
|
101
|
+
if (this.hasReceivedPosition && this.targetPosition === this.currentPosition) {
|
|
102
|
+
this.clearPendingTarget(false);
|
|
103
|
+
this.clearStopTimer();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
106
|
if (this.targetPosition !== this.currentPosition) {
|
|
107
107
|
this.pendingTargetPosition = this.targetPosition;
|
|
108
108
|
this.schedulePendingTimeout(this.targetPosition, this.currentPosition);
|
|
@@ -111,11 +111,13 @@ class FacadeBlindAccessory {
|
|
|
111
111
|
this.clearPendingTarget(false);
|
|
112
112
|
}
|
|
113
113
|
const controlMode = this.platform.getCoveringControlMode();
|
|
114
|
-
const shutValue = this.toShut(this.targetPosition).toString();
|
|
115
|
-
|
|
114
|
+
const shutValue = Math.round(this.toShut(this.targetPosition)).toString();
|
|
115
|
+
const isEndpoint = this.targetPosition === 0 || this.targetPosition === 100;
|
|
116
|
+
if ((controlMode === 'set' || controlMode === 'hybrid')
|
|
117
|
+
&& !(controlMode === 'hybrid' && isEndpoint)) {
|
|
116
118
|
const topic = `${this.context.topic}/${this.platform.getCoveringSetTopicSuffix()}`;
|
|
117
119
|
this.platform.log.debug(`Publishing ${topic} = ${shutValue}`);
|
|
118
|
-
this.platform.
|
|
120
|
+
this.platform.publishCommand(topic, shutValue, (error) => {
|
|
119
121
|
if (error) {
|
|
120
122
|
this.platform.log.error(`Publish failed for ${topic}: ${error.message}`);
|
|
121
123
|
}
|
|
@@ -129,7 +131,7 @@ class FacadeBlindAccessory {
|
|
|
129
131
|
const action = this.resolveAction(this.targetPosition, this.currentPosition);
|
|
130
132
|
if (action) {
|
|
131
133
|
this.platform.log.debug(`Publishing ${actionTopic} = ${action}`);
|
|
132
|
-
this.platform.
|
|
134
|
+
this.platform.publishCommand(actionTopic, action, (error) => {
|
|
133
135
|
if (error) {
|
|
134
136
|
this.platform.log.error(`Publish failed for ${actionTopic}: ${error.message}`);
|
|
135
137
|
}
|
|
@@ -140,12 +142,115 @@ class FacadeBlindAccessory {
|
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
144
|
}
|
|
145
|
+
async handleHoldPositionSet(value) {
|
|
146
|
+
if (!value) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const controlMode = this.platform.getCoveringControlMode();
|
|
150
|
+
if (controlMode === 'set') {
|
|
151
|
+
this.platform.log.debug(`HoldPosition ignored (set mode) for ${this.accessory.displayName}`);
|
|
152
|
+
this.service.updateCharacteristic(this.platform.Characteristic.HoldPosition, 0);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const stopAction = this.platform.getCoveringExecuteActionStop();
|
|
156
|
+
if (!stopAction) {
|
|
157
|
+
this.platform.log.debug(`HoldPosition ignored (no stop action) for ${this.accessory.displayName}`);
|
|
158
|
+
this.service.updateCharacteristic(this.platform.Characteristic.HoldPosition, 0);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const actionTopic = `${this.context.topic}/execute_action`;
|
|
162
|
+
this.platform.log.debug(`Publishing ${actionTopic} = ${stopAction} (hold)`);
|
|
163
|
+
this.platform.publishCommand(actionTopic, stopAction, (error) => {
|
|
164
|
+
if (error) {
|
|
165
|
+
this.platform.log.error(`Publish failed for ${actionTopic}: ${error.message}`);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
this.service.updateCharacteristic(this.platform.Characteristic.HoldPosition, 0);
|
|
169
|
+
this.clearPendingTarget(true);
|
|
170
|
+
this.clearStopTimer();
|
|
171
|
+
this.clearMotionStopTimer();
|
|
172
|
+
this.setJammed(false);
|
|
173
|
+
if (this.positionState !== this.platform.Characteristic.PositionState.STOPPED) {
|
|
174
|
+
this.positionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
175
|
+
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, this.positionState);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
applyShutUpdate(shutValue) {
|
|
179
|
+
var _a;
|
|
180
|
+
const previousTarget = this.targetPosition;
|
|
181
|
+
const previousState = this.positionState;
|
|
182
|
+
const rawPosition = this.toPosition(shutValue);
|
|
183
|
+
const previousRaw = (_a = this.lastRawPosition) !== null && _a !== void 0 ? _a : rawPosition;
|
|
184
|
+
const rawDelta = rawPosition - previousRaw;
|
|
185
|
+
const rawMovement = Math.abs(rawDelta) >= 0.05;
|
|
186
|
+
this.lastRawPosition = rawPosition;
|
|
187
|
+
const previousPosition = this.currentPosition;
|
|
188
|
+
this.currentPosition = Math.round(rawPosition);
|
|
189
|
+
let nextPositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
190
|
+
const now = Date.now();
|
|
191
|
+
const firstUpdate = !this.hasReceivedPosition;
|
|
192
|
+
if (firstUpdate) {
|
|
193
|
+
this.hasReceivedPosition = true;
|
|
194
|
+
}
|
|
195
|
+
if (rawMovement || this.currentPosition !== previousPosition) {
|
|
196
|
+
this.setJammed(false);
|
|
197
|
+
}
|
|
198
|
+
if (this.pendingTargetPosition !== undefined) {
|
|
199
|
+
this.clearMotionStopTimer();
|
|
200
|
+
const reached = Math.abs(this.pendingTargetPosition - this.currentPosition) <= 1;
|
|
201
|
+
const expired = this.pendingTargetExpiresAt > 0 && now > this.pendingTargetExpiresAt;
|
|
202
|
+
if (reached || expired) {
|
|
203
|
+
this.clearStopTimer();
|
|
204
|
+
this.clearPendingTarget(false);
|
|
205
|
+
this.targetPosition = this.currentPosition;
|
|
206
|
+
if (expired) {
|
|
207
|
+
this.setJammed(true);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
if (rawMovement || firstUpdate) {
|
|
212
|
+
this.schedulePendingTimeout(this.pendingTargetPosition, this.currentPosition);
|
|
213
|
+
}
|
|
214
|
+
if (this.pendingTargetPosition > this.currentPosition) {
|
|
215
|
+
nextPositionState = this.platform.Characteristic.PositionState.INCREASING;
|
|
216
|
+
}
|
|
217
|
+
else if (this.pendingTargetPosition < this.currentPosition) {
|
|
218
|
+
nextPositionState = this.platform.Characteristic.PositionState.DECREASING;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
this.clearPendingTarget(false);
|
|
224
|
+
this.clearStopTimer();
|
|
225
|
+
this.targetPosition = this.currentPosition;
|
|
226
|
+
if (rawMovement) {
|
|
227
|
+
nextPositionState = rawDelta > 0
|
|
228
|
+
? this.platform.Characteristic.PositionState.INCREASING
|
|
229
|
+
: this.platform.Characteristic.PositionState.DECREASING;
|
|
230
|
+
this.scheduleMotionStopTimer();
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
this.clearMotionStopTimer();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
this.positionState = nextPositionState;
|
|
237
|
+
if (this.currentPosition !== previousPosition) {
|
|
238
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentPosition, this.currentPosition);
|
|
239
|
+
}
|
|
240
|
+
if (this.targetPosition !== previousTarget) {
|
|
241
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.targetPosition);
|
|
242
|
+
}
|
|
243
|
+
if (this.positionState !== previousState) {
|
|
244
|
+
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, this.positionState);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
143
247
|
schedulePendingTimeout(target, current) {
|
|
144
248
|
const travelTimeSeconds = this.platform.getCoveringTravelTimeSeconds();
|
|
145
249
|
const delta = Math.abs(target - current);
|
|
146
250
|
let timeoutMs = 15000;
|
|
147
251
|
if (travelTimeSeconds > 0 && delta > 0) {
|
|
148
|
-
|
|
252
|
+
const computed = Math.round((delta / 100) * travelTimeSeconds * 1000) + 1000;
|
|
253
|
+
timeoutMs = Math.max(5000, computed);
|
|
149
254
|
}
|
|
150
255
|
if (timeoutMs <= 0) {
|
|
151
256
|
return;
|
|
@@ -156,12 +261,13 @@ class FacadeBlindAccessory {
|
|
|
156
261
|
}
|
|
157
262
|
this.pendingTargetTimer = setTimeout(() => {
|
|
158
263
|
this.pendingTargetTimer = undefined;
|
|
159
|
-
this.
|
|
160
|
-
this.
|
|
264
|
+
this.setJammed(true);
|
|
265
|
+
this.clearPendingTarget(true);
|
|
161
266
|
if (this.positionState !== this.platform.Characteristic.PositionState.STOPPED) {
|
|
162
267
|
this.positionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
163
268
|
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, this.positionState);
|
|
164
269
|
}
|
|
270
|
+
this.clearStopTimer();
|
|
165
271
|
this.platform.log.debug(`No state updates for ${this.accessory.displayName} within ${timeoutMs}ms; marking STOPPED.`);
|
|
166
272
|
}, timeoutMs);
|
|
167
273
|
}
|
|
@@ -172,33 +278,105 @@ class FacadeBlindAccessory {
|
|
|
172
278
|
}
|
|
173
279
|
this.pendingTargetPosition = undefined;
|
|
174
280
|
this.pendingTargetExpiresAt = 0;
|
|
175
|
-
if (syncTarget) {
|
|
281
|
+
if (syncTarget && this.targetPosition !== this.currentPosition) {
|
|
176
282
|
this.targetPosition = this.currentPosition;
|
|
177
283
|
this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.targetPosition);
|
|
178
284
|
}
|
|
179
285
|
}
|
|
286
|
+
clearStopTimer() {
|
|
287
|
+
if (this.stopTimer) {
|
|
288
|
+
clearTimeout(this.stopTimer);
|
|
289
|
+
this.stopTimer = undefined;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
scheduleMotionStopTimer() {
|
|
293
|
+
const quietMs = 2500;
|
|
294
|
+
if (this.motionStopTimer) {
|
|
295
|
+
clearTimeout(this.motionStopTimer);
|
|
296
|
+
}
|
|
297
|
+
this.motionStopTimer = setTimeout(() => {
|
|
298
|
+
this.motionStopTimer = undefined;
|
|
299
|
+
if (this.pendingTargetPosition !== undefined) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (this.positionState !== this.platform.Characteristic.PositionState.STOPPED) {
|
|
303
|
+
this.positionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
304
|
+
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, this.positionState);
|
|
305
|
+
}
|
|
306
|
+
}, quietMs);
|
|
307
|
+
}
|
|
308
|
+
clearMotionStopTimer() {
|
|
309
|
+
if (this.motionStopTimer) {
|
|
310
|
+
clearTimeout(this.motionStopTimer);
|
|
311
|
+
this.motionStopTimer = undefined;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
disposeTimers() {
|
|
315
|
+
this.clearPendingTarget(false);
|
|
316
|
+
this.clearStopTimer();
|
|
317
|
+
this.clearMotionStopTimer();
|
|
318
|
+
}
|
|
319
|
+
setJammed(isJammed) {
|
|
320
|
+
if (this.jammed === isJammed) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
this.jammed = isJammed;
|
|
324
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusJammed, this.jammed ? 1 : 0);
|
|
325
|
+
}
|
|
326
|
+
updateConnection(isConnected) {
|
|
327
|
+
this.connected = isConnected;
|
|
328
|
+
this.service.updateCharacteristic(this.platform.Characteristic.StatusFault, this.connected ? 0 : 1);
|
|
329
|
+
if (!this.connected) {
|
|
330
|
+
this.setJammed(false);
|
|
331
|
+
this.hasReceivedPosition = false;
|
|
332
|
+
this.hasReceivedTilt = false;
|
|
333
|
+
this.lastRawPosition = undefined;
|
|
334
|
+
this.lastTiltCommandAt = 0;
|
|
335
|
+
this.clearPendingTarget(true);
|
|
336
|
+
this.clearStopTimer();
|
|
337
|
+
this.clearMotionStopTimer();
|
|
338
|
+
if (this.positionState !== this.platform.Characteristic.PositionState.STOPPED) {
|
|
339
|
+
this.positionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
340
|
+
this.service.updateCharacteristic(this.platform.Characteristic.PositionState, this.positionState);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
180
344
|
async handlePositionStateGet() {
|
|
345
|
+
this.assertPositionAvailable();
|
|
181
346
|
return this.positionState;
|
|
182
347
|
}
|
|
183
348
|
async handleCurrentTiltGet() {
|
|
349
|
+
this.assertTiltAvailable();
|
|
184
350
|
return this.currentTiltAngle;
|
|
185
351
|
}
|
|
186
352
|
async handleTargetTiltGet() {
|
|
353
|
+
this.assertTiltAvailable();
|
|
187
354
|
return this.targetTiltAngle;
|
|
188
355
|
}
|
|
189
356
|
async handleTargetTiltSet(value) {
|
|
190
357
|
const target = value;
|
|
191
|
-
this.targetTiltAngle = this.clamp(target, -90, 90);
|
|
358
|
+
this.targetTiltAngle = Math.round(this.clamp(target, -90, 90));
|
|
359
|
+
this.lastTiltCommandAt = Date.now();
|
|
192
360
|
this.service.updateCharacteristic(this.platform.Characteristic.TargetHorizontalTiltAngle, this.targetTiltAngle);
|
|
193
361
|
const tiltValue = this.toTiltValue(this.targetTiltAngle).toString();
|
|
194
362
|
const tiltTopic = `${this.context.topic}/${this.platform.getCoveringTiltTopicSuffix()}`;
|
|
195
363
|
this.platform.log.debug(`Publishing ${tiltTopic} = ${tiltValue}`);
|
|
196
|
-
this.platform.
|
|
364
|
+
this.platform.publishCommand(tiltTopic, tiltValue, (error) => {
|
|
197
365
|
if (error) {
|
|
198
366
|
this.platform.log.error(`Publish failed for ${tiltTopic}: ${error.message}`);
|
|
199
367
|
}
|
|
200
368
|
});
|
|
201
369
|
}
|
|
370
|
+
assertPositionAvailable() {
|
|
371
|
+
if (!this.connected || !this.hasReceivedPosition) {
|
|
372
|
+
throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
assertTiltAvailable() {
|
|
376
|
+
if (!this.connected || !this.hasReceivedTilt) {
|
|
377
|
+
throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
202
380
|
toPosition(shutValue) {
|
|
203
381
|
return this.clamp(100 - shutValue, 0, 100);
|
|
204
382
|
}
|
|
@@ -242,7 +420,7 @@ class FacadeBlindAccessory {
|
|
|
242
420
|
this.stopTimer = setTimeout(() => {
|
|
243
421
|
const actionTopic = `${this.context.topic}/execute_action`;
|
|
244
422
|
this.platform.log.debug(`Publishing ${actionTopic} = ${stopAction} (auto-stop)`);
|
|
245
|
-
this.platform.
|
|
423
|
+
this.platform.publishCommand(actionTopic, stopAction, (error) => {
|
|
246
424
|
if (error) {
|
|
247
425
|
this.platform.log.error(`Publish failed for ${actionTopic}: ${error.message}`);
|
|
248
426
|
}
|