homebridge-tydom 0.32.2 → 0.32.3

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-CJBHeITb.mjs");
4
+ const { default: TydomPlatform } = await import("./platform-d-jxZ1Nu.mjs");
5
5
  var src_default = (homebridge) => {
6
6
  homebridge.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, TydomPlatform);
7
7
  };
@@ -3021,6 +3021,15 @@ const parseDiscoveryResponse = (uri, schema, payload) => {
3021
3021
  * device is not the shape the accessory was built for — which is a bug in the
3022
3022
  * signature table, not a value HomeKit should be handed.
3023
3023
  */
3024
+ /**
3025
+ * The value of a property the hardware may simply not carry.
3026
+ *
3027
+ * `getTydomDataPropValue` asserts, which is right for a property the device
3028
+ * type guarantees. Delta Dore's HVAC range guarantees less than it looks: some
3029
+ * endpoints expose a thermic level and no numbers at all, no `setpoint` and no
3030
+ * `temperature`, and asserting on those turned every read into an error.
3031
+ */
3032
+ const findTydomDataPropValue = (data, name) => data.find((prop) => prop.name === name)?.value;
3024
3033
  const getTydomDataPropValue = (data, name) => {
3025
3034
  const item = data.find((prop) => prop.name === name);
3026
3035
  assert(item, `Missing property with name="${name}" in endpoint data`);
@@ -4039,11 +4048,12 @@ var GarageDoorAccessory = class extends BaseAccessory {
4039
4048
  this.#computedPosition = doorState === CurrentDoorState.OPEN ? 100 : 0;
4040
4049
  }
4041
4050
  #setDoorState(doorState) {
4042
- const { CurrentDoorState } = this.platform.Characteristic;
4051
+ const { CurrentDoorState, TargetDoorState } = this.platform.Characteristic;
4043
4052
  debug(`assignCurrentDoorState=${styleString(this.#label(doorState))}`);
4044
4053
  this.#currentDoorState = doorState;
4045
4054
  this.#settleTarget(doorState);
4046
4055
  this.#service.updateCharacteristic(CurrentDoorState, doorState);
4056
+ if (doorState === CurrentDoorState.OPEN || doorState === CurrentDoorState.CLOSED) this.#service.updateCharacteristic(TargetDoorState, this.#targetDoorState);
4047
4057
  }
4048
4058
  /** A door at rest, open or closed, was headed exactly there. */
4049
4059
  #settleTarget(doorState) {
@@ -4813,6 +4823,14 @@ const EXPOSED_THERMIC_LEVELS = /* @__PURE__ */ new Set([
4813
4823
  "ECO",
4814
4824
  "COMFORT"
4815
4825
  ]);
4826
+ /**
4827
+ * What to report when the endpoint carries no temperature at all.
4828
+ *
4829
+ * HAP's own default for `CurrentTemperature`, so a device with no thermometer
4830
+ * looks the same as one that has not answered yet, rather than inventing a
4831
+ * reading.
4832
+ */
4833
+ const UNKNOWN_TEMPERATURE = 0;
4816
4834
  /** An electric heating controller (Delta Dore RF4890, RF6600FP). */
4817
4835
  var ThermostatAccessory = class extends BaseAccessory {
4818
4836
  #service;
@@ -4859,9 +4877,13 @@ var ThermostatAccessory = class extends BaseAccessory {
4859
4877
  debugGet(CurrentHeatingCoolingState, this.#service);
4860
4878
  const data = await this.#read();
4861
4879
  const authorization = getTydomDataPropValue(data, "authorization");
4862
- const setpoint = getTydomDataPropValue(data, "setpoint");
4863
- const temperature = getTydomDataPropValue(data, "temperature");
4880
+ const setpoint = findTydomDataPropValue(data, "setpoint");
4881
+ const temperature = findTydomDataPropValue(data, "temperature");
4864
4882
  let nextValue = CurrentHeatingCoolingState.OFF;
4883
+ if (typeof setpoint !== "number" || typeof temperature !== "number") {
4884
+ debugGetResult(CurrentHeatingCoolingState, this.#service, nextValue);
4885
+ return nextValue;
4886
+ }
4865
4887
  if (authorization === "HEATING" && setpoint > temperature) nextValue = CurrentHeatingCoolingState.HEAT;
4866
4888
  else if (authorization === "COOLING" && temperature > setpoint) nextValue = CurrentHeatingCoolingState.COOL;
4867
4889
  debugGetResult(CurrentHeatingCoolingState, this.#service, nextValue);
@@ -4901,14 +4923,15 @@ var ThermostatAccessory = class extends BaseAccessory {
4901
4923
  });
4902
4924
  this.#service.getCharacteristic(CurrentTemperature).onGet(async () => {
4903
4925
  debugGet(CurrentTemperature, this.#service);
4904
- const temperature = getTydomDataPropValue(await this.#read(), "temperature");
4926
+ const data = await this.#read();
4927
+ const temperature = findTydomDataPropValue(data, "temperature") ?? findTydomDataPropValue(data, "setpoint") ?? UNKNOWN_TEMPERATURE;
4905
4928
  debugGetResult(CurrentTemperature, this.#service, temperature);
4906
4929
  return temperature;
4907
4930
  });
4908
4931
  this.#service.getCharacteristic(TargetTemperature).onGet(async () => {
4909
4932
  debugGet(TargetTemperature, this.#service);
4910
4933
  const data = await this.#read();
4911
- const setpoint = getTydomDataPropValue(data, "setpoint") ?? getTydomDataPropValue(data, "temperature");
4934
+ const setpoint = findTydomDataPropValue(data, "setpoint") ?? findTydomDataPropValue(data, "temperature") ?? UNKNOWN_TEMPERATURE;
4912
4935
  debugGetResult(TargetTemperature, this.#service, setpoint);
4913
4936
  return setpoint;
4914
4937
  }).onSet(async (value) => {
@@ -5652,4 +5675,4 @@ var TydomPlatform = class {
5652
5675
  //#endregion
5653
5676
  export { TydomPlatform as default };
5654
5677
 
5655
- //# sourceMappingURL=platform-CJBHeITb.mjs.map
5678
+ //# sourceMappingURL=platform-d-jxZ1Nu.mjs.map