smart-home-engine 1.53.0 → 1.53.2

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.
@@ -1,4 +1,4 @@
1
- import{m as O}from"./monaco-langs-DKJI_o9J.js";import{t as I}from"./index-COKTfw7g.js";/*!-----------------------------------------------------------------------------
1
+ import{m as O}from"./monaco-langs-DKJI_o9J.js";import{t as I}from"./index-lCqN_GjH.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -175,10 +175,10 @@
175
175
  }
176
176
  })();
177
177
  </script>
178
- <script type="module" crossorigin src="/assets/index-COKTfw7g.js"></script>
178
+ <script type="module" crossorigin src="/assets/index-lCqN_GjH.js"></script>
179
179
  <link rel="modulepreload" crossorigin href="/assets/monaco-langs-DKJI_o9J.js">
180
180
  <link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
181
- <link rel="stylesheet" crossorigin href="/assets/index-x3Sn9IKo.css">
181
+ <link rel="stylesheet" crossorigin href="/assets/index-BsO7OQRT.css">
182
182
  </head>
183
183
  <body>
184
184
  <div id="app"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-home-engine",
3
- "version": "1.53.0",
3
+ "version": "1.53.2",
4
4
  "description": "Node.js based script runner for use in MQTT based Smart Home environments",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -691,6 +691,9 @@ if (config.url) {
691
691
  state.lc = state.val === oldState.val ? oldState.lc : ts;
692
692
  store.setObject('mqtt::' + topic, state);
693
693
  store.setObject('var::' + varName, state);
694
+ // dispatch now, as setVariable() does: the broker's echo of the status publish below finds the store
695
+ // already updated, so a { change: true } subscription would never see the change (B-22)
696
+ stateChange(topic, state, oldState, msg);
694
697
  mqtt.publish(topic, JSON.stringify(state), { retain: true });
695
698
  } else {
696
699
  if (!state) {
@@ -701,6 +704,18 @@ if (config.url) {
701
704
  state.ts = new Date().getTime();
702
705
  }
703
706
  oldState = store.getObject('mqtt::' + topic) || {};
707
+ // our own echo: she publishes <prefix>/status/<name> retained after a var/set or she.var.set(), and the
708
+ // broker delivers it back (we subscribe to #). The subscriptions were dispatched at set time; the
709
+ // echo carries the stored state verbatim (same ts and lc), so it is stored again but not dispatched.
710
+ if (
711
+ topicArr[0] === config.variablePrefix &&
712
+ topicArr[1] === 'status' &&
713
+ oldState.ts === state.ts &&
714
+ oldState.lc === state.lc &&
715
+ JSON.stringify(oldState.val) === JSON.stringify(state.val)
716
+ ) {
717
+ return;
718
+ }
704
719
  // lc (last change): prefer a payload-provided value; otherwise set it
705
720
  // on value change and carry the previous lc over when the value is
706
721
  // unchanged. Previously the old lc was simply lost on repeated
@@ -1688,6 +1703,9 @@ function loadDir(dir) {
1688
1703
  }
1689
1704
 
1690
1705
  const fileLabel = makeLabel(filePath);
1706
+ // the Scripts page reloads an open tab of this file (U12): every file, also libraries, disabled
1707
+ // scripts and non-.js files, since any of them may be open in a tab
1708
+ if (event === 'change') broadcast({ type: 'script:changed', path: fileLabel.slice(0, -1) });
1691
1709
  if (event === 'change' && filePath.endsWith('.js')) {
1692
1710
  if (isLibFile(filePath, dir)) {
1693
1711
  log.warn(fileLabel, 'is a library file - scripts that require() it will see the old version until they or the daemon are restarted');
@@ -1350,7 +1350,7 @@ function analysisLoaders(ctx) {
1350
1350
  } catch {
1351
1351
  /* module missing */
1352
1352
  }
1353
- if (!client) throw new Error('no Elasticsearch integration is configured in she (config "elastic")');
1353
+ if (!client) throw new Error('no Elasticsearch integration is configured in she (config "elastic"); use data.history (InfluxDB) for values over time instead');
1354
1354
  const fromMs = needTime(from, 'from');
1355
1355
  const toMs = needTime(to, 'to');
1356
1356
  const cap = Math.min(Math.max(1, Number(limit) || 1000), 5000);
@@ -2,12 +2,12 @@
2
2
  Use the tools; they read the running daemon. Where to start:
3
3
  - a room ("the light in the workshop", "presence in the bathroom"): describe_room first — every device, variable, script and discovery device of the room in one call; then narrow with describe_device (several names at once), get_timeline or get_topic_history
4
4
  - one device: describe_device; the current value of a topic: get_mqtt_topic; topics by pattern or value: search_mqtt_topics
5
- - anything about the past — "why", "when", "how often", "since when": get_timeline (the changes of several topics merged in time order; the tool for "what happened"), get_topic_history (the values of one or several topics over time), get_topic_messages (the raw messages of one topic)
5
+ - anything about the past — "why", "when", "how often", "since when": get_timeline (the changes of several topics merged in time order; the tool for "what happened"), get_topic_history (the values of one or several topics over time), get_topic_messages (the raw messages of one topic; needs Elasticsearch — without it use the history)
6
+ - a question that needs counting, correlating or comparing more than two topics over time ("did the light go off while the echo kept playing", "how often per evening", "what else changed in the minute before"): run_analysis first — one call with the computation in JavaScript beats a dozen history calls, and the user sees the code
6
7
  - which script does what: read_script (the source with its subscriptions, publishes and the scripts wired to it), list_scripts, who_publishes
7
8
  - what a script did or logged: get_script_logs with a time window; what is still pending: list_timers
8
9
  - "nothing happens": get_health first, then list_services for the adapters
9
10
  - Matter: list_matter_devices (with state), get_matter_attribute; sheDB: list_shedb_docs, get_shedb_doc
10
- - research that would take many calls or arithmetic over long lists (counts per hour, correlations, durations): run_analysis — write the computation in JavaScript over `data.topics`, `data.history`, `data.messages`, `data.log` and return a small result; the user sees the code and the result
11
11
  How to call them:
12
12
  - ask for every independent tool in the same turn — the calls of a turn run concurrently, and each turn costs a round trip
13
13
  - use MQTT filters (`radar-x/status/#`, `zigbee2mqtt/+_workshop/#`) where the topic tree is known; a substring search is for an unknown name