homebridge-bedjet 0.3.2 → 0.3.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/accessory.js +16 -7
- package/package.json +1 -1
- package/src/accessory.ts +16 -7
package/dist/accessory.js
CHANGED
|
@@ -105,13 +105,22 @@ class BedJetAccessory {
|
|
|
105
105
|
return 1; // HEAT / TURBO / EXTENDED_HEAT
|
|
106
106
|
})
|
|
107
107
|
.onSet((value) => {
|
|
108
|
-
|
|
108
|
+
const val = value;
|
|
109
109
|
const wasOff = this.bedjet.state.operatingMode === constants_1.OperatingMode.STANDBY
|
|
110
110
|
|| this.bedjet.state.operatingMode === constants_1.OperatingMode.WAIT;
|
|
111
|
-
const turningOn =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
const turningOn = val !== 0;
|
|
112
|
+
let mode;
|
|
113
|
+
if (val === 3 || (turningOn && wasOff)) {
|
|
114
|
+
// Siri sends Auto (3) when turning on — and any turn-on from standby —
|
|
115
|
+
// should respect the user's configured defaultMode.
|
|
116
|
+
mode = config.defaultMode
|
|
117
|
+
? DEFAULT_MODE_MAP[config.defaultMode]
|
|
118
|
+
: TARGET_TO_MODE[val] ?? constants_1.OperatingMode.HEAT;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
mode = TARGET_TO_MODE[val] ?? constants_1.OperatingMode.STANDBY;
|
|
122
|
+
}
|
|
123
|
+
this._applyModeAndDefaults(mode, wasOff && turningOn).catch(err => this.platform.log.error(`[${config.name}] setOperatingMode failed: ${err}`));
|
|
115
124
|
});
|
|
116
125
|
// FanV2 service
|
|
117
126
|
this.fanService = this.accessory.getService(Service.Fanv2)
|
|
@@ -130,7 +139,7 @@ class BedJetAccessory {
|
|
|
130
139
|
const mode = this.config.defaultMode
|
|
131
140
|
? DEFAULT_MODE_MAP[this.config.defaultMode]
|
|
132
141
|
: constants_1.OperatingMode.HEAT;
|
|
133
|
-
this._applyModeAndDefaults(mode, true
|
|
142
|
+
this._applyModeAndDefaults(mode, true).catch(err => this.platform.log.error(`[${config.name}] turn on failed: ${err}`));
|
|
134
143
|
}
|
|
135
144
|
});
|
|
136
145
|
this.fanService.getCharacteristic(Characteristic.RotationSpeed)
|
|
@@ -165,7 +174,7 @@ class BedJetAccessory {
|
|
|
165
174
|
* (fan turn-on path); false when HomeKit supplied the mode explicitly
|
|
166
175
|
* (thermostat path).
|
|
167
176
|
*/
|
|
168
|
-
async _applyModeAndDefaults(mode, applyDefaults
|
|
177
|
+
async _applyModeAndDefaults(mode, applyDefaults) {
|
|
169
178
|
const { config } = this;
|
|
170
179
|
// Determine HomeKit target state for pending optimistic value
|
|
171
180
|
const pendingState = mode === constants_1.OperatingMode.STANDBY ? 0
|
package/package.json
CHANGED
package/src/accessory.ts
CHANGED
|
@@ -130,13 +130,23 @@ export class BedJetAccessory {
|
|
|
130
130
|
return 1; // HEAT / TURBO / EXTENDED_HEAT
|
|
131
131
|
})
|
|
132
132
|
.onSet((value: CharacteristicValue) => {
|
|
133
|
-
|
|
133
|
+
const val = value as number;
|
|
134
134
|
const wasOff = this.bedjet.state.operatingMode === OperatingMode.STANDBY
|
|
135
135
|
|| this.bedjet.state.operatingMode === OperatingMode.WAIT;
|
|
136
|
-
const turningOn =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
const turningOn = val !== 0;
|
|
137
|
+
|
|
138
|
+
let mode: OperatingMode;
|
|
139
|
+
if (val === 3 || (turningOn && wasOff)) {
|
|
140
|
+
// Siri sends Auto (3) when turning on — and any turn-on from standby —
|
|
141
|
+
// should respect the user's configured defaultMode.
|
|
142
|
+
mode = config.defaultMode
|
|
143
|
+
? DEFAULT_MODE_MAP[config.defaultMode]
|
|
144
|
+
: TARGET_TO_MODE[val] ?? OperatingMode.HEAT;
|
|
145
|
+
} else {
|
|
146
|
+
mode = TARGET_TO_MODE[val] ?? OperatingMode.STANDBY;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
this._applyModeAndDefaults(mode, wasOff && turningOn).catch(err =>
|
|
140
150
|
this.platform.log.error(`[${config.name}] setOperatingMode failed: ${err}`),
|
|
141
151
|
);
|
|
142
152
|
});
|
|
@@ -162,7 +172,7 @@ export class BedJetAccessory {
|
|
|
162
172
|
const mode = this.config.defaultMode
|
|
163
173
|
? DEFAULT_MODE_MAP[this.config.defaultMode]
|
|
164
174
|
: OperatingMode.HEAT;
|
|
165
|
-
this._applyModeAndDefaults(mode, true
|
|
175
|
+
this._applyModeAndDefaults(mode, true).catch(err =>
|
|
166
176
|
this.platform.log.error(`[${config.name}] turn on failed: ${err}`),
|
|
167
177
|
);
|
|
168
178
|
}
|
|
@@ -211,7 +221,6 @@ export class BedJetAccessory {
|
|
|
211
221
|
private async _applyModeAndDefaults(
|
|
212
222
|
mode: OperatingMode,
|
|
213
223
|
applyDefaults: boolean,
|
|
214
|
-
applyMode: boolean,
|
|
215
224
|
): Promise<void> {
|
|
216
225
|
const { config } = this;
|
|
217
226
|
|