homebridge-denon-tv 3.23.1 → 3.23.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.
Files changed (2) hide show
  1. package/index.js +32 -30
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -931,39 +931,41 @@ class denonTvDevice {
931
931
  const index = inputsSwitchesButtons[i];
932
932
 
933
933
  //get name
934
- const inputName = this.inputsName[index];
934
+ const inputName = this.inputsName[index] || 'Not set';
935
935
 
936
936
  //get reference
937
- const inputReference = this.inputsReference[index];
937
+ const inputReference = this.inputsReference[index] || 'Not set';
938
938
 
939
939
  //get mode
940
940
  const inputMode = (zoneControl <= 2) ? this.inputsMode[index] : 'MS';
941
941
 
942
942
  //get display type
943
- const inputDisplayType = this.inputsDisplayType[index];
944
-
945
- const serviceType = [Service.Outlet, Service.Switch][inputDisplayType];
946
- const characteristicType = [Characteristic.On, Characteristic.On][inputDisplayType];
947
- const inputSwitchButtonService = new serviceType(`${this.sZoneName} ${inputName}`, `Switch ${i}`);
948
- inputSwitchButtonService.getCharacteristic(characteristicType)
949
- .onGet(async () => {
950
- const state = this.power ? (this.reference === inputReference) : false;
951
- return state;
952
- })
953
- .onSet(async (state) => {
954
- try {
955
- const zone = [inputMode, 'Z2', 'Z3', inputMode][zoneControl];
956
- const reference = zone + inputReference;
957
-
958
- const setSwitchInput = (state && this.power) ? await this.denon.send(CONSTANS.ApiUrls.iPhoneDirect + reference) : false;
959
- const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, set new ${zoneControl <= 2 ? 'Input' : 'Sound Mode'} successful, name: ${inputName}, reference: ${inputReference}`);
960
- } catch (error) {
961
- 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}`);
962
- };
963
- });
964
-
965
- this.inputSwitchButtonServices.push(inputSwitchButtonService);
966
- accessory.addService(this.inputSwitchButtonServices[i]);
943
+ const inputDisplayType = this.inputsDisplayType[index] || -1;
944
+
945
+ if (inputDisplayType >= 0) {
946
+ const serviceType = [Service.Outlet, Service.Switch][inputDisplayType];
947
+ const characteristicType = [Characteristic.On, Characteristic.On][inputDisplayType];
948
+ const inputSwitchButtonService = new serviceType(`${this.sZoneName} ${inputName}`, `Switch ${i}`);
949
+ inputSwitchButtonService.getCharacteristic(characteristicType)
950
+ .onGet(async () => {
951
+ const state = this.power ? (this.reference === inputReference) : false;
952
+ return state;
953
+ })
954
+ .onSet(async (state) => {
955
+ try {
956
+ const zone = [inputMode, 'Z2', 'Z3', inputMode][zoneControl];
957
+ const reference = zone + inputReference;
958
+
959
+ const setSwitchInput = (state && this.power) ? await this.denon.send(CONSTANS.ApiUrls.iPhoneDirect + reference) : false;
960
+ const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, set new ${zoneControl <= 2 ? 'Input' : 'Sound Mode'} successful, name: ${inputName}, reference: ${inputReference}`);
961
+ } catch (error) {
962
+ 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}`);
963
+ };
964
+ });
965
+
966
+ this.inputSwitchButtonServices.push(inputSwitchButtonService);
967
+ accessory.addService(this.inputSwitchButtonServices[i]);
968
+ }
967
969
  }
968
970
  };
969
971
  };
@@ -982,10 +984,10 @@ class denonTvDevice {
982
984
  const sensorInput = sensorInputs[i];
983
985
 
984
986
  //get name
985
- const sensorInputName = sensorInput.name || 'Not set in config';
987
+ const sensorInputName = sensorInput.name || 'Not set';
986
988
 
987
989
  //get reference
988
- const sensorInputReference = sensorInput.reference || 'Not set in config';
990
+ const sensorInputReference = sensorInput.reference || 'Not set';
989
991
 
990
992
  //get display type
991
993
  const sensorInputDisplayType = sensorInput.displayType || -1;
@@ -1021,10 +1023,10 @@ class denonTvDevice {
1021
1023
  this.log.debug('prepareButtonsService');
1022
1024
  for (const button of buttons) {
1023
1025
  //get button name
1024
- const buttonName = button.name || 'Not set in config';
1026
+ const buttonName = button.name || 'Not set';
1025
1027
 
1026
1028
  //get button reference
1027
- const buttonReference = button.reference || 'Not set in config'
1029
+ const buttonReference = button.reference || 'Not set'
1028
1030
 
1029
1031
  //get button display type
1030
1032
  const buttonDisplayType = button.displayType || -1;
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.1",
4
+ "version": "3.23.2",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Denon/Marantz AV Receivers.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",