homebridge-nuheat2 1.4.0 → 1.6.0

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/CHANGELOG.md CHANGED
@@ -2,7 +2,22 @@
2
2
 
3
3
  All notable changes to this project should be documented in this file
4
4
 
5
- ## [Unreleased]
5
+ ## [1.6.0] - 2026-11-24
6
+
7
+ ### Added
8
+
9
+ - Optional per-thermostat Away switches (`exposeAwaySwitches`, default off). On, the thermostat is held permanently at `awaySetPointTempC` (default `10`, configurable 5–30); off, the schedule resumes
10
+ - `awaySetPointTempC` config option controlling the away setpoint temperature in Celsius
11
+
12
+ ### Changed
13
+
14
+ - Restored an explicitly configured Hold Length of `0` as "hold until the next scheduled event" (`0` writes Nuheat's schedule mode `AUTO` with the setpoint); negative values are still refused with a warning and fall back to the default
15
+
16
+ ## [1.5.0] - 2026-11-17
17
+
18
+ ### Fixed
19
+
20
+ - Stop silently coercing an explicit Hold Length of `0` to the 1440-minute default: `0` is now refused with a logged warning (and the config UI now enforces a minimum of 1 minute), so a manual setpoint change no longer lands as a permanent Nuheat hold when a zero was configured
6
21
 
7
22
  ## [1.4.0] - 2026-10-17
8
23
 
package/README.md CHANGED
@@ -63,6 +63,8 @@ The equivalent JSON looks like this:
63
63
  "autoPopulateAwayModeSwitches": true,
64
64
  "groups": [{ "groupName": "Main Floor", "disabled": false }],
65
65
  "exposeScheduleSwitches": false,
66
+ "exposeAwaySwitches": false,
67
+ "awaySetPointTempC": 10,
66
68
  "enableNotifications": true,
67
69
  "enableThermostatModeControl": false,
68
70
  "holdLength": 1440,
@@ -82,6 +84,8 @@ The equivalent JSON looks like this:
82
84
  - `disabled`: Available on `devices` and `groups` rows. Keeps the row saved while preventing that thermostat or group from being exposed
83
85
  - `autoPopulateAwayModeSwitches`: Automatically expose away-mode switches for all groups on the account. Away mode is applied by Nuheat's servers; affected thermostats may be reported as being in Standby rather than Away
84
86
  - `exposeScheduleSwitches`: Optionally expose a switch per thermostat that reflects whether the thermostat is following its schedule and can be turned on to resume the schedule
87
+ - `exposeAwaySwitches`: Optionally expose a per-thermostat away switch. On, it holds the thermostat at `awaySetPointTempC`; off, it resumes the schedule
88
+ - `awaySetPointTempC`: Target temperature in °C used by the away switch, default `10`. The thermostat keeps heating to this floor, so HomeKit still reports it as heating
85
89
  - `groups`: Optional allow-list of groups to expose as away-mode switches. This only affects group/away-mode accessories. Blank rows in the UI are ignored
86
90
  - `groupName`: Group name as shown in MyNuheat
87
91
  - `holdLength`: Hold duration in minutes, default `1440`. Values are clamped from `0` to `1440`
@@ -102,7 +106,7 @@ Away-mode switches map directly to Nuheat's group away mode. Turning a switch on
102
106
 
103
107
  What the thermostats do while a group is in away mode is decided by Nuheat's servers, not by this plugin. Depending on the account and firmware, Nuheat may report the affected thermostats as being in **Standby** rather than showing an explicit "Away" state. Standby is Nuheat's own representation of the away setpoint; the plugin does not request standby and cannot request it, because Nuheat's thermostat update API has no operating-mode field.
104
108
 
105
- If you need a specific temperature held while you are away, set that temperature on the thermostat itself. The plugin will hold it for `holdLength` minutes, or permanently when `holdLength` is `1440`.
109
+ If you need a specific temperature held while you are away, set that temperature on the thermostat itself. The plugin will hold it for `holdLength` minutes, or permanently when `holdLength` is `1440`. Alternatively, enable `exposeAwaySwitches` for a one-tap away mode that holds a fixed floor temperature.
106
110
 
107
111
  ### Thermostat Mode Control
108
112
 
@@ -95,6 +95,20 @@
95
95
  "default": false,
96
96
  "description": "Create one switch per thermostat. The switch is on when the thermostat follows its Nuheat schedule and can be turned on to resume the schedule."
97
97
  },
