@avantics/node-red-home-automation 4.0.2 → 4.0.3

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/README.md CHANGED
@@ -200,11 +200,20 @@ also attaches the package tarball and its SHA-256 checksum. Install a downloaded
200
200
  tarball through **Manage palette → Install → Upload module**, or with:
201
201
 
202
202
  ```sh
203
- npm install /path/to/avantics-node-red-home-automation-4.0.2.tgz
203
+ npm install /path/to/avantics-node-red-home-automation-4.0.3.tgz
204
204
  ```
205
205
 
206
206
  Add the installed nodes from the **home automation** section of the Node-RED palette, then configure the room, device hosts, MQTT topics, source mappings, and timing limits for your deployment.
207
207
 
208
+ ### 4.0.3
209
+
210
+ Fixes the theatre state flapping on every scheduled refresh: with an activity
211
+ settled and ready, backlighting and room lighting reported themselves as
212
+ confirming while they re-read their devices, so the theatre published
213
+ `unknown` and back, and counted drift each time. A refresh of a ready target
214
+ now re-reads it without leaving ready, as the display, receiver and source
215
+ already did. A target that really changes on its own still counts as drift.
216
+
208
217
  ### 4.0.2
209
218
 
210
219
  Fixes the display controller switching the TV off before the projector was
@@ -307,6 +307,7 @@ function transitionActivityLighting(saved, msg, suppliedConfig = {}, nowValue =
307
307
  // nothing desired (it started with nothing saved): adopt them, and observe
308
308
  // below as at startup (see adopted-request.ts). Which lights it held is
309
309
  // unknown, so the next activity releases every light it holds.
310
+ let answerWithReading = false;
310
311
  const adoptable = event.kind === "refresh" ? (0, adopted_request_1.adoptableRefresh)(event, state) : null;
311
312
  const adopted = adoptable !== null && event.kind === "refresh" && typeof event.profile === "string" && Object.hasOwn(config.profiles, event.profile);
312
313
  if (adopted && event.kind === "refresh") {
@@ -348,6 +349,15 @@ function transitionActivityLighting(saved, msg, suppliedConfig = {}, nowValue =
348
349
  fail("confirmation-timeout");
349
350
  }
350
351
  }
352
+ else if (event.kind === "refresh" && state.desired && state.phase === "ready" && !state.pending &&
353
+ profileFor(state, config).targets.length > 0) {
354
+ // A settled, ready profile is re-read without leaving ready, as the
355
+ // display, source and receiver are: its target state follows the
356
+ // readings, which reconcile as any reading after ready does.
357
+ commands.push(commandFor(state, config, "observe", 0));
358
+ answerWithReading = true;
359
+ trace("refresh", "observing", "ready", { profile: state.desired.profile });
360
+ }
351
361
  else if (event.kind === "startup" || event.kind === "refresh") {
352
362
  state.observed = {};
353
363
  state.pending = null;
@@ -381,7 +391,7 @@ function transitionActivityLighting(saved, msg, suppliedConfig = {}, nowValue =
381
391
  state.phase = "manual_override";
382
392
  trace("command", "withheld", adopted_request_1.ADOPTED_MISMATCH);
383
393
  }
384
- if (state.desired) {
394
+ if (state.desired && !answerWithReading) {
385
395
  const manual = state.phase === "manual_override";
386
396
  const theatre = (0, target_state_1.targetStateEvent)({
387
397
  target: "lighting",
@@ -180,6 +180,7 @@ function transitionBacklighting(saved, msg, suppliedConfig = {}, nowValue = new
180
180
  // A refresh with the activity's wanted values, reaching a node with
181
181
  // nothing desired (it started with nothing saved): adopt them, and observe
182
182
  // below as at startup (see adopted-request.ts).
183
+ let answerWithReading = false;
183
184
  const adoptable = event.kind === "refresh" ? (0, adopted_request_1.adoptableRefresh)(event, state) : null;
184
185
  if (adoptable && event.kind === "refresh" && typeof event.power === "string" && Object.hasOwn(POWERS, event.power)) {
185
186
  state.desired = { ...adoptable, power: event.power, requestedAt: now.toISOString() };
@@ -228,6 +229,14 @@ function transitionBacklighting(saved, msg, suppliedConfig = {}, nowValue = new
228
229
  trace("command", "emitted", null, { operation: "observe", power: state.desired.power });
229
230
  }
230
231
  }
232
+ else if (event.kind === "refresh" && state.desired && state.phase === "ready" && !state.pending) {
233
+ // A settled, ready target is re-read without leaving ready, as the
234
+ // display, source and receiver are: its target state follows the
235
+ // reading, which classifies as any reading after ready does.
236
+ commands.push(commandFor(state, "observe", 0));
237
+ answerWithReading = true;
238
+ trace("refresh", "observing", "ready", { power: state.desired.power });
239
+ }
231
240
  else if (event.kind === "startup" || event.kind === "refresh") {
232
241
  state.observed = null;
233
242
  state.pending = null;
@@ -258,7 +267,7 @@ function transitionBacklighting(saved, msg, suppliedConfig = {}, nowValue = new
258
267
  state.phase = "manual_override";
259
268
  trace("command", "withheld", adopted_request_1.ADOPTED_MISMATCH);
260
269
  }
261
- if (state.desired) {
270
+ if (state.desired && !answerWithReading) {
262
271
  const theatre = (0, target_state_1.targetStateEvent)({
263
272
  target: "backlighting",
264
273
  requestId: state.desired.requestId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avantics/node-red-home-automation",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "Deterministic home automation components for Node-RED",
5
5
  "keywords": [
6
6
  "node-red",