homebridge-philips-dline-sicp 0.1.7 → 0.1.8

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 +26 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -360,8 +360,13 @@ class PhilipsDLineTelevisionAccessory {
360
360
  }
361
361
 
362
362
  async handleSetActiveIdentifier(identifier) {
363
- await this._ensureOn();
364
- await this._setInputByIdentifier(identifier);
363
+ try {
364
+ await this._ensureOn();
365
+ await this._setInputByIdentifier(identifier);
366
+ } catch (e) {
367
+ this.log.error('Failed to set ActiveIdentifier:', e.message);
368
+ throw new hap.HapStatusError(hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE);
369
+ }
365
370
  }
366
371
 
367
372
  async handleSetVolume(val) {
@@ -439,12 +444,27 @@ class PhilipsDLineTelevisionAccessory {
439
444
  const code = this._codeFromIdentifier(identifier);
440
445
  if (code == null) {
441
446
  this.log.error('Unknown input identifier:', identifier);
442
- return;
447
+ throw new Error(`Unknown input identifier: ${identifier}`);
443
448
  }
444
- const reply = await this._send([0xAC, code]); // Set Input
445
- const parsed = parseReply(reply);
449
+
450
+ // Attempt 1
451
+ let reply = await this._send([0xAC, code]); // Set Input
452
+ let parsed = parseReply(reply);
453
+
454
+ // If NAV (not available) or NACK, wait and retry once
455
+ if (parsed.nav || parsed.nack) {
456
+ this.log.debug(`SetInput attempt 1 rejected (${parsed.nav ? 'nav' : 'nack'}), retrying in 500ms...`);
457
+ await delay(500);
458
+ reply = await this._send([0xAC, code]);
459
+ parsed = parseReply(reply);
460
+ }
461
+
446
462
  this.log.debug(`SetInput(${identifier}/0x${code.toString(16)}) reply:`, parsed.raw);
447
- if (parsed.nack || parsed.nav) throw new Error('Device rejected input change');
463
+
464
+ if (parsed.nack || parsed.nav) {
465
+ throw new Error(`Device rejected input change (reply: ${parsed.raw})`);
466
+ }
467
+
448
468
  this.activeIdentifier = identifier;
449
469
  this.televisionService.updateCharacteristic(hap.Characteristic.ActiveIdentifier, identifier);
450
470
  if (this.exposeInputSwitches) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-philips-dline-sicp",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Homebridge plugin to control Philips D-Line signage displays (e.g., 55BDL4511D) over LAN using SICP (TCP:5000). Exposes as a HomeKit Television with inputs.",
5
5
  "main": "index.js",
6
6
  "keywords": [