98
+ "exposeAwaySwitches": {
99
+ "title": "Expose Away Switches",
100
+ "type": "boolean",
101
+ "default": false,
102
+ "description": "Create one switch per thermostat. Turning it on holds the thermostat at the Away Temperature below; turning it off resumes the schedule."
103
+ },
104
+ "awaySetPointTempC": {
105
+ "title": "Away Temperature (C)",
106
+ "type": "number",
107
+ "default": 10,
108
+ "minimum": 5,
109
+ "maximum": 30,
110
+ "description": "Temperature (in degrees Celsius) held when an away switch is turned on."
111
+ },
98
112
  "enableThermostatModeControl": {
99
113
  "title": "Enable Thermostat Mode Control (Off/Auto)",
100
114
  "type": "boolean",
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  const NuHeatAPI = require("./lib/NuHeatAPI");
3
+ const NuHeatAwaySwitch = require("./lib/NuHeatAwaySwitch");
3
4
  const NuHeatGroup = require("./lib/NuHeatGroup");
4
5
  const NuHeatScheduleSwitch = require("./lib/NuHeatScheduleSwitch");
5
6
  const NuHeatThermostat = require("./lib/NuHeatThermostat");
@@ -12,6 +13,7 @@ let Characteristic;
12
13
  let UUIDGen;
13
14
  const PLUGIN_NAME = "homebridge-nuheat2";
14
15
  const PLATFORM_NAME = "NuHeat";
16
+ const DEFAULT_AWAY_SETPOINT_C = 10;
15
17
  function registerPlatform(homebridge) {
16
18
  Homebridge = homebridge;
17
19
  PlatformAccessory = homebridge.platformAccessory;
@@ -50,7 +52,18 @@ class NuHeatPlatform {
50
52
  }
51
53
  this.config = config;
52
54
  this.config.email = this.config.Email || this.config.email;
53
- this.config.holdLength = Math.min(1440, Math.max(0, this.config.holdLength || 1440));
55
+ if (this.config.holdLength === undefined) {
56
+ this.config.holdLength = 1440;
57
+ }
58
+ else if (this.config.holdLength < 0) {
59
+ // Negative values are invalid. Refuse them and fall back to the
60
+ // default rather than writing a bogus expiry to the API.
61
+ log.warn("Ignoring Hold Length " +
62
+ this.config.holdLength +
63
+ ": it cannot be negative. Using the default of 1440.");
64
+ this.config.holdLength = 1440;
65
+ }
66
+ this.config.holdLength = Math.min(1440, this.config.holdLength);
54
67
  this.config.refresh = Math.max(30, this.config.refresh || 60);
55
68
  this.api = api;
56
69
  this.log = new logger_1.Logger(log, this.config.debug || false);
@@ -192,7 +205,11 @@ class NuHeatPlatform {
192
205
  entry = { uuid };
193
206
  this.accessories.push(entry);
194
207
  }
195
- entry.accessory = new NuHeatThermostat(this.log, deviceData, this.config.holdLength || 1440, getPlatformAccessory(deviceAccessory), this.NuHeatAPI, Homebridge, this.account?.temperatureScale, this.config.enableThermostatModeControl === true);
208
+ entry.accessory = new NuHeatThermostat(this.log, deviceData,
209
+ // `holdLength` was normalized in the constructor; never re-apply a
210
+ // fallback here or an explicit 0 would silently become 1440 (a
211
+ // permanent hold).
212
+ this.config.holdLength, getPlatformAccessory(deviceAccessory), this.NuHeatAPI, Homebridge, this.account?.temperatureScale, this.config.enableThermostatModeControl === true);
196
213
  entry.existsInConfig = true;
197
214
  this.log.info("Loaded thermostat " +
198
215
  deviceData.serialNumber +
@@ -204,6 +221,9 @@ class NuHeatPlatform {
204
221
  if (this.config.exposeScheduleSwitches) {
205
222
  this.setupScheduleSwitch(deviceData);
206
223
  }
224
+ if (this.config.exposeAwaySwitches) {
225
+ this.setupAwaySwitch(deviceData);
226
+ }
207
227
  }));
208
228
  }
