homebridge-denon-tv 3.23.2 → 3.23.5

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/README.md CHANGED
@@ -67,16 +67,16 @@ This plugin is based upon the official documentation for communicating with and
67
67
  | `inputs.name` | Here set *Input Name* which You want expose to the *Homebridge/HomeKit*. |
68
68
  | `inputs.reference` | Choose from available inputs, the inputs that should be published to and appear in HomeKit app in the device tile as inputs list |
69
69
  | `inputs.mode` | Choose from available inputs mode. |
70
- | `inputs.displayType` | Here select display type in HomeKit app, possible `None`, `Button`, `Switch`.|
70
+ | `inputs.displayType` | Here select display type in HomeKit app, possible `None`, `Outlet`, `Switch`.|
71
71
  | `buttonsMainZone.name` | Here set *Button Name* which You want expose to the *Homebridge/HomeKit*. |
72
72
  | `buttonsMainZone.reference` | Here choice function for additional control button for Main Zone. |
73
- | `buttonsMainZone.displayType` | Here select display type in HomeKit app, possible `None`, `Button`, `Switch`.|
73
+ | `buttonsMainZone.displayType` | Here select display type in HomeKit app, possible `None`, `Outlet`, `Switch`.|
74
74
  | `buttonsZone2.name` | Here set *Button Name* which You want expose to the *Homebridge/HomeKit*. |
75
75
  | `buttonsZone2.reference` | Here choice function for additional control button for Zone 2. |
76
- | `buttonsZone2.displayType` | Here select display type in HomeKit app, possible `None`, `Button`, `Switch`.|
76
+ | `buttonsZone2.displayType` | Here select display type in HomeKit app, possible `None`, `Outlet`, `Switch`.|
77
77
  | `buttonsZone3.name` | Here set *Button Name* which You want expose to the *Homebridge/HomeKit*. |
78
78
  | `buttonsZone3.reference` | Here choice function for additional control button for Zone 3. |
79
- | `buttonsZone3.displayType` | Here select display type in HomeKit app, possible `None`, `Button`, `Switch`.|
79
+ | `buttonsZone3.displayType` | Here select display type in HomeKit app, possible `None`, `Outlet`, `Switch`.|
80
80
  | `sensorPower`| If enabled, then the Power will be exposed as a `Motion Sensor` (active on Power ON) to use with automations. |
81
81
  | `sensorVolume`| If enabled, then the Volume will be exposed as a `Motion Sensor` (active on every Volume change) to use with automations. |
82
82
  | `sensorMute`| If enabled, then the Mute will be exposed as a `Motion Sensor` (active on Mute ON) to use with automations. |
@@ -86,7 +86,7 @@ This plugin is based upon the official documentation for communicating with and
86
86
  | `sensorInputs.displayType` | Here select sensor type to be exposed in HomeKit app, possible `None`, `Motion Sensor`, `Occupancy Sensor`, `Contact Sensor`. |
87
87
  | `surrounds.name` | Here set *Surround Mode Name* which You want expose to the *Homebridge/HomeKit*. |
88
88
  | `surrounds.reference` | Here choice *Surround Mode*, the mode that should be published to and appear in HomeKit app in the extra tile as Surrounds List. |
89
- | `surrounds.displayType` | Here select display type in HomeKit app, possible `None`, `Button`, `Switch`.|
89
+ | `surrounds.displayType` | Here select display type in HomeKit app, possible `None`, `Outlet`, `Switch`.|
90
90
  | `enableDebugMode` | If enabled, deep log will be present in homebridge console. |
91
91
  | `disableLogInfo` | If enabled, disable log info, all values and state will not be displayed in Homebridge log console. |
92
92
  | `disableLogDeviceInfo` | If enabled, add ability to disable log device info by every connections device to the network. |
@@ -106,7 +106,7 @@ This plugin is based upon the official documentation for communicating with and
106
106
  | `mqttPasswd` | Here set the MQTT Broker password. |
107
107
  | `mqttDebug` | If enabled, deep log will be present in homebridge console for MQTT. |
108
108
  | `AV Surround Mode` | This extra Accessory will control all functions of Main Zone except (Inputs and Buttons). |
109
- | `Display Type Inputs/Buttons` | -1 - `None`, 0 - `Button`, 1 - `Switch`.|
109
+ | `Display Type Inputs/Buttons` | -1 - `None`, 0 - `Outlet`, 1 - `Switch`.|
110
110
  | `Display Type Sensors` | -1 - `None`, 0 - `Motion Sensor`, 1 - `Occupancy Sensor`, 2 - `Contact Sensor`.|
