homebridge-eosstb 2.4.0-beta.3 → 2.4.0-beta.4

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 (3) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/index.js +31 -36
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,12 +5,16 @@ See the [Readme file](https://github.com/jsiegenthaler/homebridge-eosstb/blob/ma
5
5
  Please restart Homebridge after every plugin update.
6
6
 
7
7
 
8
+ ## 2.4.0-beta.4 (2026-05-10)
9
+
10
+ - Improved performance of refreshMasterChannelList
11
+
8
12
  ## 2.4.0-beta.3 (2026-05-10)
9
13
 
10
14
  This release focusses improved error handling and has extra debugging added to catch a refresh error
11
15
 
12
16
  - Improved handling of errors for web requests
13
- - Added extra debugging to assist in catching a refresh error in refreshChannelList
17
+ - Added extra debugging to assist in catching a refresh error in refreshMasterChannelList
14
18
 
15
19
  ## 2.4.0-beta.2 (2026-05-09)
16
20
 
package/index.js CHANGED
@@ -356,7 +356,7 @@ class StbPlatform {
356
356
  this.stbDevices = []; // store stbDevice in this.stbDevices
357
357
  this.masterChannelList = [];
358
358
  this.masterChannelListRefreshedAt = null; // null = never fetched since startup
359
- this.masterChannelListExpiryDate = 0; // epoch = always expired on first run, forces immediate fetch
359
+ this.masterChannelListExpiryDate = 0; // epoch = always expired on first run, forces immediate fetch
360
360
  this.checkChannelListTimeout = null; // nightly scheduler handler
361
361
  this.mqttReconnecting = false; // nightly reconnect indicator
362
362
  this.isDev = config.devMode === true;
@@ -3401,45 +3401,50 @@ class StbPlatform {
3401
3401
 
3402
3402
  // the header contains the following:
3403
3403
  // Cache-Control: max-age=600, public, stale-if-error=43200
3404
- // this could be used to set expiry date...
3405
3404
  const cacheControl = response.headers["cache-control"];
3406
- const maxAgeMatch = cacheControl?.match(/max-age=(\d+)/);
3407
- const serverMaxAge = maxAgeMatch ? parseInt(maxAgeMatch[1], 10) : null;
3405
+ const maxAge = cacheControl
3406
+ ?.split(",")
3407
+ .find((part) => part.trim().startsWith("max-age="))
3408
+ ?.split("=")[1];
3409
+ const serverMaxAge = maxAge ? parseInt(maxAge, 10) : null; //get the max age from the server
3408
3410
  const validForSecs =
3409
3411
  serverMaxAge ||
3410
3412
  this.config.masterChannelListValidFor ||
3411
3413
  MASTER_CHANNEL_LIST_VALID_FOR_S;
3412
3414
 
3413
- // Expiry priority: server Cache-Control max-age → config override → hardcoded constant
3414
- this.masterChannelListExpiryDate = Date.now() + validForSecs * 1000; // always a number
3415
+ this.masterChannelListExpiryDate = Date.now() + validForSecs * 1000;
3415
3416
 
3416
- // load the channel list with all channels found
3417
- this.masterChannelList = [];
3418
3417
  const channels = response.data;
3419
3418
  this.log.debug("Channels to process:", channels.length);
3420
- for (const channel of channels) {
3419
+ response.data = null; // release raw payload for GC
3420
+
3421
+ // Performance optimisation: Single pass — pre-allocated array + Map built together, shared object refs
3422
+ const newList = new Array(channels.length);
3423
+ const newMap = new Map();
3424
+
3425
+ for (let i = 0; i < channels.length; i++) {
3426
+ const ch = channels[i];
3421
3427
  if (this.debugLevel > 2) {
3422
3428
  this.log(
3423
3429
  "Processing channel:",
3424
- channel.logicalChannelNumber,
3425
- channel.id,
3426
- channel.name,
3430
+ ch.logicalChannelNumber,
3431
+ ch.id,
3432
+ ch.name,
3427
3433
  );
3428
3434
  }
3429
- this.masterChannelList.push({
3430
- id: channel.id,
3431
- name: cleanNameForHomeKit(channel.name),
3432
- logicalChannelNumber: channel.logicalChannelNumber,
3433
- linearProducts: channel.linearProducts,
3434
- });
3435
+ const entry = {
3436
+ id: ch.id,
3437
+ name: cleanNameForHomeKit(ch.name),
3438
+ logicalChannelNumber: ch.logicalChannelNumber,
3439
+ linearProducts: ch.linearProducts,
3440
+ };
3441
+ newList[i] = entry;
3442
+ newMap.set(ch.id, entry);
3435
3443
  }
3436
- // add a map for faster access to the master channel list
3437
- this.masterChannelMap = new Map(
3438
- this.masterChannelList.map((ch) => [ch.id, ch]),
3439
- );
3440
3444
 
3441
- // record when we refreshed it
3442
- this.masterChannelListRefreshedAt = Date.now()
3445
+ this.masterChannelList = newList;
3446
+ this.masterChannelMap = newMap;
3447
+ this.masterChannelListRefreshedAt = Date.now();
3443
3448
 
3444
3449
  this.log(
3445
3450
  "MasterChannelList contains %s channels, valid until %s",
@@ -3447,20 +3452,10 @@ class StbPlatform {
3447
3452
  new Date(this.masterChannelListExpiryDate).toLocaleString(), // format for display only
3448
3453
  );
3449
3454
 
3450
- if (this.debugLevel > 1) {
3451
- this.log.warn(
3452
- "refreshMasterChannelList: Master channel list refreshed with %s channels, valid until %s",
3453
- this.masterChannelList.length,
3454
- new Date(this.masterChannelListExpiryDate).toLocaleString(),
3455
- );
3456
- }
3457
3455
  return this.masterChannelList;
3456
+ //++++++++++++++++++++++++++++++++++++++++++++++++
3458
3457
  } catch (error) {
3459
- this._handleWebError(
3460
- error,
3461
- `refresh master channel list`,
3462
- url,
3463
- );
3458
+ this._handleWebError(error, `refresh master channel list`, url);
3464
3459
  }
3465
3460
  } // end of refreshMasterChannelList
3466
3461
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "displayName": "Homebridge EOSSTB",
4
4
  "description": "Add your set-top box to Homekit (for Telenet BE, Sunrise CH, UPC SK, Virgin Media GB & IE, Ziggo NL)",
5
5
  "author": "Jochen Siegenthaler (https://github.com/jsiegenthaler/)",
6
- "version": "2.4.0-beta.3",
6
+ "version": "2.4.0-beta.4",
7
7
  "platformname": "eosstb",
8
8
  "dependencies": {
9
9
  "axios": "^1.16.0",