homebridge-denon-tv 3.16.2 → 3.16.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## Note - after update to 3.15.x need remove the accessory frome Home app and add it again.
8
8
 
9
+ ## [3.16.3] - (18.01.2022)
10
+ ### Changes
11
+ - update dependencies
12
+
9
13
  ## [3.16.2] - (17.01.2022)
10
14
  ### Changes
11
15
  - update dependencies
package/README.md CHANGED
@@ -63,7 +63,7 @@ Install and use [Homebridge Config UI X](https://github.com/oznu/homebridge-conf
63
63
  | --- | --- |
64
64
  | `name` | Here set the accessory *Name* to be displayed in *Homebridge/HomeKit*. |
65
65
  | `host` | Here set the *Hsostname or Address IP* of TV. |
66
- | `port` | This is the network port that this plugin will use to communicate with the receiver. If port `8080` is not working then try to use port `80` which some receivers use alternatively. Try the other port if the first one does not work |
66
+ | `port` | Here set the API communication port, if `8080` is not working try to use port `80` which some receivers use alternatively. |
67
67
  | `zoneControl` | Selects which zone will be controlled by this section (`0` - Main Zone, `1` - Zone 2, `2` - Zone 3, `3` - Surround Mode) or choice from the configurations GUI |
68
68
  | `enableDebugMode` | If enabled, deep log will be present in homebridge console. |
69
69
  | `disableLogInfo` | If enabled, disable log info, all values and state will not be displayed in Homebridge log console. |
package/index.js CHANGED
@@ -133,17 +133,17 @@ class denonTvDevice {
133
133
  }
134
134
  if (this.zoneControl == 0) {
135
135
  if (fs.existsSync(this.devInfoFile) == false) {
136
- fs.writeFileSync(this.devInfoFile, '');
136
+ fs.writeFileSync(this.devInfoFile, {});
137
137
  }
138
138
  }
139
139
  if (fs.existsSync(this.inputsFile) == false) {
140
- fs.writeFileSync(this.inputsFile, '');
140
+ fs.writeFileSync(this.inputsFile, []);
141
141
  }
142
142
  if (fs.existsSync(this.inputsNamesFile) == false) {
143
- fs.writeFileSync(this.inputsNamesFile, '');
143
+ fs.writeFileSync(this.inputsNamesFile, {});
144
144
  }
145
145
  if (fs.existsSync(this.inputsTargetVisibilityFile) == false) {
146
- fs.writeFileSync(this.inputsTargetVisibilityFile, '');
146
+ fs.writeFileSync(this.inputsTargetVisibilityFile, {});
147
147
  }
148
148
 
149
149
  //save inputs to the file
@@ -739,99 +739,103 @@ class denonTvDevice {
739
739
 
740
740
  //Prepare inputs switch service
741
741
  //check available switch inputs and possible count (max 94)
742
- this.switchServices = new Array();
743
742
  const inputsSwitchCount = this.inputsSwitchIndex.length;
744
743
  const availableInputsSwitchCount = 94 - maxInputsCount;
745
744
  const maxInputsSwitchCount = (availableInputsSwitchCount > 0) ? (availableInputsSwitchCount > inputsSwitchCount) ? inputsSwitchCount : availableInputsSwitchCount : 0;
746
- for (let i = 0; i < maxInputsSwitchCount; i++) {
745
+ if (maxInputsSwitchCount > 0) {
746
+ this.log.debug('prepareInputsSwitchService');
747
+ this.switchServices = new Array();
748
+ for (let i = 0; i < maxInputsSwitchCount; i++) {
747
749
 
748
- //get input switch index
749
- const inputSwitchIndex = this.inputsSwitchIndex[i];
750
+ //get input switch index
751
+ const inputSwitchIndex = this.inputsSwitchIndex[i];
750
752
 
751
- //get input switch reference
752
- const inputSwitchReference = this.inputsReference[inputSwitchIndex];
753
+ //get input switch reference
754
+ const inputSwitchReference = this.inputsReference[inputSwitchIndex];
753
755
 
754
- //get input switch name
755
- const inputSwitchName = this.inputsName[inputSwitchIndex];
756
+ //get input switch name
757
+ const inputSwitchName = this.inputsName[inputSwitchIndex];
756
758
 
757
- //get input switch mode
758
- const inputSwitchMode = (this.zoneControl <= 2) ? this.inputsMode[inputSwitchIndex] : 'MS';
759
+ //get input switch mode
760
+ const inputSwitchMode = (this.zoneControl <= 2) ? this.inputsMode[inputSwitchIndex] : 'MS';
759
761
 
760
- //get input switch display type
761
- const inputSwitchDisplayType = this.inputsSwitchDisplayType[inputSwitchIndex];
762
+ //get input switch display type
763
+ const inputSwitchDisplayType = this.inputsSwitchDisplayType[inputSwitchIndex];
762
764
 
763
765
 
764
- const serviceType = [Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor][inputSwitchDisplayType];
765
- const characteristicType = [Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected][inputSwitchDisplayType];
766
- const switchService = new serviceType(`${this.sZoneName} ${inputSwitchName}`, `Sensor ${i}`);
767
- switchService.getCharacteristic(characteristicType)
768
- .onGet(async () => {
769
- const state = this.powerState ? (inputSwitchReference == this.reference) : false;
770
- return state;
771
- })
772
- .onSet(async (state) => {
773
- if (inputSwitchDisplayType <= 1) {
774
- const zone = [inputSwitchMode, 'Z2', 'Z3', inputSwitchMode][this.zoneControl];
775
- const inputSwitchRef = zone + inputSwitchReference;
776
- try {
777
- const setSwitchInput = (state && this.powerState) ? await this.denon.send(API_URL.iPhoneDirect + inputSwitchRef) : false;
778
- const logInfo = this.disableLogInfo ? false : this.log('Device: %s %s, set new Input successful, name: %s, reference: %s', this.host, accessoryName, inputSwitchName, inputSwitchReference);
779
- } catch (error) {
780
- this.log.error('Device: %s %s, can not set new Input. Might be due to a wrong settings in config, error: %s.', this.host, accessoryName, error);
766
+ const serviceType = [Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor][inputSwitchDisplayType];
767
+ const characteristicType = [Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected][inputSwitchDisplayType];
768
+ const switchService = new serviceType(`${this.sZoneName} ${inputSwitchName}`, `Sensor ${i}`);
769
+ switchService.getCharacteristic(characteristicType)
770
+ .onGet(async () => {
771
+ const state = this.powerState ? (inputSwitchReference == this.reference) : false;
772
+ return state;
773
+ })
774
+ .onSet(async (state) => {
775
+ if (inputSwitchDisplayType <= 1) {
776
+ const zone = [inputSwitchMode, 'Z2', 'Z3', inputSwitchMode][this.zoneControl];
777
+ const inputSwitchRef = zone + inputSwitchReference;
778
+ try {
779
+ const setSwitchInput = (state && this.powerState) ? await this.denon.send(API_URL.iPhoneDirect + inputSwitchRef) : false;
780
+ const logInfo = this.disableLogInfo ? false : this.log('Device: %s %s, set new Input successful, name: %s, reference: %s', this.host, accessoryName, inputSwitchName, inputSwitchReference);
781
+ } catch (error) {
782
+ this.log.error('Device: %s %s, can not set new Input. Might be due to a wrong settings in config, error: %s.', this.host, accessoryName, error);
783
+ };
784
+ if (!this.powerState) {
785
+ setTimeout(() => {
786
+ this.switchServices[i]
787
+ .updateCharacteristic(Characteristic.On, false);
788
+ }, 150);
789
+ }
781
790
  };
782
- if (!this.powerState) {
783
- setTimeout(() => {
784
- this.switchServices[i]
785
- .updateCharacteristic(Characteristic.On, false);
786
- }, 150);
787
- }
788
- };
789
- });
791
+ });
790
792
 
791
- this.switchServices.push(switchService);
792
- accessory.addService(this.switchServices[i]);
793
+ this.switchServices.push(switchService);
794
+ accessory.addService(this.switchServices[i]);
795
+ }
793
796
  }
794
797
 
795
- //Prepare button service
796
798
  if (this.zoneControl <= 2) {
797
- this.log.debug('prepareButtonsService');
798
-
799
+ //Prepare button service
799
800
  //check available buttons and possible count (max 94)
800
801
  const buttons = this.buttons;
801
802
  const buttonsCount = buttons.length;
802
803
  const availableButtonsCount = (94 - (maxInputsCount + maxInputsSwitchCount));
803
804
  const maxButtonsCount = (availableButtonsCount > 0) ? (availableButtonsCount > buttonsCount) ? buttonsCount : availableButtonsCount : 0;
804
- for (let i = 0; i < maxButtonsCount; i++) {
805
-
806
- //get button reference
807
- const buttonReference = buttons[i].reference;
808
-
809
- //get button name
810
- const buttonName = (buttons[i].name != undefined) ? buttons[i].name : buttons[i].reference;
811
-
812
- //get button display type
813
- const buttonDisplayType = (buttons[i].displayType != undefined) ? buttons[i].displayType : 0;
814
-
815
- const serviceType = [Service.Outlet, Service.Switch][buttonDisplayType];
816
- const buttonService = new serviceType(`${this.sZoneName} ${buttonName}`, `Button ${i}`);
817
- buttonService.getCharacteristic(Characteristic.On)
818
- .onGet(async () => {
819
- const state = false;
820
- return state;
821
- })
822
- .onSet(async (state) => {
823
- try {
824
- const setFunction = (state && this.powerState) ? await this.denon.send(API_URL.iPhoneDirect + buttonReference) : false;
825
- const logInfo = this.disableLogInfo ? false : this.log('Device: %s %s, set new Input successful, name: %s, reference: %s', this.host, accessoryName, buttonName, buttonReference);
826
- } catch (error) {
827
- this.log.error('Device: %s %s, can not set new Input. Might be due to a wrong settings in config, error: %s.', this.host, accessoryName, error);
828
- };
829
- setTimeout(() => {
830
- buttonService.updateCharacteristic(Characteristic.On, false);
831
- }, 150);
832
- });
805
+ if (maxButtonsCount > 0) {
806
+ this.log.debug('prepareButtonsService');
807
+ for (let i = 0; i < maxButtonsCount; i++) {
808
+
809
+ //get button reference
810
+ const buttonReference = buttons[i].reference;
811
+
812
+ //get button name
813
+ const buttonName = (buttons[i].name != undefined) ? buttons[i].name : buttons[i].reference;
814
+
815
+ //get button display type
816
+ const buttonDisplayType = (buttons[i].displayType != undefined) ? buttons[i].displayType : 0;
817
+
818
+ const serviceType = [Service.Outlet, Service.Switch][buttonDisplayType];
819
+ const buttonService = new serviceType(`${this.sZoneName} ${buttonName}`, `Button ${i}`);
820
+ buttonService.getCharacteristic(Characteristic.On)
821
+ .onGet(async () => {
822
+ const state = false;
823
+ return state;
824
+ })
825
+ .onSet(async (state) => {
826
+ try {
827
+ const setFunction = (state && this.powerState) ? await this.denon.send(API_URL.iPhoneDirect + buttonReference) : false;
828
+ const logInfo = this.disableLogInfo ? false : this.log('Device: %s %s, set new Input successful, name: %s, reference: %s', this.host, accessoryName, buttonName, buttonReference);
829
+ } catch (error) {
830
+ this.log.error('Device: %s %s, can not set new Input. Might be due to a wrong settings in config, error: %s.', this.host, accessoryName, error);
831
+ };
832
+ setTimeout(() => {
833
+ buttonService.updateCharacteristic(Characteristic.On, false);
834
+ }, 150);
835
+ });
833
836
 
834
- accessory.addService(buttonService);
837
+ accessory.addService(buttonService);
838
+ }
835
839
  }
836
840
  }
837
841
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Denon TV",
3
3
  "name": "homebridge-denon-tv",
4
- "version": "3.16.2",
4
+ "version": "3.16.4",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Denon/Marantz AV Receivers.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -32,7 +32,7 @@
32
32
  "homebridge": ">=1.3.0"
33
33
  },
34
34
  "dependencies": {
35
- "axios": ">=0.24.0",
35
+ "axios": ">=0.25.0",
36
36
  "xml2js": ">=0.4.23"
37
37
  },
38
38
  "keywords": [