111
111
 
112
112
 
@@ -648,7 +648,7 @@
648
648
  ]
649
649
  },
650
650
  {
651
- "title": "Button",
651
+ "title": "Outlet",
652
652
  "enum": [
653
653
  0
654
654
  ]
@@ -836,7 +836,7 @@
836
836
  ]
837
837
  },
838
838
  {
839
- "title": "Button",
839
+ "title": "Outlet",
840
840
  "enum": [
841
841
  0
842
842
  ]
@@ -3004,7 +3004,7 @@
3004
3004
  ]
3005
3005
  },
3006
3006
  {
3007
- "title": "Button",
3007
+ "title": "Outlet",
3008
3008
  "enum": [
3009
3009
  0
3010
3010
  ]
@@ -3204,7 +3204,7 @@
3204
3204
  ]
3205
3205
  },
3206
3206
  {
3207
- "title": "Button",
3207
+ "title": "Outlet",
3208
3208
  "enum": [
3209
3209
  0
3210
3210
  ]
@@ -3392,7 +3392,7 @@
3392
3392
  ]
3393
3393
  },
3394
3394
  {
3395
- "title": "Button",
3395
+ "title": "Outlet",
3396
3396
  "enum": [
3397
3397
  0
3398
3398
  ]
package/index.js CHANGED
@@ -833,7 +833,7 @@ class denonTvDevice {
833
833
  const savedInputsTargetVisibility = fs.readFileSync(this.inputsTargetVisibilityFile).length > 0 ? JSON.parse(fs.readFileSync(this.inputsTargetVisibilityFile)) : {};
834
834
  const debug2 = this.enableDebugMode ? this.log(`Device: ${this.host} ${this.name}, read saved ${this.zoneControl <= 2 ? 'Inputs' : 'Sound Modes'}, Target Visibility states: ${JSON.stringify(savedInputsTargetVisibility, null, 2)}`) : false;
835
835
 
836
- //check available inputs and possible count (max 80)
836
+ //check possible inputs and possible count (max 80)
837
837
  const inputs = savedInputs;
838
838
  const inputsCount = inputs.length;
839
839
  const maxInputsCount = inputsCount < 80 ? inputsCount : 80;
@@ -921,8 +921,8 @@ class denonTvDevice {
921
921
  this.inputSwitchButtonServices = [];
922
922
  const inputsSwitchesButtons = this.inputsSwitchesButtons;
923
923
  const inputsSwitchesButtonsCount = inputsSwitchesButtons.length;
924
- const availableInputsSwitchesButtonsCount = 80 - this.inputsReference.length;
925
- const maxInputsSwitchesButtonsCount = availableInputsSwitchesButtonsCount > 0 ? (availableInputsSwitchesButtonsCount > inputsSwitchesButtonsCount ? inputsSwitchesButtonsCount : availableInputsSwitchesButtonsCount) : 0;
924
+ const possibleInputsSwitchesButtonsCount = 80 - this.inputsReference.length;
925
+ const maxInputsSwitchesButtonsCount = possibleInputsSwitchesButtonsCount >= inputsSwitchesButtonsCount ? inputsSwitchesButtonsCount : possibleInputsSwitchesButtonsCount;
926
926
  if (!this.getInputsFromDevice) {
927
927
  if (maxInputsSwitchesButtonsCount > 0) {
928
928
  this.log.debug('prepareSwitchsService');
@@ -940,7 +940,7 @@ class denonTvDevice {
940
940
  const inputMode = (zoneControl <= 2) ? this.inputsMode[index] : 'MS';
941
941
 
942
942
  //get display type
943
- const inputDisplayType = this.inputsDisplayType[index] || -1;
943
+ const inputDisplayType = this.inputsDisplayType[index] >= 0 ? this.inputsDisplayType[index] : -1;
944
944
 
945
945
  if (inputDisplayType >= 0) {
946
946
  const serviceType = [Service.Outlet, Service.Switch][inputDisplayType];
@@ -974,8 +974,8 @@ class denonTvDevice {
974
974
  this.sensorInputsServices = [];
975
975
  const sensorInputs = this.sensorInputs;
976
976
  const sensorInputsCount = sensorInputs.length;
977
- const availableSensorInputsCount = 80 - this.inputsReference.length;
978
- const maxSensorInputsCount = availableSensorInputsCount > 0 ? (availableSensorInputsCount > sensorInputsCount ? sensorInputsCount : availableSensorInputsCount) : 0;
977
+ const possibleSensorInputsCount = 80 - this.inputsReference.length;
978
+ const maxSensorInputsCount = possibleSensorInputsCount >= sensorInputsCount ? sensorInputsCount : possibleSensorInputsCount;
979
979
  if (this.getInputsFromDevice) {
980
980
  if (maxSensorInputsCount > 0) {
981
981
  this.log.debug('prepareInputSensorServices');
@@ -990,12 +990,12 @@ class denonTvDevice {
990
990
  const sensorInputReference = sensorInput.reference || 'Not set';
991
991
 
992
992
  //get display type
993
- const sensorInputDisplayType = sensorInput.displayType || -1;
993
+ const sensorInputDisplayType = sensorInput.displayType >= 0 ? sensorInput.displayType : -1;
994
994
 
995
995
  if (sensorInputDisplayType >= 0) {
996
996
  const serviceType = [Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][sensorInputDisplayType];
997
997
  const characteristicType = [Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][sensorInputDisplayType];
998
- const sensorInputService = new serviceType(`${accessoryName} ${sensorInputName}`, `Sensor ${sensorInputName}`);
998
+ const sensorInputService = new serviceType(`${accessoryName} ${sensorInputName}`, `Sensor ${i}`);
999
999
  sensorInputService.getCharacteristic(characteristicType)
1000
1000
  .onGet(async () => {
1001
1001
  const state = this.power ? (this.reference === sensorInputReference) : false;
@@ -1013,15 +1013,18 @@ class denonTvDevice {
1013
1013
 
1014
1014
  //prepare button services zone 0 to 2
1015
1015
  if (zoneControl <= 2) {
1016
- //check available buttons and possible count (max 80)
1016
+ this.buttonsServices = [];
1017
1017
  const buttons = this.buttons;
1018
1018
  const buttonsCount = buttons.length;
1019
1019
  const maxbuttonsCount = this.getInputsFromDevice ? this.inputsReference.length + this.sensorInputsServices.length : this.inputsReference.length + this.inputSwitchButtonServices.length;
1020
- const availableButtonsCount = 80 - (maxInputsCount + maxbuttonsCount);
1021
- const maxButtonsCount = availableButtonsCount > 0 ? (availableButtonsCount > buttonsCount ? buttonsCount : availableButtonsCount) : 0;
1020
+ const possibleButtonsCount = 80 - (maxInputsCount + maxbuttonsCount);
1021
+ const maxButtonsCount = possibleButtonsCount >= buttonsCount ? buttonsCount : possibleButtonsCount;
1022
1022
  if (maxButtonsCount > 0) {
1023
- this.log.debug('prepareButtonsService');
1024
- for (const button of buttons) {
1023
+ this.log.debug('prepareInputsButtonService');
1024
+ for (let i = 0; i < maxButtonsCount; i++) {
1025
+ //get button
1026
+ const button = buttons[i];
1027
+
1025
1028
  //get button name
1026
1029
  const buttonName = button.name || 'Not set';
1027
1030
 
@@ -1029,11 +1032,11 @@ class denonTvDevice {
1029
1032
  const buttonReference = button.reference || 'Not set'
1030
1033
 
1031
1034
  //get button display type
1032
- const buttonDisplayType = button.displayType || -1;
1035
+ const buttonDisplayType = button.displayType >= 0 ? button.displayType : -1;
1033
1036
 
1034
1037
  if (buttonDisplayType >= 0) {
1035
1038
  const serviceType = [Service.Outlet, Service.Switch][buttonDisplayType];
1036
- const buttonService = new serviceType(`${this.sZoneName} ${buttonName}`, `Button ${buttonName}`);
1039
+ const buttonService = new serviceType(`${this.sZoneName} ${buttonName}`, `Button ${i}`);
1037
1040
  buttonService.getCharacteristic(Characteristic.On)
1038
1041
  .onGet(async () => {
1039
1042
  const state = false;
@@ -1050,7 +1053,8 @@ class denonTvDevice {
1050
1053
  this.log.error(`Device: ${this.host} ${accessoryName}, can not set new ${zoneControl <= 2 ? 'Input' : 'Sound Mode'}. Might be due to a wrong settings in config, error: ${error}`);
1051
1054
  };
1052
1055
  });
1053
- accessory.addService(buttonService);
1056
+ this.buttonsServices.push(buttonService);
1057
+ accessory.addService(this.buttonsServices[i]);
1054
1058
  }
1055
1059
  };
1056
1060
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Denon TV",
3
3
  "name": "homebridge-denon-tv",
4
- "version": "3.23.2",
4
+ "version": "3.23.5",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Denon/Marantz AV Receivers.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",