homebridge-nuheat2 1.3.0 → 1.5.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 +14 -1
- package/README.md +2 -2
- package/config.schema.json +1 -1
- package/index.js +18 -2
- package/lib/NuHeatAPI.js +29 -3
- package/lib/NuHeatGroup.js +4 -1
- package/lib/NuHeatModels.js +38 -12
- package/lib/NuHeatThermostat.js +7 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project should be documented in this file
|
|
4
4
|
|
|
5
|
-
## [
|
|
5
|
+
## [1.5.0] - 2026-11-17
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- 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
|
|
10
|
+
|
|
11
|
+
## [1.4.0] - 2026-10-17
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Report a requested `Off` back to HomeKit as `Off`: standby is now derived from a manual or hold mode parked at the minimum target temperature, so the Home app no longer bounces the tile back to `Heat` after turning a thermostat off
|
|
16
|
+
- Stop treating an auto schedule combined with a manual operating mode as `Off`; an auto schedule is always a scheduled run and is reported as `Auto`
|
|
17
|
+
- Fail gracefully when a Nuheat API or OAuth token response is not valid JSON instead of throwing an unhandled parse error
|
|
18
|
+
- Acknowledge failed away-mode switch writes and re-read the group so the switch reconciles with the real state instead of wedging the Home app
|
|
6
19
|
|
|
7
20
|
## [1.3.0] - 2026-10-15
|
|
8
21
|
|
package/README.md
CHANGED
|
@@ -116,9 +116,9 @@ Setting `enableThermostatModeControl` to `true` adds `Off` and `Auto` to the tar
|
|
|
116
116
|
| `Heat` | `PUT /api/v2/Mode/Hold` at the current target temperature, or `Mode/Manual` when `holdLength` is `1440` |
|
|
117
117
|
| `Auto` | `PUT /api/v2/Mode/Auto`, resuming the schedule |
|
|
118
118
|
|
|
119
|
-
Reads still come from the v1 API, which is the only version that reports `groupId` (needed for away mode) and `operatingMode`/`scheduleMode`. The plugin derives the HomeKit target state from those fields:
|
|
119
|
+
Reads still come from the v1 API, which is the only version that reports `groupId` (needed for away mode) and `operatingMode`/`scheduleMode`. The plugin derives the HomeKit target state from those fields: a manual or hold mode parked at the minimum target temperature is reported as `Off` (Nuheat's Standby — exactly how this plugin requests it), a warmer manual or hold setpoint is reported as `Heat`, and an auto schedule is reported as `Auto` regardless of the thermostat's operating mode.
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
Nuheat has no explicit "off" concept, so `Off` is implemented as a permanent manual setpoint at the minimum temperature, and reads recognize that state by the parked setpoint. Mode writes through the v2 mode API are reflected in subsequent v1 reads, so a requested `Off` reads back as `Off`.
|
|
122
122
|
|
|
123
123
|
### Device Discovery
|
|
124
124
|
|
package/config.schema.json
CHANGED
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"title": "Hold Length (minutes)",
|
|
106
106
|
"type": "integer",
|
|
107
107
|
"default": 1440,
|
|
108
|
-
"minimum":
|
|
108
|
+
"minimum": 1,
|
|
109
109
|
"maximum": 1440,
|
|
110
110
|
"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
111
|
},
|
package/index.js
CHANGED
|
@@ -50,7 +50,19 @@ class NuHeatPlatform {
|
|
|
50
50
|
}
|
|
51
51
|
this.config = config;
|
|
52
52
|
this.config.email = this.config.Email || this.config.email;
|
|
53
|
-
|
|
53
|
+
if (this.config.holdLength === undefined) {
|
|
54
|
+
this.config.holdLength = 1440;
|
|
55
|
+
}
|
|
56
|
+
else if (!(this.config.holdLength > 0)) {
|
|
57
|
+
// A hold length of 0 (or less) expires immediately, which the Nuheat
|
|
58
|
+
// API treats as a permanent hold. Refuse it and fall back to the
|
|
59
|
+
// default instead of silently converting it to 1440.
|
|
60
|
+
log.warn("Ignoring Hold Length " +
|
|
61
|
+
this.config.holdLength +
|
|
62
|
+
": it must be at least 1 minute. Using the default of 1440.");
|
|
63
|
+
this.config.holdLength = 1440;
|
|
64
|
+
}
|
|
65
|
+
this.config.holdLength = Math.min(1440, this.config.holdLength);
|
|
54
66
|
this.config.refresh = Math.max(30, this.config.refresh || 60);
|
|
55
67
|
this.api = api;
|
|
56
68
|
this.log = new logger_1.Logger(log, this.config.debug || false);
|
|
@@ -192,7 +204,11 @@ class NuHeatPlatform {
|
|
|
192
204
|
entry = { uuid };
|
|
193
205
|
this.accessories.push(entry);
|
|
194
206
|
}
|
|
195
|
-
entry.accessory = new NuHeatThermostat(this.log, deviceData,
|
|
207
|
+
entry.accessory = new NuHeatThermostat(this.log, deviceData,
|
|
208
|
+
// `holdLength` was normalized in the constructor; never re-apply a
|
|
209
|
+
// fallback here or an explicit 0 would silently become 1440 (a
|
|
210
|
+
// permanent hold).
|
|
211
|
+
this.config.holdLength, getPlatformAccessory(deviceAccessory), this.NuHeatAPI, Homebridge, this.account?.temperatureScale, this.config.enableThermostatModeControl === true);
|
|
196
212
|
entry.existsInConfig = true;
|
|
197
213
|
this.log.info("Loaded thermostat " +
|
|
198
214
|
deviceData.serialNumber +
|
package/lib/NuHeatAPI.js
CHANGED
|
@@ -290,7 +290,17 @@ class NuHeatAPI {
|
|
|
290
290
|
if (response.status === 204) {
|
|
291
291
|
return true;
|
|
292
292
|
}
|
|
293
|
-
|
|
293
|
+
let returnedData;
|
|
294
|
+
try {
|
|
295
|
+
returnedData = await response.json();
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
this.log.warn("NuHeatAPI: " +
|
|
299
|
+
this.describeRequest(callURL, callOptions) +
|
|
300
|
+
" returned a response that could not be parsed as JSON: " +
|
|
301
|
+
error);
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
294
304
|
if (options.normalize) {
|
|
295
305
|
if (options.normalizeArray && Array.isArray(returnedData)) {
|
|
296
306
|
return returnedData.map(options.normalize);
|
|
@@ -625,7 +635,15 @@ class NuHeatAPI {
|
|
|
625
635
|
return null;
|
|
626
636
|
}
|
|
627
637
|
this.tokenScope = redirectUrl.searchParams.get("scope") ?? "";
|
|
628
|
-
|
|
638
|
+
let token;
|
|
639
|
+
try {
|
|
640
|
+
token = (await response.json());
|
|
641
|
+
}
|
|
642
|
+
catch (error) {
|
|
643
|
+
this.log.warn("NuHeatAPI: The OAuth token response could not be parsed as JSON: " +
|
|
644
|
+
error);
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
629
647
|
this.log.debug("NuHeatAPI: OAuth access token received. Granted scopes: " +
|
|
630
648
|
(token.scope || this.tokenScope || "unknown") +
|
|
631
649
|
". Refresh token present: " +
|
|
@@ -646,7 +664,15 @@ class NuHeatAPI {
|
|
|
646
664
|
if (!response) {
|
|
647
665
|
return false;
|
|
648
666
|
}
|
|
649
|
-
|
|
667
|
+
let token;
|
|
668
|
+
try {
|
|
669
|
+
token = (await response.json());
|
|
670
|
+
}
|
|
671
|
+
catch (error) {
|
|
672
|
+
this.log.warn("NuHeatAPI: The refreshed OAuth token response could not be parsed as JSON: " +
|
|
673
|
+
error);
|
|
674
|
+
return false;
|
|
675
|
+
}
|
|
650
676
|
const previousRefreshToken = this.refreshToken;
|
|
651
677
|
this.accessToken = token.access_token;
|
|
652
678
|
this.accessTokenTimestamp = Date.now();
|
package/lib/NuHeatGroup.js
CHANGED
|
@@ -31,7 +31,10 @@ class NuHeatGroup {
|
|
|
31
31
|
const response = await this.NuHeatAPI.setAwayMode(this.deviceData.groupId ?? "", value);
|
|
32
32
|
if (!response) {
|
|
33
33
|
this.log.error("Error setting away mode", this.deviceData.groupName);
|
|
34
|
-
|
|
34
|
+
// Acknowledge the write so HomeKit does not wedge the switch, then
|
|
35
|
+
// re-read the group to reconcile the tile with the real state.
|
|
36
|
+
callback(null);
|
|
37
|
+
await this.updateAccessory();
|
|
35
38
|
}
|
|
36
39
|
else {
|
|
37
40
|
this.updateValues({ ...this.deviceData, awayMode: value });
|
package/lib/NuHeatModels.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TEMPERATURE_TYPE = exports.HEATING_MODE = exports.OPERATING_MODE = exports.SCHEDULE_MODE = void 0;
|
|
3
|
+
exports.STANDBY_SETPOINT_C = exports.TEMPERATURE_TYPE = exports.HEATING_MODE = exports.OPERATING_MODE = exports.SCHEDULE_MODE = void 0;
|
|
4
4
|
exports.isThermostatOnline = isThermostatOnline;
|
|
5
|
+
exports.fromNuHeatTemperature = fromNuHeatTemperature;
|
|
6
|
+
exports.isStandbySetpoint = isStandbySetpoint;
|
|
5
7
|
exports.deriveHeatingMode = deriveHeatingMode;
|
|
6
8
|
exports.normalizeAccount = normalizeAccount;
|
|
7
9
|
exports.normalizeGroup = normalizeGroup;
|
|
@@ -41,10 +43,29 @@ function isThermostatOnline(thermostat) {
|
|
|
41
43
|
}
|
|
42
44
|
return true;
|
|
43
45
|
}
|
|
46
|
+
/** The minimum NuHeat target temperature, which the plugin uses for standby. */
|
|
47
|
+
exports.STANDBY_SETPOINT_C = 10;
|
|
48
|
+
/** Converts a raw NuHeat temperature (e.g. `setPointTemp`) to Celsius. */
|
|
49
|
+
function fromNuHeatTemperature(raw) {
|
|
50
|
+
return (((raw - 33) / 56 + 33 - 32) * 5) / 9;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Standby is a manual or hold mode parked at the minimum target temperature,
|
|
54
|
+
* which is how this plugin requests it. Away mode reads back even lower, so
|
|
55
|
+
* anything at or below the standby setpoint counts.
|
|
56
|
+
*/
|
|
57
|
+
function isStandbySetpoint(setPointTemp) {
|
|
58
|
+
if (setPointTemp === undefined || setPointTemp === null) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
const celsius = fromNuHeatTemperature(Number(setPointTemp));
|
|
62
|
+
return Number.isFinite(celsius) && celsius <= exports.STANDBY_SETPOINT_C;
|
|
63
|
+
}
|
|
44
64
|
/**
|
|
45
|
-
* NuHeat has no "off". Standby is
|
|
46
|
-
*
|
|
47
|
-
* schedule
|
|
65
|
+
* NuHeat has no "off". Standby is a manual or hold mode parked at the minimum
|
|
66
|
+
* target temperature; a genuine manual setpoint change always reads back
|
|
67
|
+
* warmer, and an auto schedule is a scheduled run regardless of the
|
|
68
|
+
* thermostat's operating mode.
|
|
48
69
|
*/
|
|
49
70
|
function deriveHeatingMode(thermostat) {
|
|
50
71
|
if (!isThermostatOnline(thermostat)) {
|
|
@@ -52,20 +73,25 @@ function deriveHeatingMode(thermostat) {
|
|
|
52
73
|
}
|
|
53
74
|
const scheduleMode = Number(thermostat.scheduleMode);
|
|
54
75
|
if (scheduleMode === exports.SCHEDULE_MODE.HOLD) {
|
|
55
|
-
return
|
|
76
|
+
return isStandbySetpoint(thermostat.setPointTemp)
|
|
77
|
+
? exports.HEATING_MODE.OFF
|
|
78
|
+
: exports.HEATING_MODE.HOLD;
|
|
56
79
|
}
|
|
57
80
|
if (scheduleMode === exports.SCHEDULE_MODE.PERMANENT_HOLD) {
|
|
58
|
-
return
|
|
81
|
+
return isStandbySetpoint(thermostat.setPointTemp)
|
|
82
|
+
? exports.HEATING_MODE.OFF
|
|
83
|
+
: exports.HEATING_MODE.MANUAL;
|
|
59
84
|
}
|
|
60
85
|
if (scheduleMode === exports.SCHEDULE_MODE.AUTO) {
|
|
61
|
-
return
|
|
62
|
-
? exports.HEATING_MODE.OFF
|
|
63
|
-
: exports.HEATING_MODE.AUTO;
|
|
86
|
+
return exports.HEATING_MODE.AUTO;
|
|
64
87
|
}
|
|
65
88
|
// Unknown schedule mode: report whatever the hardware tells us.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
89
|
+
if (Number(thermostat.operatingMode) === exports.OPERATING_MODE.MANUAL) {
|
|
90
|
+
return isStandbySetpoint(thermostat.setPointTemp)
|
|
91
|
+
? exports.HEATING_MODE.OFF
|
|
92
|
+
: exports.HEATING_MODE.MANUAL;
|
|
93
|
+
}
|
|
94
|
+
return exports.HEATING_MODE.AUTO;
|
|
69
95
|
}
|
|
70
96
|
function normalizeAccount(account = {}) {
|
|
71
97
|
return {
|
package/lib/NuHeatThermostat.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
const NuHeatModels_1 = require("./NuHeatModels");
|
|
3
3
|
let Characteristic;
|
|
4
4
|
let ThermostatService;
|
|
5
|
-
const MIN_TARGET_TEMPERATURE_C = 10;
|
|
6
5
|
const MAX_TARGET_TEMPERATURE_C = 38;
|
|
7
6
|
class NuHeatThermostat {
|
|
8
7
|
log;
|
|
@@ -69,7 +68,7 @@ class NuHeatThermostat {
|
|
|
69
68
|
return;
|
|
70
69
|
}
|
|
71
70
|
this.log.info("NuHeat does not support an off mode. Setting the thermostat to its minimum target temperature instead.", this.deviceData.name);
|
|
72
|
-
const response = await this.NuHeatAPI.setHeatSetpoint(this.deviceData.serialNumber ?? "", this.toNuHeatTemperature(
|
|
71
|
+
const response = await this.NuHeatAPI.setHeatSetpoint(this.deviceData.serialNumber ?? "", this.toNuHeatTemperature(NuHeatModels_1.STANDBY_SETPOINT_C), this.holdLength);
|
|
73
72
|
if (!response) {
|
|
74
73
|
this.log.error("Error setting minimum target temperature for off request", this.deviceData.name);
|
|
75
74
|
callback(new Error("Error: setTargetHeatingCooling"));
|
|
@@ -91,7 +90,7 @@ class NuHeatThermostat {
|
|
|
91
90
|
const options = {};
|
|
92
91
|
if (value === OFF) {
|
|
93
92
|
mode = NuHeatModels_1.HEATING_MODE.OFF;
|
|
94
|
-
options.setPointTemp = this.toNuHeatTemperature(
|
|
93
|
+
options.setPointTemp = this.toNuHeatTemperature(NuHeatModels_1.STANDBY_SETPOINT_C);
|
|
95
94
|
this.log.info("Setting the thermostat to standby (minimum target temperature).", this.deviceData.name);
|
|
96
95
|
}
|
|
97
96
|
else if (value === AUTO) {
|
|
@@ -130,8 +129,8 @@ class NuHeatThermostat {
|
|
|
130
129
|
}
|
|
131
130
|
async setTargetTemperature(value, callback) {
|
|
132
131
|
this.log.info("Setting target temperature to " + value + " C", this.deviceData.name);
|
|
133
|
-
if (value <
|
|
134
|
-
value =
|
|
132
|
+
if (value < NuHeatModels_1.STANDBY_SETPOINT_C)
|
|
133
|
+
value = NuHeatModels_1.STANDBY_SETPOINT_C;
|
|
135
134
|
if (value > MAX_TARGET_TEMPERATURE_C)
|
|
136
135
|
value = MAX_TARGET_TEMPERATURE_C;
|
|
137
136
|
const heatSetPoint = this.toNuHeatTemperature(value);
|
|
@@ -174,8 +173,8 @@ class NuHeatThermostat {
|
|
|
174
173
|
.getCharacteristic(Characteristic.CurrentTemperature)
|
|
175
174
|
.updateValue(currentTemperature);
|
|
176
175
|
let setPointTemperature = Number(this.toHBTemperature(newValues.setPointTemp ?? 0));
|
|
177
|
-
if (setPointTemperature <
|
|
178
|
-
setPointTemperature =
|
|
176
|
+
if (setPointTemperature < NuHeatModels_1.STANDBY_SETPOINT_C) {
|
|
177
|
+
setPointTemperature = NuHeatModels_1.STANDBY_SETPOINT_C;
|
|
179
178
|
}
|
|
180
179
|
if (setPointTemperature > MAX_TARGET_TEMPERATURE_C) {
|
|
181
180
|
setPointTemperature = MAX_TARGET_TEMPERATURE_C;
|
|
@@ -211,7 +210,7 @@ class NuHeatThermostat {
|
|
|
211
210
|
return (((temperature * 9) / 5 + 32 - 33) * 56 + 33).toFixed(0);
|
|
212
211
|
}
|
|
213
212
|
toHBTemperature(temperature) {
|
|
214
|
-
return ((
|
|
213
|
+
return (0, NuHeatModels_1.fromNuHeatTemperature)(temperature).toFixed(1);
|
|
215
214
|
}
|
|
216
215
|
toHomeBridgeHeatingCoolingState(newValues) {
|
|
217
216
|
if (!this.enableThermostatModeControl) {
|