ecoflow2mqtt 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/index.js +14 -1
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -50,6 +50,8 @@ const items = createItems();
50
50
  /** (cmd_func, cmd_id) pairs already logged, so unknown frames are reported once (E-7) */
51
51
  const seenFrames = new Set();
52
52
  let lastFrame = 0;
53
+ /** when the current stale period was last warned about, 0 while frames are arriving */
54
+ let lastStaleWarn = 0;
53
55
  let lastProductId = null;
54
56
  let staleTimer = null;
55
57
  let capture = null;
@@ -124,6 +126,10 @@ function handleFrame(frame) {
124
126
  return;
125
127
  }
126
128
 
129
+ if (lastStaleWarn) {
130
+ log.info(`frames from the inverter resumed after ${Math.round((Date.now() - lastFrame) / 1000)} s`);
131
+ lastStaleWarn = 0;
132
+ }
127
133
  lastFrame = Date.now();
128
134
  setDeviceConnected(true);
129
135
  if (frame.productId && frame.productId !== lastProductId) {
@@ -142,6 +148,9 @@ function handleFrame(frame) {
142
148
  }
143
149
  }
144
150
 
151
+ /** while stale, warn once and then at most hourly: the inverter is off every night, that is normal */
152
+ const STALE_WARN_INTERVAL = 3600_000;
153
+
145
154
  /** The device counts as connected while frames keep arriving (E-5) — the cloud's own flag lags. */
146
155
  function watchStaleness() {
147
156
  clearInterval(staleTimer);
@@ -151,7 +160,11 @@ function watchStaleness() {
151
160
  }
152
161
  const age = (Date.now() - lastFrame) / 1000;
153
162
  if (age > config.timeout) {
154
- log.warn(`no frame from the inverter for ${Math.round(age)} s`);
163
+ const now = Date.now();
164
+ if (now - lastStaleWarn >= STALE_WARN_INTERVAL) {
165
+ lastStaleWarn = now;
166
+ log.warn(`no frame from the inverter for ${Math.round(age)} s`);
167
+ }
155
168
  setDeviceConnected(false);
156
169
  }
157
170
  }, 30_000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecoflow2mqtt",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Interface between EcoFlow STREAM / PowerStream micro-inverters and MQTT",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "mqtt": "^5.10.0",
62
- "mqtt-interfaces-core": "^0.11.3",
62
+ "mqtt-interfaces-core": "^0.12.0",
63
63
  "protobufjs": "^7.4.0"
64
64
  },
65
65
  "devDependencies": {