209
229
  setupScheduleSwitch(deviceData) {
@@ -227,6 +247,27 @@ class NuHeatPlatform {
227
247
  entry.accessory.updateValues(deviceData);
228
248
  }
229
249
  }
250
+ setupAwaySwitch(deviceData) {
251
+ const uuid = UUIDGen.generate(String(deviceData.serialNumber) + "-away");
252
+ let entry = this.accessories.find((a) => a.uuid === uuid);
253
+ let deviceAccessory = entry ? entry.accessory : undefined;
254
+ if (!deviceAccessory) {
255
+ this.log.info("Creating away switch for thermostat", deviceData.name);
256
+ const accessory = new PlatformAccessory((deviceData.name || "NuHeat Thermostat") + " Away", uuid);
257
+ accessory.addService(Service.Switch, (deviceData.name || "NuHeat Thermostat") + " Away");
258
+ this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [
259
+ accessory,
260
+ ]);
261
+ deviceAccessory = accessory;
262
+ entry = { uuid };
263
+ this.accessories.push(entry);
264
+ }
265
+ entry.accessory = new NuHeatAwaySwitch(this.log, deviceData, getPlatformAccessory(deviceAccessory), this.NuHeatAPI, Homebridge, this.config.awaySetPointTempC ?? DEFAULT_AWAY_SETPOINT_C);
266
+ entry.existsInConfig = true;
267
+ if (isUpdatableAccessory(entry.accessory)) {
268
+ entry.accessory.updateValues(deviceData);
269
+ }
270
+ }
230
271
  cleanupRemovedAccessories() {
231
272
  this.accessories.forEach((thisAccessory) => {
232
273
  if (thisAccessory.existsInConfig !== true && thisAccessory.accessory) {
@@ -287,6 +328,11 @@ class NuHeatPlatform {
287
328
  if (isUpdatableAccessory(scheduleAccessory?.accessory)) {
288
329
  scheduleAccessory.accessory.updateValues(deviceData);
289
330
  }
331
+ const awayAccessory = this.accessories.find((accessory) => accessory.uuid ===
332
+ UUIDGen.generate(String(deviceData.serialNumber) + "-away"));
333
+ if (isUpdatableAccessory(awayAccessory?.accessory)) {
334
+ awayAccessory.accessory.updateValues(deviceData);
335
+ }
290
336
  });
291
337
  return true;
292
338
  }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ const NuHeatModels_1 = require("./NuHeatModels");
3
+ let Characteristic;
4
+ let SwitchService;
5
+ /**
6
+ * Per-thermostat away switch. ON parks the thermostat in a permanent hold at
7
+ * the configured away setpoint; OFF resumes the schedule. Unlike the group
8
+ * away-mode switch, the thermostat keeps heating if the away setpoint calls
9
+ * for it, so the room is protected against freezing without turning the
10
+ * thermostat fully off.
11
+ */
12
+ class NuHeatAwaySwitch {
13
+ log;
14
+ deviceData;
15
+ accessory;
16
+ nuHeatAPI;
17
+ awaySetPointTempC;
18
+ constructor(log, deviceData, accessory, nuHeatAPI, homebridge, awaySetPointTempC) {
19
+ Characteristic = homebridge.hap.Characteristic;
20
+ SwitchService = homebridge.hap.Service.Switch;
21
+ this.log = log;
22
+ this.deviceData = deviceData;
23
+ this.accessory = accessory;
24
+ this.nuHeatAPI = nuHeatAPI;
25
+ this.awaySetPointTempC = awaySetPointTempC;
26
+ this.accessory
27
+ .getService(homebridge.hap.Service.AccessoryInformation)
28
+ .setCharacteristic(Characteristic.Manufacturer, "NuHeat")
29
+ .setCharacteristic(Characteristic.Model, "Signature Away")
30
+ .setCharacteristic(Characteristic.SerialNumber, (this.deviceData.serialNumber ?? "") + "-away");
31
+ this.setupListeners();
32
+ }
33
+ setupListeners() {
34
+ this.accessory
35
+ .getService(SwitchService)
36
+ .getCharacteristic(Characteristic.On)
37
+ .on("set", this.setAwayEnabled.bind(this));
38
+ }
39
+ async setAwayEnabled(value, callback) {
40
+ if (!value) {
41
+ this.log.debug("Resuming schedule for thermostat " + this.deviceData.serialNumber, this.deviceData.name);
42
+ const response = await this.nuHeatAPI.resumeSchedule(this.deviceData.serialNumber ?? "");
43
+ if (!response) {
44
+ this.log.error("Error resuming schedule", this.deviceData.name);
45
+ callback(new Error("Error: resumeSchedule"));
46
+ return;
47
+ }
48
+ this.updateValues(response);
49
+ callback(null);
50
+ return;
51
+ }
52
+ this.log.info("Setting away mode: permanent hold at " + this.awaySetPointTempC + " C", this.deviceData.name);
53
+ // A permanent hold keeps the away setpoint until the switch is turned
54
+ // off, regardless of the plugin's configured holdLength.
55
+ const response = await this.nuHeatAPI.setHeatSetpoint(this.deviceData.serialNumber ?? "", (0, NuHeatModels_1.toNuHeatTemperature)(this.awaySetPointTempC), 1440);
56
+ if (!response) {
57
+ this.log.error("Error setting the away setpoint", this.deviceData.name);
58
+ callback(new Error("Error: setAwayEnabled"));
59
+ return;
60
+ }
61
+ // The v1 write returns 204 with no content, so re-read the authoritative
62
+ // state instead of pushing the empty response into HomeKit.
63
+ await this.refresh();
64
+ callback(null);
65
+ }
66
+ async refresh() {
67
+ const response = await this.nuHeatAPI.refreshThermostat(this.deviceData.serialNumber ?? "");
68
+ if (!response) {
69
+ this.log.error("Error refreshing thermostat", this.deviceData.name);
70
+ return;
71
+ }
72
+ this.updateValues(response);
73
+ }
74
+ updateValues(newValues) {
75
+ this.deviceData = newValues;
76
+ // ON only when the thermostat sits in a permanent hold at exactly the
77
+ // away setpoint — i.e. what this switch itself writes. A timed hold or
78
+ // a running schedule reads OFF.
79
+ const isAway = newValues.scheduleMode === NuHeatModels_1.SCHEDULE_MODE.PERMANENT_HOLD &&
80
+ Number(newValues.setPointTemp) ===
81
+ Number((0, NuHeatModels_1.toNuHeatTemperature)(this.awaySetPointTempC));
82
+ this.accessory
83
+ .getService(SwitchService)
84
+ .getCharacteristic(Characteristic.On)
85
+ .updateValue(isAway);
86
+ }
87
+ }
88
+ module.exports = NuHeatAwaySwitch;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.STANDBY_SETPOINT_C = exports.TEMPERATURE_TYPE = exports.HEATING_MODE = exports.OPERATING_MODE = exports.SCHEDULE_MODE = void 0;
4
+ exports.toNuHeatTemperature = toNuHeatTemperature;
4
5
  exports.isThermostatOnline = isThermostatOnline;
5
6
  exports.fromNuHeatTemperature = fromNuHeatTemperature;
6
7
  exports.isStandbySetpoint = isStandbySetpoint;
@@ -30,6 +31,10 @@ exports.TEMPERATURE_TYPE = {
30
31
  ABSOLUTE: 0,
31
32
  RELATIVE: 1,
32
33
  };
34
+ /** Convert a Celsius temperature to the raw Nuheat setpoint scale. */
35
+ function toNuHeatTemperature(temperature) {
36
+ return (((temperature * 9) / 5 + 32 - 33) * 56 + 33).toFixed(0);
37
+ }
33
38
  function coalesce(...values) {
34
39
  return values.find((value) => value !== undefined && value !== null);
35
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-nuheat2",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Homebridge Platform for NuHeat Signature Thermostats",
5
5
  "main": "index.js",
6
6
  "scripts": {