homebridge-denon-tv 6.1.21 → 6.1.22-beta.0

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/package.json +1 -1
  2. package/src/denon.js +5 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Denon TV",
3
3
  "name": "homebridge-denon-tv",
4
- "version": "6.1.21",
4
+ "version": "6.1.22-beta.0",
5
5
  "description": "Homebridge plugin to control Denon/Marantz AV Receivers.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/denon.js CHANGED
@@ -16,14 +16,17 @@ class Denon extends EventEmitter {
16
16
  this.firstRun = true;
17
17
  this.functions = new Functions();
18
18
 
19
- const protocol = this.generation === 2 ? 'https' : 'http';
19
+ // Some gen 2 (2023+) models front their API with HTTPS on port 443 (e.g. self-signed nginx),
20
+ // others still serve plain HTTP on 80/8080 (e.g. Cinema series) - use the port as the signal.
21
+ const useHttps = this.generation === 2 && Number(config.port) === 443;
22
+ const protocol = useHttps ? 'https' : 'http';
20
23
  const baseUrl = `${protocol}://${config.host}:${config.port}`;
21
24
  const commonConfig = {
22
25
  baseURL: baseUrl,
23
26
  timeout: 20000
24
27
  };
25
28
 
26
- const httpsConfig = this.generation === 2 ? { httpsAgent: new HttpsAgent({ rejectUnauthorized: false, keepAlive: false }) } : {};
29
+ const httpsConfig = useHttps ? { httpsAgent: new HttpsAgent({ rejectUnauthorized: false, keepAlive: false }) } : {};
27
30
  this.client = axios.create({
28
31
  ...commonConfig,
29
32
  ...httpsConfig,