homebridge-warmup4ie-v2 2.0.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 +90 -0
- package/LICENSE +202 -0
- package/README.md +152 -0
- package/package.json +61 -0
- package/src/index.js +208 -0
- package/src/lib/state.js +24 -0
- package/src/lib/warmup4ie.js +200 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `homebridge-warmup4ie-v2` are documented here.
|
|
4
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
|
|
6
|
+
This package is a maintained fork of [`homebridge-warmup4ie`](https://github.com/NorthernMan54/homebridge-warmup4ie). The fork begins at version 2.0.0 (a tribute to the original 1.x lineage) and is published to npm as `homebridge-warmup4ie-v2`. Pre-2.0.0 history below is the upstream history, kept for context.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [2.0.0] — 2026-05-05
|
|
11
|
+
|
|
12
|
+
**First release of the maintained fork.** Restores the working hard-off that broke in upstream 0.1.0–0.1.1, replaces the deprecated `request` HTTP library with native `fetch`, adds a real test suite, and ships under the new npm name `homebridge-warmup4ie-v2`.
|
|
13
|
+
|
|
14
|
+
### Migration from `homebridge-warmup4ie`
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
sudo npm uninstall -g homebridge-warmup4ie
|
|
18
|
+
sudo npm install -g homebridge-warmup4ie-v2
|
|
19
|
+
sudo systemctl restart homebridge
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Your `config.json` does **not** need changes — the platform identifier (`"platform": "warmup4ie"`) is unchanged for compatibility.
|
|
23
|
+
|
|
24
|
+
### Why this fork exists
|
|
25
|
+
|
|
26
|
+
The upstream 0.1.0 PR ("Beta 0.1.0 - HB 2.0 support", Dec 2024) rewrote the API client from function-style to class-style. The rewrite quietly simplified two wire-format details that the Warmup cloud API silently rejects with `200 OK` + `{status:{result:"error"}}`:
|
|
27
|
+
|
|
28
|
+
- The `setModes locMode: "off"` body lost five required filler keys (`holEnd`, `holStart`, `holTemp`, `fixedTemp`, `geoMode`). HomeKit's "Off" command silently failed for ~5 months while users thought it worked.
|
|
29
|
+
- The `setOverride until` field switched from local time to UTC, breaking override durations by the local timezone offset.
|
|
30
|
+
|
|
31
|
+
Both regressions were verified byte-for-byte against the [Python reference impl](https://github.com/alex-0103/warmup4IE) and fixed in this release.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
- **`setRoomOff`** — restored the full filler `values` dict. The hard-off that worked in 0.0.14 works again. (Reminder: this is a **location-wide** off — the Warmup mobile app does the same call. The cloud API has no per-room hard-off.)
|
|
35
|
+
- **`setTargetTemperature` `until`** — back to local time.
|
|
36
|
+
- **API errors are surfaced** — `_sendRequest` now fails the callback when the response is `{status:{result:"error"}}`. Both upstream 0.0.14 and 0.1.1 silently treated that as success.
|
|
37
|
+
- **Per-accessory `room` snapshot was frozen at startup.** `updateStatus()` now refreshes `accessory.room` per poll, so `setTargetHeatingCooling`'s `runMode`-based logic sees fresh state.
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
- **Transport: `request` → native `fetch`.** Drops a 12-year-old deprecated dependency (`request` is unmaintained since 2020 and ships unfixed prototype-pollution / SSRF advisories). Native `fetch` is built into Node ≥18, so no new dep, no install-size cost. Behaviour preserved: same headers, same JSON body, same 10 s timeout (now via `AbortSignal.timeout`).
|
|
41
|
+
- **Polling consolidated.** Upstream had two timers running (`refresh` from the platform, `refresh/2` from the lib) — the API was being hit ~3× per refresh window. The lib timer was removed; the platform now fetches *and* pushes in a single tick at `refresh` seconds.
|
|
42
|
+
- **`SerialNumber` is now `warmup4ie-<roomId>`** instead of `<hostname>-<name>` — stable across host moves, matches HAP-NodeJS guidance on accessory identity.
|
|
43
|
+
- **`setPrimaryService(true)`** is used in place of direct `isPrimaryService = true` (per HAP-NodeJS v2 docs), with a property-assignment fallback for HB 1.x environments.
|
|
44
|
+
- **`updateStatus` refactored** — pure `deriveCurrentHeatingState` / `deriveTargetHeatingState` helpers extracted to `src/lib/state.js`, shared by the initial `getServices()` build and the polling path.
|
|
45
|
+
- **Multi-location accounts: first location only**, by design. Documented explicitly. The Python reference filters by name; we don't, because this plugin has no `location` config knob and adding one is out of scope here. If you need multiple locations on one account, run a second Homebridge child bridge.
|
|
46
|
+
|
|
47
|
+
### Removed
|
|
48
|
+
- **`request` dependency.** Replaced with native `fetch`.
|
|
49
|
+
- **Unused upstream dependencies:** `fakegato-history`, `homebridge-lib`, `moment`, `semver`. None had a live code path; `fakegato-history` was already commented out in upstream 0.1.1.
|
|
50
|
+
- **Dead code in `index.js`:** commented-out fakegato / CustomCharacteristics blocks; unused `storage` config option (was never wired up); unused `username` / `password` fields on the per-accessory object.
|
|
51
|
+
- **Dead public methods on `Warmup4IE`:** `setRoomOverride`, `setRoomFixed`, `_setRoomMode`, `pollDevices`, `destroy`. None had callers.
|
|
52
|
+
- **Unused constructor options** on `Warmup4IE` (`location`, `room`, `target_temp`, `setup_finished`).
|
|
53
|
+
|
|
54
|
+
### Added
|
|
55
|
+
- **`LICENSE` file** — Apache-2.0 boilerplate (the original repo declared the license but didn't include the file).
|
|
56
|
+
- **Full test suite** under `test/`:
|
|
57
|
+
- **Unit** (`test/unit/`): wire-format builders, state derivers (truth tables), `until` time formatting (TZ + DST + wraparound), `_fetch` error paths.
|
|
58
|
+
- **Integration** (`test/integration/`): full bootstrap chain, polling state propagation, error recovery, plugin loadtime / `registerPlatform` smoke.
|
|
59
|
+
- **Live** (`test/live/api.test.js`): opt-in via `WARMUP_LIVE_TEST=1`, real `api.warmup.com` calls; plus a destructive `setRoomOff/setRoomAuto` cycle gated behind `WARMUP_LIVE_DESTRUCTIVE=1`.
|
|
60
|
+
- **Fixtures** (`test/fixtures/`): sanitized JSON snapshots of API responses.
|
|
61
|
+
- **`QA_TESTS.md`** — manual pre-release checklist (~15 min) covering Home app smoke, single-room and multi-room control flows, regression sentinels, edge cases, and rollback.
|
|
62
|
+
- **CI** (`.github/workflows/ci.yml`) — lint + test + smoke on Node 18.20, 20.15, 22 for every push and PR.
|
|
63
|
+
- **Release** (`.github/workflows/release.yml`) — tag-driven (`v*`) publish to npm with provenance, plus a GitHub Release. Verifies the tag matches `package.json` version before publishing.
|
|
64
|
+
|
|
65
|
+
### Repository
|
|
66
|
+
- **npm name:** `homebridge-warmup4ie-v2` (new; original `homebridge-warmup4ie` is unaffected and still abandoned upstream).
|
|
67
|
+
- **GitHub:** `nookied/homebridge-warmup4ie` (this fork; `upstream` git remote intentionally not configured).
|
|
68
|
+
- **Author:** Karol Nowacki (this fork) + NorthernMan54 (original). Apache-2.0 preserved.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Upstream history (pre-fork)
|
|
73
|
+
|
|
74
|
+
The entries below are the upstream `NorthernMan54/homebridge-warmup4ie` history, kept here for context. They do not correspond to versions of *this* package — only to versions of the upstream package on npm.
|
|
75
|
+
|
|
76
|
+
### upstream 0.1.1 — 2024-12-14
|
|
77
|
+
|
|
78
|
+
Final upstream `package.json` bump on top of 0.1.0 beta after merging HB 2.0 support to `main`. No source changes since the merge commit. **`Off` control silently broken** (see "Why this fork exists" above).
|
|
79
|
+
|
|
80
|
+
### upstream 0.1.0 — 2024-12-13 (the breaking rewrite)
|
|
81
|
+
|
|
82
|
+
Wholesale rewrite of `lib/warmup4ie.js` from function-style to class-style ("Beta 0.1.0 - HB 2.0 support", PR #7). Added Homebridge 2.0 support, ESLint v9, Jest test sketch, and a CI workflow. Quietly introduced the two wire-format regressions documented above; the resulting plugin loads under HB 2.0 but cannot turn thermostats off and cannot accurately time overrides.
|
|
83
|
+
|
|
84
|
+
### upstream 0.0.14 — 2021-11-23
|
|
85
|
+
|
|
86
|
+
Last known-good upstream version. `Off` worked correctly here (full `setModes` body with all filler keys); overrides used local time. Crashed on Homebridge 2.0 + HAP v2 because of a transitive `fakegato-history` incompatibility (`Formats.DATA` undefined), but on HB 1.x it ran cleanly.
|
|
87
|
+
|
|
88
|
+
### upstream pre-0.0.14 — 2019–2021
|
|
89
|
+
|
|
90
|
+
Initial development sprint (June 2019, "Day 1"–"Day 7 - Beta ready"), iOS 13 fixes (Sept 2019), small patches (2019–2021). See upstream `git log` for details — commit messages are sparse ("Ooops", "Fix").
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2019-2024 NorthernMan54 (original homebridge-warmup4ie)
|
|
190
|
+
Copyright 2026 Karol Nowacki (homebridge-warmup4ie-v2 maintained fork)
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# homebridge-warmup4ie-v2
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/homebridge-warmup4ie-v2)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Homebridge plugin for **[Warmup 4iE](https://www.warmup.com/thermostats/smart/4ie)** underfloor-heating thermostats.
|
|
7
|
+
|
|
8
|
+
This is a **maintained fork** of [`homebridge-warmup4ie`](https://github.com/NorthernMan54/homebridge-warmup4ie) (NorthernMan54), which became broken at version 0.1.0–0.1.1 in late 2024 and has not been updated since. The original silently rejected the `Off` HomeKit command (location turn-off API was sending the wrong body) and overrode temperatures in UTC instead of local time. This fork restores the working behaviour, replaces the deprecated `request` HTTP library with native `fetch`, and adds a real test suite.
|
|
9
|
+
|
|
10
|
+
If you have `homebridge-warmup4ie` installed, **uninstall it first** before installing this package — see [Migration](#migration) below.
|
|
11
|
+
|
|
12
|
+
## Why this fork exists
|
|
13
|
+
|
|
14
|
+
The 0.1.0 rewrite of the original plugin (PR #7, "Beta 0.1.0 - HB 2.0 support") simplified two wire-format details that the Warmup cloud API silently rejects:
|
|
15
|
+
|
|
16
|
+
- The `setModes locMode: "off"` body lost five required filler keys (`holEnd`, `holStart`, `holTemp`, `fixedTemp`, `geoMode`). The API responds with `200 OK` + `{status:{result:"error"}}` — the plugin treated that as success, so HomeKit reported "Off" while the thermostats kept heating.
|
|
17
|
+
- The override `until` time switched from local-time `HH:MM` to UTC, making boost overrides expire at the wrong wall-clock time.
|
|
18
|
+
|
|
19
|
+
Both regressions were verified byte-for-byte against the [Python reference implementation](https://github.com/alex-0103/warmup4IE) and fixed in this fork's first release. See [CHANGELOG.md](CHANGELOG.md) for the full restoration story.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
sudo npm install -g homebridge-warmup4ie-v2
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or via the Homebridge UI: search for **homebridge-warmup4ie-v2** in the plugin browser.
|
|
28
|
+
|
|
29
|
+
To install straight from git instead of npm (e.g. to pin a specific commit):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
sudo npm install -g github:nookied/homebridge-warmup4ie
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
Add a platform entry to your Homebridge `config.json`:
|
|
38
|
+
|
|
39
|
+
```jsonc
|
|
40
|
+
{
|
|
41
|
+
"platforms": [
|
|
42
|
+
{
|
|
43
|
+
"platform": "warmup4ie",
|
|
44
|
+
"name": "WarmUP",
|
|
45
|
+
"username": "you@example.com",
|
|
46
|
+
"password": "your-my.warmup.com-password",
|
|
47
|
+
"refresh": 60,
|
|
48
|
+
"duration": 60
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
| Key | Required | Default | Notes |
|
|
55
|
+
|---|---|---|---|
|
|
56
|
+
| `platform` | yes | — | Must be exactly `"warmup4ie"` (the platform identifier — same as the original plugin, so existing configs migrate without edits) |
|
|
57
|
+
| `name` | yes | — | Display name in Homebridge logs |
|
|
58
|
+
| `username` | yes | — | Your my.warmup.com email |
|
|
59
|
+
| `password` | yes | — | Your my.warmup.com password |
|
|
60
|
+
| `refresh` | no | `60` | API polling interval, seconds |
|
|
61
|
+
| `duration` | no | `60` | Override duration, minutes — how long a manual temperature change stays active before the schedule resumes |
|
|
62
|
+
|
|
63
|
+
## Behaviour
|
|
64
|
+
|
|
65
|
+
### Temperature changes
|
|
66
|
+
Any temperature change in HomeKit creates a Warmup **override** lasting `duration` minutes. After that, the room returns to whatever schedule was active before.
|
|
67
|
+
|
|
68
|
+
### Modes
|
|
69
|
+
HomeKit thermostats expose four modes; this plugin only uses three:
|
|
70
|
+
|
|
71
|
+
| HomeKit | Action on Warmup |
|
|
72
|
+
|---|---|
|
|
73
|
+
| **Off** | Sends `setModes locMode=off` — turns off the **whole location** (see below). Same behaviour as the Warmup mobile app's "Off" button. |
|
|
74
|
+
| **Heat** | Resumes the room's program. If the room is already in `fixed` or `override` state, no-op (preserves the override). |
|
|
75
|
+
| **Auto** | Resumes the room's program (same as Heat). |
|
|
76
|
+
| **Cool** | Not used — Warmup is a heating-only system. |
|
|
77
|
+
|
|
78
|
+
### Off is location-wide, not per-room
|
|
79
|
+
The Warmup cloud API has no per-room hard-off operation — confirmed against the Python reference impl and the mobile app's wire traffic. If you have multiple rooms on one account, tapping "Off" on **any** room turns the whole location off. This is the API contract, not a plugin limitation. If you want a per-room "off" effect, set `Heat` mode and drop the temperature to a frost setpoint (~5°C); the room stops heating until you raise it again.
|
|
80
|
+
|
|
81
|
+
## Migration
|
|
82
|
+
|
|
83
|
+
If you're moving from the original `homebridge-warmup4ie`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
sudo npm uninstall -g homebridge-warmup4ie
|
|
87
|
+
sudo npm install -g homebridge-warmup4ie-v2
|
|
88
|
+
sudo systemctl restart homebridge # or: hb-service restart
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Your `config.json` does not need changes.** The platform identifier (`"platform": "warmup4ie"`) is unchanged for compatibility — only the npm package name differs.
|
|
92
|
+
|
|
93
|
+
If accessories appear duplicated after migration, clear Homebridge's cached accessories from the UI (Settings → Remove Single Cached Accessory) for the orphaned ones from the old plugin.
|
|
94
|
+
|
|
95
|
+
## Troubleshooting
|
|
96
|
+
|
|
97
|
+
### Plugin won't start, error mentions `fakegato-history`
|
|
98
|
+
You're still on `homebridge-warmup4ie@0.0.14` or older. Uninstall it (`sudo npm uninstall -g homebridge-warmup4ie`) and install this fork.
|
|
99
|
+
|
|
100
|
+
### "Off" doesn't actually stop the heat
|
|
101
|
+
On `homebridge-warmup4ie@0.1.0` or `0.1.1`? That version has the broken `setRoomOff` body. Switch to this fork.
|
|
102
|
+
|
|
103
|
+
### "Not Responding" in Home app after a control action
|
|
104
|
+
The Warmup API rejected the call (e.g. invalid credentials, expired token, server error). Check the Homebridge log for `Warmup API: ...` errors. This plugin surfaces API-level errors instead of swallowing them; that's intentional — the original plugin would silently report success.
|
|
105
|
+
|
|
106
|
+
### Multi-location accounts
|
|
107
|
+
This plugin uses the **first** location only (`locations[0].id`). If you have e.g. a primary residence + a holiday home on the same Warmup account, only the first one is exposed. Run a second Homebridge instance/child bridge with a different account to expose the other location.
|
|
108
|
+
|
|
109
|
+
### Live API debugging
|
|
110
|
+
```bash
|
|
111
|
+
DEBUG=warmup4ie* sudo -E systemctl restart homebridge
|
|
112
|
+
sudo journalctl -u homebridge -f
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
git clone https://github.com/nookied/homebridge-warmup4ie.git
|
|
119
|
+
cd homebridge-warmup4ie
|
|
120
|
+
npm install
|
|
121
|
+
npm run lint # ESLint
|
|
122
|
+
npm test # Jest — unit + integration (no network)
|
|
123
|
+
npm run watch # Run plugin against test/hbConfig sandbox
|
|
124
|
+
|
|
125
|
+
WARMUP_LIVE_TEST=1 \
|
|
126
|
+
WARMUP_USERNAME=you@example.com \
|
|
127
|
+
WARMUP_PASSWORD=... \
|
|
128
|
+
npm test # Adds the live-API test suite
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
See [QA_TESTS.md](QA_TESTS.md) for the manual pre-release checklist.
|
|
132
|
+
|
|
133
|
+
## Versioning
|
|
134
|
+
|
|
135
|
+
This fork starts at **2.0.0** as a tribute to the original v1 lineage. From here, the fork follows [Semantic Versioning](https://semver.org/):
|
|
136
|
+
|
|
137
|
+
| Bump | When |
|
|
138
|
+
|---|---|
|
|
139
|
+
| **MAJOR** (`X.0.0`) | Breaking change to config keys or HomeKit accessory shape |
|
|
140
|
+
| **MINOR** (`X.Y.0`) | New feature (e.g. multi-location config, new HomeKit service) |
|
|
141
|
+
| **PATCH** (`X.Y.Z`) | Bug fix, dependency bump, doc-only change |
|
|
142
|
+
|
|
143
|
+
Releases are tag-driven: `npm version patch && git push --follow-tags` triggers the publish workflow.
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
[Apache 2.0](LICENSE). Copyright 2019–2024 NorthernMan54 (original) + 2026 Karol Nowacki (this fork). The Apache-2.0 license is preserved from the original.
|
|
148
|
+
|
|
149
|
+
## Credits
|
|
150
|
+
|
|
151
|
+
- **NorthernMan54** — original `homebridge-warmup4ie` (2019), the basis for this fork.
|
|
152
|
+
- **alex-0103** — [`warmup4IE`](https://github.com/alex-0103/warmup4IE) Python reference implementation, the source of truth for the Warmup cloud API wire format.
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "homebridge-warmup4ie-v2",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Homebridge plugin for Warmup 4iE underfloor-heating thermostats. Maintained fork of homebridge-warmup4ie with fixes for Homebridge 2.0 and the broken Off control in 0.1.0–0.1.1.",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"lint": "eslint --max-warnings=0 .",
|
|
8
|
+
"lint:fix": "eslint --fix --max-warnings=0 .",
|
|
9
|
+
"watch": "nodemon",
|
|
10
|
+
"test": "jest --detectOpenHandles",
|
|
11
|
+
"test-coverage": "jest --coverage",
|
|
12
|
+
"smoke": "node -e \"const m = require('./src/index.js'); if (typeof m !== 'function') { process.exit(1); }\""
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/nookied/homebridge-warmup4ie.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"homebridge-plugin",
|
|
20
|
+
"homebridge-warmup4ie",
|
|
21
|
+
"warmup4ie",
|
|
22
|
+
"warmup",
|
|
23
|
+
"thermostat",
|
|
24
|
+
"underfloor-heating",
|
|
25
|
+
"homekit"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"homebridge": "^1.6.0 || ^2.0.0-beta.0",
|
|
29
|
+
"node": "^18.20.4 || ^20.15.1 || ^22.0.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"debug": "^4.4.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@eslint/js": "^9.14.0",
|
|
36
|
+
"eslint": "^8.57.1",
|
|
37
|
+
"eslint-plugin-format": "^0.1.2",
|
|
38
|
+
"eslint-plugin-jest": "^28.8.3",
|
|
39
|
+
"globals": "^15.12.0",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"nodemon": "^3.1.7"
|
|
42
|
+
},
|
|
43
|
+
"author": "Karol Nowacki (fork of NorthernMan54/homebridge-warmup4ie)",
|
|
44
|
+
"license": "Apache-2.0",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/nookied/homebridge-warmup4ie/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/nookied/homebridge-warmup4ie#readme",
|
|
49
|
+
"nodemonConfig": {
|
|
50
|
+
"watch": [
|
|
51
|
+
"src"
|
|
52
|
+
],
|
|
53
|
+
"ext": "js",
|
|
54
|
+
"ignore": [],
|
|
55
|
+
"exec": "DEBUG=HAP-NodeJS*,warmup4ie* ~/npm/bin/homebridge -U ./test/hbConfig -I -Q -T -D -P .",
|
|
56
|
+
"signal": "SIGTERM",
|
|
57
|
+
"env": {
|
|
58
|
+
"NODE_OPTIONS": "--trace-warnings"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Homebridge platform for Warmup 4iE underfloor-heating thermostats.
|
|
2
|
+
// Each Warmup "room" is exposed as a HomeKit Thermostat (primary) plus a
|
|
3
|
+
// paired TemperatureSensor for the air-temp probe. Static accessory platform
|
|
4
|
+
// (legacy `accessories(callback)` flow) — Homebridge v2 still supports this.
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const debug = require('debug')('warmup4ie');
|
|
9
|
+
const { Warmup4IE } = require('./lib/warmup4ie');
|
|
10
|
+
const { deriveCurrentHeatingState, deriveTargetHeatingState } = require('./lib/state');
|
|
11
|
+
const { version: PLUGIN_VERSION, name: PLUGIN_NAME } = require('../package.json');
|
|
12
|
+
|
|
13
|
+
let Service, Characteristic;
|
|
14
|
+
const myAccessories = [];
|
|
15
|
+
let thermostats;
|
|
16
|
+
|
|
17
|
+
module.exports = function (homebridge) {
|
|
18
|
+
Service = homebridge.hap.Service;
|
|
19
|
+
Characteristic = homebridge.hap.Characteristic;
|
|
20
|
+
|
|
21
|
+
// First arg matches the npm package name (Homebridge uses it for plugin
|
|
22
|
+
// disambiguation). Second arg is the platform identifier users put in
|
|
23
|
+
// their config.json — kept as `warmup4ie` for migration compatibility.
|
|
24
|
+
homebridge.registerPlatform(PLUGIN_NAME, 'warmup4ie', warmup4iePlatform);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function warmup4iePlatform(log, config /* , api */) {
|
|
28
|
+
this.username = config.username;
|
|
29
|
+
this.password = config.password;
|
|
30
|
+
this.refresh = config.refresh || 60; // polling interval, seconds
|
|
31
|
+
this.duration = config.duration || 60; // override duration, minutes
|
|
32
|
+
this.log = log;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
warmup4iePlatform.prototype = {
|
|
36
|
+
accessories: function (callback) {
|
|
37
|
+
this.log('Logging into warmup4ie...');
|
|
38
|
+
|
|
39
|
+
thermostats = new Warmup4IE(this, (err, rooms) => {
|
|
40
|
+
if (err) {
|
|
41
|
+
this.log.error('Warmup login/initial fetch failed:', err.message);
|
|
42
|
+
callback([]);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.log('Found %s room(s)', rooms.length);
|
|
46
|
+
rooms.forEach((room) => {
|
|
47
|
+
this.log('Adding', room.roomName);
|
|
48
|
+
myAccessories.push(new Warmup4ieAccessory(this, room.roomName, thermostats.room[room.roomId]));
|
|
49
|
+
});
|
|
50
|
+
callback(myAccessories);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
setInterval(() => {
|
|
54
|
+
thermostats.getStatus((err) => {
|
|
55
|
+
if (err) {
|
|
56
|
+
this.log.error('Warmup poll failed:', err.message);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
thermostats.room.forEach((room) => {
|
|
60
|
+
if (room) updateStatus(room);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}, this.refresh * 1000);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function getAccessory(accessories, roomId) {
|
|
68
|
+
return accessories.find((accessory) => accessory.roomId === roomId);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function updateStatus(room) {
|
|
72
|
+
const acc = getAccessory(myAccessories, room.roomId);
|
|
73
|
+
if (!acc) return;
|
|
74
|
+
|
|
75
|
+
// Refresh the per-accessory snapshot so .runMode-dependent setters see fresh state.
|
|
76
|
+
acc.room = room;
|
|
77
|
+
|
|
78
|
+
const targetTemperature = (room.targetTemp > room.minTemp ? room.targetTemp : room.minTemp);
|
|
79
|
+
acc.thermostatService
|
|
80
|
+
.getCharacteristic(Characteristic.TargetTemperature)
|
|
81
|
+
.updateValue(Number(targetTemperature / 10));
|
|
82
|
+
|
|
83
|
+
acc.thermostatService
|
|
84
|
+
.getCharacteristic(Characteristic.CurrentTemperature)
|
|
85
|
+
.updateValue(Number(room.currentTemp / 10));
|
|
86
|
+
|
|
87
|
+
acc.thermostatService
|
|
88
|
+
.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
|
89
|
+
.updateValue(deriveCurrentHeatingState(room));
|
|
90
|
+
|
|
91
|
+
acc.thermostatService
|
|
92
|
+
.getCharacteristic(Characteristic.TargetHeatingCoolingState)
|
|
93
|
+
.updateValue(deriveTargetHeatingState(room));
|
|
94
|
+
|
|
95
|
+
acc.temperatureService
|
|
96
|
+
.getCharacteristic(Characteristic.CurrentTemperature)
|
|
97
|
+
.updateValue(Number(room.airTemp / 10));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function Warmup4ieAccessory(that, name, room) {
|
|
101
|
+
this.log = that.log;
|
|
102
|
+
this.log('Adding warmup4ie Device', name);
|
|
103
|
+
this.name = name;
|
|
104
|
+
this.room = room;
|
|
105
|
+
this.roomId = room.roomId;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
Warmup4ieAccessory.prototype = {
|
|
109
|
+
|
|
110
|
+
setTargetHeatingCooling: function (value, callback) {
|
|
111
|
+
this.log('Setting system switch for', this.name, 'to', value);
|
|
112
|
+
switch (value) {
|
|
113
|
+
case 0: // Off (location-wide — see lib note)
|
|
114
|
+
thermostats.setRoomOff(this.roomId, (err, json) => {
|
|
115
|
+
if (err) return callback(err);
|
|
116
|
+
debug('setRoomOff - Result', json);
|
|
117
|
+
callback(null);
|
|
118
|
+
});
|
|
119
|
+
break;
|
|
120
|
+
case 1: // Heat — keep override/fixed if already set, otherwise resume schedule
|
|
121
|
+
if (this.room.runMode === 'fixed' || this.room.runMode === 'override') {
|
|
122
|
+
callback(null);
|
|
123
|
+
} else {
|
|
124
|
+
thermostats.setRoomAuto(this.roomId, (err, json) => {
|
|
125
|
+
if (err) return callback(err);
|
|
126
|
+
debug('setRoomAuto - Result', json);
|
|
127
|
+
callback(null);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case 3: // Auto
|
|
132
|
+
thermostats.setRoomAuto(this.roomId, (err, json) => {
|
|
133
|
+
if (err) return callback(err);
|
|
134
|
+
debug('setRoomAuto - Result', json);
|
|
135
|
+
callback(null);
|
|
136
|
+
});
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
callback(null);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
setTargetTemperature: function (value, callback) {
|
|
144
|
+
this.log('Setting target temperature for', this.name, 'to', value + '°');
|
|
145
|
+
thermostats.setTargetTemperature(this.roomId, value, (err, json) => {
|
|
146
|
+
if (err) return callback(err);
|
|
147
|
+
debug('setTargetTemperature - Result', json);
|
|
148
|
+
callback(null);
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
getServices: function () {
|
|
153
|
+
const informationService = new Service.AccessoryInformation()
|
|
154
|
+
.setCharacteristic(Characteristic.Manufacturer, 'warmup4ie')
|
|
155
|
+
// Stable serial: roomId is unique per Warmup account and survives host moves.
|
|
156
|
+
.setCharacteristic(Characteristic.SerialNumber, `warmup4ie-${this.roomId}`)
|
|
157
|
+
.setCharacteristic(Characteristic.FirmwareRevision, PLUGIN_VERSION);
|
|
158
|
+
|
|
159
|
+
this.temperatureService = new Service.TemperatureSensor(this.name + ' Air');
|
|
160
|
+
this.temperatureService
|
|
161
|
+
.getCharacteristic(Characteristic.CurrentTemperature)
|
|
162
|
+
.setProps({ minValue: -100, maxValue: 100 })
|
|
163
|
+
.updateValue(Number(this.room.airTemp / 10));
|
|
164
|
+
|
|
165
|
+
this.thermostatService = new Service.Thermostat(this.name);
|
|
166
|
+
if (typeof this.thermostatService.setPrimaryService === 'function') {
|
|
167
|
+
this.thermostatService.setPrimaryService(true);
|
|
168
|
+
} else {
|
|
169
|
+
this.thermostatService.isPrimaryService = true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
this.thermostatService
|
|
173
|
+
.getCharacteristic(Characteristic.TargetHeatingCoolingState)
|
|
174
|
+
.setProps({ validValues: [0, 1, 3] })
|
|
175
|
+
.on('set', this.setTargetHeatingCooling.bind(this));
|
|
176
|
+
|
|
177
|
+
this.thermostatService
|
|
178
|
+
.getCharacteristic(Characteristic.TargetTemperature)
|
|
179
|
+
.setProps({
|
|
180
|
+
minValue: this.room.minTemp / 10,
|
|
181
|
+
maxValue: this.room.maxTemp / 10
|
|
182
|
+
})
|
|
183
|
+
.on('set', this.setTargetTemperature.bind(this));
|
|
184
|
+
|
|
185
|
+
this.thermostatService
|
|
186
|
+
.getCharacteristic(Characteristic.CurrentTemperature)
|
|
187
|
+
.setProps({ minValue: -100, maxValue: 100 });
|
|
188
|
+
|
|
189
|
+
const targetTemperature = (this.room.targetTemp > this.room.minTemp ? this.room.targetTemp : this.room.minTemp);
|
|
190
|
+
this.thermostatService
|
|
191
|
+
.getCharacteristic(Characteristic.TargetTemperature)
|
|
192
|
+
.updateValue(Number(targetTemperature / 10));
|
|
193
|
+
|
|
194
|
+
this.thermostatService
|
|
195
|
+
.getCharacteristic(Characteristic.CurrentTemperature)
|
|
196
|
+
.updateValue(Number(this.room.currentTemp / 10));
|
|
197
|
+
|
|
198
|
+
this.thermostatService
|
|
199
|
+
.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
|
200
|
+
.updateValue(deriveCurrentHeatingState(this.room));
|
|
201
|
+
|
|
202
|
+
this.thermostatService
|
|
203
|
+
.getCharacteristic(Characteristic.TargetHeatingCoolingState)
|
|
204
|
+
.updateValue(deriveTargetHeatingState(this.room));
|
|
205
|
+
|
|
206
|
+
return [informationService, this.thermostatService, this.temperatureService];
|
|
207
|
+
}
|
|
208
|
+
};
|
package/src/lib/state.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Pure mappings from Warmup `room` payloads to HAP HeatingCoolingState values.
|
|
4
|
+
// Extracted so unit tests can exercise the truth table without spinning up
|
|
5
|
+
// HAP-NodeJS. Numeric values are HAP characteristic values:
|
|
6
|
+
// CurrentHeatingCoolingState: 0=OFF, 1=HEAT, 2=COOL (we only emit 0 and 1)
|
|
7
|
+
// TargetHeatingCoolingState: 0=OFF, 1=HEAT, 2=COOL, 3=AUTO (we only emit 0, 1, 3)
|
|
8
|
+
|
|
9
|
+
function deriveCurrentHeatingState(room) {
|
|
10
|
+
if (room.runMode === 'off') return 0;
|
|
11
|
+
return room.currentTemp < room.targetTemp ? 1 : 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function deriveTargetHeatingState(room) {
|
|
15
|
+
switch (room.runMode) {
|
|
16
|
+
case 'off': return 0;
|
|
17
|
+
case 'fixed':
|
|
18
|
+
case 'override': return 1;
|
|
19
|
+
case 'schedule': return 3;
|
|
20
|
+
default: return 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = { deriveCurrentHeatingState, deriveTargetHeatingState };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('debug')('warmup4ie:lib');
|
|
4
|
+
|
|
5
|
+
const TOKEN_URL = 'https://api.warmup.com/apps/app/v1';
|
|
6
|
+
const APP_TOKEN = 'M=;He<Xtg"$}4N%5k{$:PD+WA"]D<;#PriteY|VTuA>_iyhs+vA"4lic{6-LqNM:';
|
|
7
|
+
const REQUEST_HEADERS = {
|
|
8
|
+
'user-agent': 'WARMUP_APP',
|
|
9
|
+
'accept-encoding': 'br, gzip, deflate',
|
|
10
|
+
'accept': '*/*',
|
|
11
|
+
'content-type': 'application/json',
|
|
12
|
+
'app-token': APP_TOKEN,
|
|
13
|
+
'app-version': '1.8.1',
|
|
14
|
+
'accept-language': 'de-de'
|
|
15
|
+
};
|
|
16
|
+
const REQUEST_TIMEOUT_MS = 10000;
|
|
17
|
+
|
|
18
|
+
let WarmupAccessToken = null;
|
|
19
|
+
let LocId = null;
|
|
20
|
+
|
|
21
|
+
class Warmup4IE {
|
|
22
|
+
constructor(options, callback) {
|
|
23
|
+
this._username = options.username;
|
|
24
|
+
this._password = options.password;
|
|
25
|
+
this._duration = options.duration;
|
|
26
|
+
this.room = [];
|
|
27
|
+
|
|
28
|
+
this._bootstrap().then(
|
|
29
|
+
(rooms) => callback(null, rooms),
|
|
30
|
+
(err) => callback(err)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async _bootstrap() {
|
|
35
|
+
await this._generateAccessToken();
|
|
36
|
+
await this._getLocations();
|
|
37
|
+
return this._fetchRooms();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Public callback-style transport. Stubbed by tests.
|
|
41
|
+
_sendRequest(body, callback) {
|
|
42
|
+
this._fetch(body).then(
|
|
43
|
+
(json) => callback(null, json),
|
|
44
|
+
(err) => {
|
|
45
|
+
console.error(err);
|
|
46
|
+
callback(err);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async _fetch(body) {
|
|
52
|
+
let response;
|
|
53
|
+
try {
|
|
54
|
+
response = await fetch(TOKEN_URL, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: REQUEST_HEADERS,
|
|
57
|
+
body: JSON.stringify(body),
|
|
58
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
59
|
+
});
|
|
60
|
+
} catch (ex) {
|
|
61
|
+
throw new Error(`Warmup network error: ${ex.message}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw new Error(`Warmup HTTP ${response.status}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const text = await response.text();
|
|
69
|
+
let json;
|
|
70
|
+
try {
|
|
71
|
+
json = JSON.parse(text);
|
|
72
|
+
} catch (ex) {
|
|
73
|
+
throw new Error(`Warmup JSON parse error: ${ex.message}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// The Warmup API returns 200 with `{status:{result:"error",...}}` on rejection.
|
|
77
|
+
if (json.status && json.status.result !== 'success') {
|
|
78
|
+
const msg = json.message || json.status.message || JSON.stringify(json.status);
|
|
79
|
+
throw new Error(`Warmup API: ${msg}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return json;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async _generateAccessToken() {
|
|
86
|
+
const json = await this._fetch({
|
|
87
|
+
request: {
|
|
88
|
+
email: this._username,
|
|
89
|
+
password: this._password,
|
|
90
|
+
method: 'userLogin',
|
|
91
|
+
appId: 'WARMUP-APP-V001'
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
WarmupAccessToken = json.response.token;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// By design: multi-location accounts use the first location only. The Warmup
|
|
98
|
+
// app does the same when no location is explicitly selected. If you need a
|
|
99
|
+
// second location, run a second Homebridge child bridge with another account.
|
|
100
|
+
async _getLocations() {
|
|
101
|
+
if (!WarmupAccessToken) throw new Error('Missing access token.');
|
|
102
|
+
|
|
103
|
+
const json = await this._fetch({
|
|
104
|
+
account: { email: this._username, token: WarmupAccessToken },
|
|
105
|
+
request: { method: 'getLocations' }
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const first = json.response.locations && json.response.locations[0];
|
|
109
|
+
if (!first) throw new Error('No locations on Warmup account.');
|
|
110
|
+
LocId = first.id;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async _fetchRooms() {
|
|
114
|
+
if (!LocId || !WarmupAccessToken) throw new Error('Missing LocId or access token.');
|
|
115
|
+
|
|
116
|
+
const json = await this._fetch({
|
|
117
|
+
account: { email: this._username, token: WarmupAccessToken },
|
|
118
|
+
request: { method: 'getRooms', locId: LocId }
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const rooms = json.response.rooms || [];
|
|
122
|
+
rooms.forEach((room) => {
|
|
123
|
+
this.room[room.roomId] = room;
|
|
124
|
+
});
|
|
125
|
+
return rooms;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
getStatus(callback) {
|
|
129
|
+
this._fetchRooms().then(
|
|
130
|
+
(rooms) => callback(null, rooms),
|
|
131
|
+
(err) => callback(err)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
setTargetTemperature(roomId, value, callback) {
|
|
136
|
+
// `until` is local-time HH:MM. The Warmup app sends local time; UTC here makes
|
|
137
|
+
// the override expire at the wrong wall-clock time (off by the timezone offset).
|
|
138
|
+
const end = new Date(Date.now() + this._duration * 60000);
|
|
139
|
+
const until = `${String(end.getHours()).padStart(2, '0')}:${String(end.getMinutes()).padStart(2, '0')}`;
|
|
140
|
+
|
|
141
|
+
const body = {
|
|
142
|
+
account: { email: this._username, token: WarmupAccessToken },
|
|
143
|
+
request: {
|
|
144
|
+
method: 'setOverride',
|
|
145
|
+
rooms: [roomId],
|
|
146
|
+
type: 3,
|
|
147
|
+
temp: parseInt(value * 10, 10),
|
|
148
|
+
until
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
debug('setTargetTemperature', JSON.stringify(body));
|
|
153
|
+
this.room[roomId] = null;
|
|
154
|
+
this._sendRequest(body, callback);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
setRoomAuto(roomId, callback) {
|
|
158
|
+
const body = {
|
|
159
|
+
account: { email: this._username, token: WarmupAccessToken },
|
|
160
|
+
request: {
|
|
161
|
+
method: 'setProgramme',
|
|
162
|
+
roomId,
|
|
163
|
+
roomMode: 'prog'
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
this.room[roomId] = null;
|
|
168
|
+
this._sendRequest(body, callback);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Hard-off — the Warmup mobile app does this exact same call when you turn a
|
|
172
|
+
// thermostat off, which is location-wide (`locMode: off`). There is no
|
|
173
|
+
// per-room hard-off in the Warmup API; this is the documented behaviour.
|
|
174
|
+
// Filler keys (`holEnd`, `holStart`, `holTemp`, `fixedTemp`, `geoMode`) are
|
|
175
|
+
// *required* — without them the API returns 200 OK with a JSON error body
|
|
176
|
+
// and the thermostats never receive the command. Match the Python reference
|
|
177
|
+
// body byte-for-byte (alex-0103/warmup4IE).
|
|
178
|
+
setRoomOff(roomId, callback) {
|
|
179
|
+
const body = {
|
|
180
|
+
account: { email: this._username, token: WarmupAccessToken },
|
|
181
|
+
request: {
|
|
182
|
+
method: 'setModes',
|
|
183
|
+
values: {
|
|
184
|
+
holEnd: '-',
|
|
185
|
+
fixedTemp: '',
|
|
186
|
+
holStart: '-',
|
|
187
|
+
geoMode: '0',
|
|
188
|
+
holTemp: '-',
|
|
189
|
+
locId: LocId,
|
|
190
|
+
locMode: 'off'
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
this.room[roomId] = null;
|
|
196
|
+
this._sendRequest(body, callback);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
module.exports = { Warmup4IE };
|