homebridge-nuheat2 1.5.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 +11 -0
- package/README.md +5 -1
- package/config.schema.json +15 -1
- package/index.js +35 -5
- package/lib/NuHeatAwaySwitch.js +88 -0
- package/lib/NuHeatModels.js +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project should be documented in this file
|
|
4
4
|
|
|
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
|
+
|
|
5
16
|
## [1.5.0] - 2026-11-17
|
|
6
17
|
|
|
7
18
|
### Fixed
|
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
|
|
package/config.schema.json
CHANGED
|
@@ -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",
|
|
@@ -105,7 +119,7 @@
|
|
|
105
119
|
"title": "Hold Length (minutes)",
|
|
106
120
|
"type": "integer",
|
|
107
121
|
"default": 1440,
|
|
108
|
-
"minimum":
|
|
122
|
+
"minimum": 0,
|
|
109
123
|
"maximum": 1440,
|
|
110
124
|
"description": "Duration for HomeKit setpoint changes. Use 0 to hold until the next scheduled event, 1-1439 for a timed hold, or 1440 for a permanent hold."
|
|
111
125
|
},
|
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;
|
|
@@ -53,13 +55,12 @@ class NuHeatPlatform {
|
|
|
53
55
|
if (this.config.holdLength === undefined) {
|
|
54
56
|
this.config.holdLength = 1440;
|
|
55
57
|
}
|
|
56
|
-
else if (
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
// default instead of silently converting it to 1440.
|
|
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.
|
|
60
61
|
log.warn("Ignoring Hold Length " +
|
|
61
62
|
this.config.holdLength +
|
|
62
|
-
": it
|
|
63
|
+
": it cannot be negative. Using the default of 1440.");
|
|
63
64
|
this.config.holdLength = 1440;
|
|
64
65
|
}
|
|
65
66
|
this.config.holdLength = Math.min(1440, this.config.holdLength);
|
|
@@ -220,6 +221,9 @@ class NuHeatPlatform {
|
|
|
220
221
|
if (this.config.exposeScheduleSwitches) {
|
|
221
222
|
this.setupScheduleSwitch(deviceData);
|
|
222
223
|
}
|
|
224
|
+
if (this.config.exposeAwaySwitches) {
|
|
225
|
+
this.setupAwaySwitch(deviceData);
|
|
226
|
+
}
|
|
223
227
|
}));
|
|
224
228
|
}
|
|
225
229
|
setupScheduleSwitch(deviceData) {
|
|
@@ -243,6 +247,27 @@ class NuHeatPlatform {
|
|
|
243
247
|
entry.accessory.updateValues(deviceData);
|
|
244
248
|
}
|
|
245
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
|
+
}
|
|
246
271
|
cleanupRemovedAccessories() {
|
|
247
272
|
this.accessories.forEach((thisAccessory) => {
|
|
248
273
|
if (thisAccessory.existsInConfig !== true && thisAccessory.accessory) {
|
|
@@ -303,6 +328,11 @@ class NuHeatPlatform {
|
|
|
303
328
|
if (isUpdatableAccessory(scheduleAccessory?.accessory)) {
|
|
304
329
|
scheduleAccessory.accessory.updateValues(deviceData);
|
|
305
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
|
+
}
|
|
306
336
|
});
|
|
307
337
|
return true;
|
|
308
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;
|
package/lib/NuHeatModels.js
CHANGED
|
@@ -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
|
}
|