homebridge-tydom 0.32.0 → 0.32.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/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as PLUGIN_NAME, t as PLATFORM_NAME } from "./env-B2-Dw8C2.mjs";
2
2
  //#region src/index.ts
3
3
  process.setSourceMapsEnabled(true);
4
- const { default: TydomPlatform } = await import("./platform-DmVGk0po.mjs");
4
+ const { default: TydomPlatform } = await import("./platform-BssMTVVc.mjs");
5
5
  var src_default = (homebridge) => {
6
6
  homebridge.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, TydomPlatform);
7
7
  };
@@ -3875,6 +3875,12 @@ var GarageDoorAccessory = class extends BaseAccessory {
3875
3875
  /** Some drivers expose only TOGGLE and cannot be commanded to a state. */
3876
3876
  #toggleOnly;
3877
3877
  #currentDoorState;
3878
+ /**
3879
+ * Where the door was last asked to go. TargetDoorState only admits OPEN and
3880
+ * CLOSED, so it cannot mirror the current state through OPENING, CLOSING or
3881
+ * STOPPED.
3882
+ */
3883
+ #targetDoorState;
3878
3884
  #lastUpdatedAt = 0;
3879
3885
  #computedPosition = 0;
3880
3886
  #transition;
@@ -3888,6 +3894,7 @@ var GarageDoorAccessory = class extends BaseAccessory {
3888
3894
  const levelCmdValues = metadata.find((m) => m.name === "levelCmd")?.enum_values;
3889
3895
  this.#toggleOnly = levelCmdValues?.length === 1 && levelCmdValues[0] === "TOGGLE";
3890
3896
  this.#currentDoorState = CurrentDoorState.CLOSED;
3897
+ this.#targetDoorState = TargetDoorState.CLOSED;
3891
3898
  const legacy = this.accessory.getService(this.platform.Service.Switch);
3892
3899
  if (legacy) this.accessory.removeService(legacy);
3893
3900
  this.#service = this.service(this.platform.Service.GarageDoorOpener);
@@ -3905,8 +3912,8 @@ var GarageDoorAccessory = class extends BaseAccessory {
3905
3912
  this.#service.getCharacteristic(TargetDoorState).onGet(async () => {
3906
3913
  debugGet(TargetDoorState, this.#service);
3907
3914
  if (this.#toggleOnly) {
3908
- debugGetResult(TargetDoorState, this.#service, this.#currentDoorState);
3909
- return this.#currentDoorState;
3915
+ debugGetResult(TargetDoorState, this.#service, this.#targetDoorState);
3916
+ return this.#targetDoorState;
3910
3917
  }
3911
3918
  const next = await this.#readDoorState();
3912
3919
  this.#lastUpdatedAt = Date.now();
@@ -3955,6 +3962,7 @@ var GarageDoorAccessory = class extends BaseAccessory {
3955
3962
  const { CurrentDoorState } = this.platform.Characteristic;
3956
3963
  this.#lastUpdatedAt = Date.now();
3957
3964
  this.#computedPosition = this.#positionNow();
3965
+ this.#targetDoorState = targetDoorState;
3958
3966
  let next = this.#nextDoorState(targetDoorState);
3959
3967
  if (next === this.#currentDoorState) {
3960
3968
  debug(`nextCurrentDoorState=${styleNumber(next)} === currentDoorState, nothing to do`);
@@ -4026,6 +4034,7 @@ var GarageDoorAccessory = class extends BaseAccessory {
4026
4034
  #applyKnownState(doorState) {
4027
4035
  const { CurrentDoorState } = this.platform.Characteristic;
4028
4036
  this.#currentDoorState = doorState;
4037
+ this.#settleTarget(doorState);
4029
4038
  this.#lastUpdatedAt = Date.now();
4030
4039
  this.#computedPosition = doorState === CurrentDoorState.OPEN ? 100 : 0;
4031
4040
  }
@@ -4033,8 +4042,15 @@ var GarageDoorAccessory = class extends BaseAccessory {
4033
4042
  const { CurrentDoorState } = this.platform.Characteristic;
4034
4043
  debug(`assignCurrentDoorState=${styleString(this.#label(doorState))}`);
4035
4044
  this.#currentDoorState = doorState;
4045
+ this.#settleTarget(doorState);
4036
4046
  this.#service.updateCharacteristic(CurrentDoorState, doorState);
4037
4047
  }
4048
+ /** A door at rest, open or closed, was headed exactly there. */
4049
+ #settleTarget(doorState) {
4050
+ const { CurrentDoorState, TargetDoorState } = this.platform.Characteristic;
4051
+ if (doorState === CurrentDoorState.OPEN) this.#targetDoorState = TargetDoorState.OPEN;
4052
+ else if (doorState === CurrentDoorState.CLOSED) this.#targetDoorState = TargetDoorState.CLOSED;
4053
+ }
4038
4054
  /** Where the door has got to, given how long it has been travelling. */
4039
4055
  #positionNow() {
4040
4056
  const { CurrentDoorState } = this.platform.Characteristic;
@@ -5604,4 +5620,4 @@ var TydomPlatform = class {
5604
5620
  //#endregion
5605
5621
  export { TydomPlatform as default };
5606
5622
 
5607
- //# sourceMappingURL=platform-DmVGk0po.mjs.map
5623
+ //# sourceMappingURL=platform-BssMTVVc.mjs.map