homebridge-bedjet 0.3.4 → 0.3.5

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.
@@ -46,12 +46,12 @@
46
46
  "description": "Mode to activate when the BedJet is turned on from HomeKit"
47
47
  },
48
48
  "defaultTemperature": {
49
- "title": "Default Temperature °C (when turned on)",
49
+ "title": "Default Temperature °F (when turned on)",
50
50
  "type": "number",
51
- "minimum": 19,
52
- "maximum": 43,
53
- "multipleOf": 0.5,
54
- "description": "Target temperature to set when turned on. Range: 19–43°C (66–109°F). Leave blank to keep the BedJet's last-used temperature."
51
+ "minimum": 66,
52
+ "maximum": 109,
53
+ "multipleOf": 1,
54
+ "description": "Target temperature to set when turned on, in °F. Range: 66–109°F. Leave blank to keep the BedJet's last-used temperature."
55
55
  },
56
56
  "defaultFanSpeed": {
57
57
  "title": "Default Fan Speed % (when turned on)",
package/dist/accessory.js CHANGED
@@ -171,8 +171,16 @@ class BedJetAccessory {
171
171
  await this.bedjet.setOperatingMode(mode);
172
172
  if (applyDefaults) {
173
173
  if (config.defaultTemperature !== undefined) {
174
- this.setPending(config.defaultTemperature, 'pendingTemp', 'pendingTempTimer', 5000);
175
- await this.bedjet.setTemperature(config.defaultTemperature);
174
+ // Config stores °F (values > 43 are unambiguously Fahrenheit).
175
+ // Old configs stored °C (≤ 43) — leave those as-is for backward compat.
176
+ let tempC = config.defaultTemperature;
177
+ if (tempC > 43) {
178
+ tempC = (tempC - 32) * 5 / 9;
179
+ }
180
+ // Clamp to BedJet V3 valid range 19–43 °C, rounded to nearest 0.5
181
+ tempC = Math.max(19, Math.min(43, Math.round(tempC * 2) / 2));
182
+ this.setPending(tempC, 'pendingTemp', 'pendingTempTimer', 5000);
183
+ await this.bedjet.setTemperature(tempC);
176
184
  }
177
185
  if (config.defaultFanSpeed !== undefined) {
178
186
  this.setPending(config.defaultFanSpeed, 'pendingFanSpeed', 'pendingFanSpeedTimer', 5000);
@@ -362,19 +362,27 @@
362
362
  modeField.appendChild(modeSelect);
363
363
  row.appendChild(modeField);
364
364
 
365
- // Temperature
365
+ // Temperature — stored and entered in °F.
366
+ // Old configs may have stored °C (≤ 43); convert those to °F for display.
367
+ var tempF = null;
368
+ if (currentTemp != null) {
369
+ tempF = currentTemp > 43
370
+ ? Math.round(currentTemp) // already °F
371
+ : Math.round(currentTemp * 9 / 5 + 32); // was °C — convert for display
372
+ }
373
+
366
374
  var tempField = document.createElement('div');
367
375
  tempField.className = 'field';
368
376
  var tempLabel = document.createElement('label');
369
- tempLabel.textContent = 'Temp °C';
377
+ tempLabel.textContent = 'Temp °F';
370
378
  var tempInput = document.createElement('input');
371
379
  tempInput.type = 'number';
372
380
  tempInput.className = 'field-temp';
373
- tempInput.min = '19';
374
- tempInput.max = '43';
375
- tempInput.step = '0.5';
381
+ tempInput.min = '66';
382
+ tempInput.max = '109';
383
+ tempInput.step = '1';
376
384
  tempInput.placeholder = 'Optional';
377
- if (currentTemp != null) tempInput.value = currentTemp;
385
+ if (tempF !== null) tempInput.value = tempF;
378
386
  tempField.appendChild(tempLabel);
379
387
  tempField.appendChild(tempInput);
380
388
  row.appendChild(tempField);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-bedjet",
3
3
  "displayName": "BedJet",
4
- "version": "0.3.4",
4
+ "version": "0.3.5",
5
5
  "description": "Homebridge plugin for BedJet V3 via Bluetooth LE",
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",
package/src/accessory.ts CHANGED
@@ -222,8 +222,16 @@ export class BedJetAccessory {
222
222
 
223
223
  if (applyDefaults) {
224
224
  if (config.defaultTemperature !== undefined) {
225
- this.setPending(config.defaultTemperature, 'pendingTemp', 'pendingTempTimer', 5000);
226
- await this.bedjet.setTemperature(config.defaultTemperature);
225
+ // Config stores °F (values > 43 are unambiguously Fahrenheit).
226
+ // Old configs stored °C (≤ 43) — leave those as-is for backward compat.
227
+ let tempC = config.defaultTemperature;
228
+ if (tempC > 43) {
229
+ tempC = (tempC - 32) * 5 / 9;
230
+ }
231
+ // Clamp to BedJet V3 valid range 19–43 °C, rounded to nearest 0.5
232
+ tempC = Math.max(19, Math.min(43, Math.round(tempC * 2) / 2));
233
+ this.setPending(tempC, 'pendingTemp', 'pendingTempTimer', 5000);
234
+ await this.bedjet.setTemperature(tempC);
227
235
  }
228
236
  if (config.defaultFanSpeed !== undefined) {
229
237
  this.setPending(config.defaultFanSpeed, 'pendingFanSpeed', 'pendingFanSpeedTimer', 5000);
@@ -27,7 +27,7 @@ export interface BedJetConfig {
27
27
  address: string; // BLE MAC e.g. "AA:BB:CC:DD:EE:FF"
28
28
  scanTimeout?: number; // seconds (default 30)
29
29
  defaultMode?: DefaultMode; // mode to activate when turned on from HomeKit
30
- defaultTemperature?: number; // °C, applied on turn-on
30
+ defaultTemperature?: number; // °F (values >43 treated as °F; ≤43 treated as °C for backward compat)
31
31
  defaultFanSpeed?: number; // percent 5–100, applied on turn-on
32
32
  }
33
33