From 47115068f39afeaf667331bd2e9a54b23759dcde Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Wed, 1 May 2024 10:31:43 +0200 Subject: [PATCH] feat: Created some RenderingControl extensions --- .../rendering-control.service.extension.ts | 44 +++++++++++++++++++ src/sonos-device.ts | 18 ++++---- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/services/rendering-control.service.extension.ts b/src/services/rendering-control.service.extension.ts index 769c61d..68e2554 100644 --- a/src/services/rendering-control.service.extension.ts +++ b/src/services/rendering-control.service.extension.ts @@ -21,4 +21,48 @@ export class RenderingControlService extends RenderingControlServiceBase { } return super.ResolveEventPropertyValue(name, originalValue, type); } + + /** + * Get nightmode status of playbar. + * + * @returns {Promise} + * @memberof RenderingControlService + */ + public async GetNightMode(): Promise { + return (await this.GetEQ({ InstanceID: 0, EQType: 'NightMode' })).CurrentValue === 1; + } + + /** + * Turn on/off night mode, on your playbar. + * shortcut to .RenderingControlService.SetEQ({ InstanceID: 0, EQType: 'NightMode', DesiredValue: dialogLevel === true ? 1 : 0 }) + * + * @param {boolean} nightmode + * @returns {Promise} + * @memberof RenderingControlService + */ + public SetNightMode(nightmode: boolean): Promise { + return this.SetEQ({ InstanceID: 0, EQType: 'NightMode', DesiredValue: nightmode === true ? 1 : 0 }); + } + + /** + * Get Speech Enhancement status of playbar + * + * @returns {Promise} + * @memberof RenderingControlService + */ + public async GetSpeechEnhancement(): Promise { + return (await this.GetEQ({ InstanceID: 0, EQType: 'DialogLevel' })).CurrentValue === 1; + } + + /** + * Turn on/off speech enhancement, on your playbar, + * shortcut to .RenderingControlService.SetEQ({ InstanceID: 0, EQType: 'DialogLevel', DesiredValue: dialogLevel === true ? 1 : 0 }) + * + * @param {boolean} dialogLevel + * @returns {Promise} + * @memberof RenderingControlService + */ + public SetSpeechEnhancement(dialogLevel: boolean): Promise { + return this.SetEQ({ InstanceID: 0, EQType: 'DialogLevel', DesiredValue: dialogLevel === true ? 1 : 0 }); + } } diff --git a/src/sonos-device.ts b/src/sonos-device.ts index b13b36b..2b25ba3 100644 --- a/src/sonos-device.ts +++ b/src/sonos-device.ts @@ -1131,8 +1131,8 @@ export default class SonosDevice extends SonosDeviceBase { * @returns {Promise} * @memberof SonosDevice */ - public async GetNightMode(): Promise { - return (await this.RenderingControlService.GetEQ({ InstanceID: 0, EQType: 'NightMode' })).CurrentValue === 1; + public GetNightMode(): Promise { + return this.RenderingControlService.GetNightMode(); } /** @@ -1165,8 +1165,8 @@ export default class SonosDevice extends SonosDeviceBase { * @returns {Promise} * @memberof SonosDevice */ - public async GetSpeechEnhancement(): Promise { - return (await this.RenderingControlService.GetEQ({ InstanceID: 0, EQType: 'DialogLevel' })).CurrentValue === 1; + public GetSpeechEnhancement(): Promise { + return this.RenderingControlService.GetSpeechEnhancement(); } /** @@ -1254,9 +1254,8 @@ export default class SonosDevice extends SonosDeviceBase { * @returns {Promise} * @memberof SonosDevice */ - public async SetNightMode(nightmode: boolean): Promise { - return await this.RenderingControlService - .SetEQ({ InstanceID: 0, EQType: 'NightMode', DesiredValue: nightmode === true ? 1 : 0 }); + public SetNightMode(nightmode: boolean): Promise { + return this.RenderingControlService.SetNightMode(nightmode); } /** @@ -1319,9 +1318,8 @@ export default class SonosDevice extends SonosDeviceBase { * @returns {Promise} * @memberof SonosDevice */ - public async SetSpeechEnhancement(dialogLevel: boolean): Promise { - return await this.RenderingControlService - .SetEQ({ InstanceID: 0, EQType: 'DialogLevel', DesiredValue: dialogLevel === true ? 1 : 0 }); + public SetSpeechEnhancement(dialogLevel: boolean): Promise { + return this.RenderingControlService.SetSpeechEnhancement(dialogLevel); } /**