-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce NightMode and SpeechEnhancement calls
Recognize subs connected to PLAYBAR v1.4.0
- Loading branch information
Showing
8 changed files
with
313 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
const soap = require('../../helpers/soap'); | ||
const TYPE = soap.TYPE; | ||
|
||
function nightMode(enable) { | ||
const value = enable ? '1' : '0'; | ||
return soap.invoke( | ||
`${this.baseUrl}/MediaRenderer/RenderingControl/Control`, | ||
TYPE.SetEQ, | ||
{ eqType: 'NightMode', value }); | ||
}; | ||
|
||
module.exports = nightMode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
const soap = require('../../helpers/soap'); | ||
const TYPE = soap.TYPE; | ||
|
||
function speechEnhancement(enable) { | ||
const value = enable ? '1' : '0'; | ||
return soap.invoke( | ||
`${this.baseUrl}/MediaRenderer/RenderingControl/Control`, | ||
TYPE.SetEQ, | ||
{ eqType: 'DialogLevel', value }); | ||
}; | ||
|
||
module.exports = speechEnhancement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "sonos-discovery", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "A simple node library for managing your Sonos system", | ||
"author": "Jimmy Shimizu <[email protected]>", | ||
"repository": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
'use strict'; | ||
const expect = require('chai').expect; | ||
const sinon = require('sinon'); | ||
const proxyquire = require('proxyquire'); | ||
require('chai').use(require('sinon-chai')); | ||
|
||
const soap = require('../../../../lib/helpers/soap'); | ||
const TYPE = soap.TYPE; | ||
|
||
describe('Player.nightMode()', () => { | ||
let zoneMemberData; | ||
let request; | ||
let Player; | ||
let player; | ||
let Subscriber; | ||
let subscriber; | ||
let listener; | ||
let system; | ||
let musicServices; | ||
|
||
beforeEach(() => { | ||
sinon.stub(soap, 'invoke').resolves(); | ||
sinon.stub(soap, 'parse'); | ||
}); | ||
|
||
afterEach(() => { | ||
if (soap.invoke.restore) | ||
soap.invoke.restore(); | ||
if (soap.parse.restore) | ||
soap.parse.restore(); | ||
}); | ||
|
||
beforeEach(() => { | ||
zoneMemberData = { | ||
uuid: 'RINCON_00000000000001400', | ||
location: 'http://192.168.1.151:1400/xml/device_description.xml', | ||
zonename: 'Kitchen', | ||
icon: 'x-rincon-roomicon:kitchen', | ||
configuration: '1', | ||
softwareversion: '31.8-24090', | ||
mincompatibleversion: '29.0-00000', | ||
legacycompatibleversion: '24.0-00000', | ||
bootseq: '114', | ||
wirelessmode: '0', | ||
hasconfiguredssid: '0', | ||
channelfreq: '2412', | ||
behindwifiextender: '0', | ||
wifienabled: '1', | ||
orientation: '0', | ||
sonarstate: '4' | ||
}; | ||
|
||
subscriber = { | ||
dispose: sinon.spy() | ||
}; | ||
|
||
Subscriber = sinon.stub().returns(subscriber); | ||
|
||
musicServices = { | ||
tryGetHighResArt: sinon.stub() | ||
}; | ||
|
||
musicServices.tryGetHighResArt.onCall(0).resolves('http://example.org/image1'); | ||
musicServices.tryGetHighResArt.onCall(1).resolves('http://example.org/image2'); | ||
|
||
Player = proxyquire('../../../../lib/models/Player', { | ||
'../Subscriber': Subscriber, | ||
'../musicservices': musicServices | ||
}); | ||
|
||
listener = { | ||
endpoint: sinon.stub().returns('http://127.0.0.2/'), | ||
on: sinon.spy() | ||
}; | ||
|
||
system = { | ||
zones: [ | ||
{ | ||
uuid: zoneMemberData.uuid, | ||
members: [] | ||
} | ||
], | ||
on: sinon.stub(), | ||
emit: sinon.spy() | ||
}; | ||
|
||
player = new Player(zoneMemberData, listener, system); | ||
player.coordinator = player; | ||
system.zones[0].coordinator = player; | ||
system.zones[0].members.push(player); | ||
}); | ||
|
||
it('should call correct soap call when enabling', () => { | ||
return player.nightMode(true) | ||
.then(() => { | ||
expect(soap.invoke).calledOnce; | ||
expect(soap.invoke.firstCall.args).eql([ | ||
'http://192.168.1.151:1400/MediaRenderer/RenderingControl/Control', | ||
TYPE.SetEQ, | ||
{ | ||
eqType: 'NightMode', | ||
value: '1' | ||
} | ||
]); | ||
}); | ||
}); | ||
|
||
it('should call correct soap call when disabling', () => { | ||
return player.nightMode(false) | ||
.then(() => { | ||
expect(soap.invoke).calledOnce; | ||
expect(soap.invoke.firstCall.args).eql([ | ||
'http://192.168.1.151:1400/MediaRenderer/RenderingControl/Control', | ||
TYPE.SetEQ, | ||
{ | ||
eqType: 'NightMode', | ||
value: '0' | ||
} | ||
]); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.