diff --git a/Changelog.md b/Changelog.md index 8b8cd10..90c918a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,13 @@ # Changelog +# v5.0.3 - 2021-09-20 + +## Other Changes +- Refactored `volume selector`: IRCC instead of API calls + +## Bugfixes +- Minor Bugfixes + # v5.0.2 - 2021-09-20 ## Other Changes diff --git a/package-lock.json b/package-lock.json index ecc9c78..4a7d8f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-bravia-tvos", - "version": "5.0.2", + "version": "5.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -322,9 +322,9 @@ "dev": true }, "@seydx/bravia": { - "version": "2.0.0-beta.12", - "resolved": "https://registry.npmjs.org/@seydx/bravia/-/bravia-2.0.0-beta.12.tgz", - "integrity": "sha512-p26tEJWF4WU9nAdbdhtY8ya/WnvDaaqWIatEAl+RSaDV4zDJ4ebOxmVQMifC4Cd4sAyz+iZfN0sHdiNeGmbraw==", + "version": "2.0.0-beta.14", + "resolved": "https://registry.npmjs.org/@seydx/bravia/-/bravia-2.0.0-beta.14.tgz", + "integrity": "sha512-JYdv8mShU4MFhyKNUkCHNCfMAn3IkZnEvNPXdgupIB/ep3qnmjaAqmpSOP0YeUGqhlAq/xPkX7wffy8QhWrbzg==", "requires": { "caporal": "^1.4.0", "debug": "^4.3.2", diff --git a/package.json b/package.json index 1a4b0f7..628edb6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-bravia-tvos", - "version": "5.0.2", + "version": "5.0.3", "description": "Homebridge plugin for Sony Bravia Android TVs", "main": "index.js", "repository": { @@ -50,7 +50,7 @@ }, "dependencies": { "@homebridge/plugin-ui-utils": "^0.0.19", - "@seydx/bravia": "^2.0.0-beta.12", + "@seydx/bravia": "^2.0.0-beta.14", "fs-extra": "^10.0.0" }, "devDependencies": { diff --git a/src/accessories/accessory.handler.js b/src/accessories/accessory.handler.js index b8b1f9f..fe01052 100644 --- a/src/accessories/accessory.handler.js +++ b/src/accessories/accessory.handler.js @@ -448,11 +448,9 @@ class Handler { } const target = - this.accessory.context.config.speaker.output === 'other' - ? 'speaker' - : this.accessory.context.config.speaker.output; + this.accessory.context.config.speaker.output === 'other' ? '' : this.accessory.context.config.speaker.output; - logger.info(`Volume: ${state} (${target})`); + logger.info(`Volume: ${state} (${this.accessory.context.config.speaker.output})`); this.accessory.context.busy = true; @@ -481,26 +479,59 @@ class Handler { return; } + // Volume Control through IRCC + const target = this.accessory.context.config.speaker.output === 'other' ? 'speaker' : this.accessory.context.config.speaker.output; const volumeLevel = state - ? `-${this.accessory.context.config.speaker.reduceBy}` - : `+${this.accessory.context.config.speaker.increaseBy}`; + ? this.accessory.context.config.speaker.reduceBy + : this.accessory.context.config.speaker.increaseBy; + + const volumeCommand = state + ? this.accessory.context.config.remote.VOLUME_DOWN + : this.accessory.context.config.remote.VOLUME_UP; + + const irccCommands = []; + + for (let i = 0; i < volumeLevel; i++) { + irccCommands.push(volumeCommand); + } logger.info( `${state ? 'Reducing' : 'Increasing'} volume by ${volumeLevel} (${target})`, this.accessory.displayName ); + logger.debug(`Execute Command: ${volumeCommand}`, this.accessory.displayName); + + this.accessory.context.busy = true; + + await this.bravia.execCommand(irccCommands); + + /* + + //Volume control through API + + const target = + this.accessory.context.config.speaker.output === 'other' + ? 'speaker' + : this.accessory.context.config.speaker.output; + + const volumeLevel = state + ? `-${this.accessory.context.config.speaker.reduceBy}` + : `+${this.accessory.context.config.speaker.increaseBy}`; + this.accessory.context.busy = true; await this.bravia.exec('audio', 'setAudioVolume', '1.0', { target: '', volume: volumeLevel, }); + + */ } catch (err) { logger.warn('An error occured during setting volume (selector)!', this.accessory.displayName); logger.error(err, this.accessory.displayName);