homebridge-xiaomi-miot 1.2.1 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.2] - 2026-11-09
4
+
5
+ ### Fixed
6
+ - **Offline detection no longer interferes with the MiOT library's reconnect cycle** — `pushOffline` previously set `miotDevice.localConnected = false` directly, which caused the vendored library to treat the device as disconnected and trigger an unnecessary handshake/reconnect cycle (~80 s downtime) even when the device was actually reachable. Now `localConnected` is left untouched; instead, `onSet` handlers are patched (the same way `onGet` handlers already were) so that both reads and writes correctly return `SERVICE_COMMUNICATION_FAILURE` while offline. Handlers are restored when the device comes back.
7
+ - **Property set and action failures are now logged at `warn` level** — errors in `setProperty` and `executeAction` were previously swallowed into `debug`-only logs, making silent control failures invisible to users. They now appear as `warn` messages in the Homebridge log.
8
+
9
+ ---
10
+
3
11
  ## [1.2.1] - 2026-06-08
4
12
 
5
13
  ### Changed
package/index.js CHANGED
@@ -12,7 +12,7 @@ const Events = require(MIOT_ROOT + 'constants/Events.js');
12
12
 
13
13
  const PLUGIN_NAME = 'homebridge-xiaomi-miot';
14
14
  const PLATFORM_NAME = 'XiaomiMiot';
15
- const PLUGIN_VERSION = '1.2.1';
15
+ const PLUGIN_VERSION = '1.2.2';
16
16
 
17
17
  /* ── Silence verbose MiOT startup logs ── */
18
18
  const MIOT_INFO_SUPPRESS = [
@@ -229,7 +229,6 @@ class XiaomiMiotDeviceController {
229
229
 
230
230
  /* ── Install error-throwing getHandler on every characteristic ── */
231
231
  const pushOffline = () => {
232
- this.miotDevice.localConnected = false;
233
232
  eachChar(char => {
234
233
  /* Save original handler (once only) and replace with error thrower */
235
234
  if (!Object.prototype.hasOwnProperty.call(char, '_xiaomiOrigGet')) {
@@ -238,13 +237,18 @@ class XiaomiMiotDeviceController {
238
237
  throw new HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
239
238
  });
240
239
  }
240
+ if (!Object.prototype.hasOwnProperty.call(char, '_xiaomiOrigSet') && char.setHandler !== undefined) {
241
+ char._xiaomiOrigSet = char.setHandler;
242
+ char.onSet(() => {
243
+ throw new HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
244
+ });
245
+ }
241
246
  });
242
247
  this.logger.warn(`[OfflineDetect] ${this.name} — offline.`);
243
248
  };
244
249
 
245
- /* ── Restore original getHandlers when device comes back ── */
250
+ /* ── Restore original get/set handlers when device comes back ── */
246
251
  const pushOnline = () => {
247
- this.miotDevice.localConnected = true;
248
252
  eachChar(char => {
249
253
  if (Object.prototype.hasOwnProperty.call(char, '_xiaomiOrigGet')) {
250
254
  if (char._xiaomiOrigGet) {
@@ -254,6 +258,10 @@ class XiaomiMiotDeviceController {
254
258
  }
255
259
  delete char._xiaomiOrigGet;
256
260
  }
261
+ if (Object.prototype.hasOwnProperty.call(char, '_xiaomiOrigSet')) {
262
+ char.onSet(char._xiaomiOrigSet);
263
+ delete char._xiaomiOrigSet;
264
+ }
257
265
  });
258
266
  };
259
267
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-xiaomi-miot",
3
3
  "displayName": "Homebridge Xiaomi MiOT",
4
- "version": "1.2.1",
4
+ "version": "1.2.2",
5
5
  "description": "Homebridge plugin for Xiaomi devices using the MiOT protocol — local and MiCloud",
6
6
  "main": "index.js",
7
7
  "scripts": {},
@@ -1237,7 +1237,7 @@ class MiotDevice extends EventEmitter {
1237
1237
  throw new Error(`Error while setting property ${prop.getName()} to value ${value}! Invalid response. Response: ${JSON.stringify(result)}`);
1238
1238
  }
1239
1239
  } catch (err) {
1240
- this.logger.debug(err);
1240
+ this.logger.warn(`Set property failed: ${err.message || err}`);
1241
1241
  }
1242
1242
  }
1243
1243
 
@@ -1262,7 +1262,7 @@ class MiotDevice extends EventEmitter {
1262
1262
  throw new Error(`Error while executing action ${action.getName()} with params ${paramValues}! Invalid response from device. Response: ${JSON.stringify(result)}`);
1263
1263
  }
1264
1264
  } catch (err) {
1265
- this.logger.debug(err);
1265
+ this.logger.warn(`Execute action failed: ${err.message || err}`);
1266
1266
  }
1267
1267
  }
1268
1268