Skip to content

Commit

Permalink
feat: Created some RenderingControl extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
svrooij committed May 1, 2024
1 parent 4d46e03 commit 4711506
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
44 changes: 44 additions & 0 deletions src/services/rendering-control.service.extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,48 @@ export class RenderingControlService extends RenderingControlServiceBase {
}
return super.ResolveEventPropertyValue(name, originalValue, type);
}

/**
* Get nightmode status of playbar.
*
* @returns {Promise<boolean>}
* @memberof RenderingControlService
*/
public async GetNightMode(): Promise<boolean> {
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<boolean>}
* @memberof RenderingControlService
*/
public SetNightMode(nightmode: boolean): Promise<boolean> {
return this.SetEQ({ InstanceID: 0, EQType: 'NightMode', DesiredValue: nightmode === true ? 1 : 0 });
}

/**
* Get Speech Enhancement status of playbar
*
* @returns {Promise<boolean>}
* @memberof RenderingControlService
*/
public async GetSpeechEnhancement(): Promise<boolean> {
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<boolean>}
* @memberof RenderingControlService
*/
public SetSpeechEnhancement(dialogLevel: boolean): Promise<boolean> {
return this.SetEQ({ InstanceID: 0, EQType: 'DialogLevel', DesiredValue: dialogLevel === true ? 1 : 0 });
}
}
18 changes: 8 additions & 10 deletions src/sonos-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,8 @@ export default class SonosDevice extends SonosDeviceBase {
* @returns {Promise<boolean>}
* @memberof SonosDevice
*/
public async GetNightMode(): Promise<boolean> {
return (await this.RenderingControlService.GetEQ({ InstanceID: 0, EQType: 'NightMode' })).CurrentValue === 1;
public GetNightMode(): Promise<boolean> {
return this.RenderingControlService.GetNightMode();
}

/**
Expand Down Expand Up @@ -1165,8 +1165,8 @@ export default class SonosDevice extends SonosDeviceBase {
* @returns {Promise<boolean>}
* @memberof SonosDevice
*/
public async GetSpeechEnhancement(): Promise<boolean> {
return (await this.RenderingControlService.GetEQ({ InstanceID: 0, EQType: 'DialogLevel' })).CurrentValue === 1;
public GetSpeechEnhancement(): Promise<boolean> {
return this.RenderingControlService.GetSpeechEnhancement();
}

/**
Expand Down Expand Up @@ -1254,9 +1254,8 @@ export default class SonosDevice extends SonosDeviceBase {
* @returns {Promise<boolean>}
* @memberof SonosDevice
*/
public async SetNightMode(nightmode: boolean): Promise<boolean> {
return await this.RenderingControlService
.SetEQ({ InstanceID: 0, EQType: 'NightMode', DesiredValue: nightmode === true ? 1 : 0 });
public SetNightMode(nightmode: boolean): Promise<boolean> {
return this.RenderingControlService.SetNightMode(nightmode);
}

/**
Expand Down Expand Up @@ -1319,9 +1318,8 @@ export default class SonosDevice extends SonosDeviceBase {
* @returns {Promise<boolean>}
* @memberof SonosDevice
*/
public async SetSpeechEnhancement(dialogLevel: boolean): Promise<boolean> {
return await this.RenderingControlService
.SetEQ({ InstanceID: 0, EQType: 'DialogLevel', DesiredValue: dialogLevel === true ? 1 : 0 });
public SetSpeechEnhancement(dialogLevel: boolean): Promise<boolean> {
return this.RenderingControlService.SetSpeechEnhancement(dialogLevel);
}

/**
Expand Down

0 comments on commit 4711506

Please sign in to comment.