Skip to content

Commit

Permalink
Merge pull request #483 from bencevans/alpha
Browse files Browse the repository at this point in the history
Releasing all improvements in alpha version

Signed-off-by: Ben Evans <638535+bencevans@users.noreply.github.com>
Signed-off-by: Stephan van Rooij <1292510+svrooij@users.noreply.github.com>
Co-authored-by: Pascal Opitz <271740+pascalopitz@users.noreply.github.com>
  • Loading branch information
svrooij and pascalopitz authored Aug 13, 2020
2 parents 1985700 + 35c7b76 commit a8674ff
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 58 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- beta
- alpha
pull_request:

jobs:
Expand All @@ -20,4 +21,35 @@ jobs:
- name: Install depencencies
run: npm ci
- name: Run tests
run: npm run test
run: npm run test

release:
needs: build-and-test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/alpha' # only run on alpha branch for now.
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Use node 12
uses: actions/setup-node@v1
with:
node-version: 12
- uses: svrooij/secret-gate-action@v1 # see https://github.com/svrooij/secret-gate-action this is to fail quiet until secret is set.
id: mygate
with:
inputsToCheck: 'NPM_TOKEN'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install depencencies
if: steps.mygate.outputs.inputsChecked == 'true'
run: npm ci
- name: Run tests
if: steps.mygate.outputs.inputsChecked == 'true'
run: npm run test
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
if: steps.mygate.outputs.inputsChecked == 'true'
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions lib/deviceDiscovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ DeviceDiscovery.prototype.destroy = function (callback) {
* @param {Object} options Optional Options to control search behavior.
* Set 'timeout' to how long to search for devices
* (in milliseconds).
* Set 'port' to use a specific inbound UDP port,
* rather than a randomly assigned one
* @param {Function} listener Optional 'DeviceAvailable' listener (sonos)
* @return {DeviceDiscovery}
*/
Expand Down
3 changes: 2 additions & 1 deletion lib/events/adv-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const listenAddress = process.env.SONOS_LISTENER || ip.address('public')

const globalEventEndpoints = [
'/AlarmClock/Event',
'/ZoneGroupTopology/Event'
'/ZoneGroupTopology/Event',
'/MediaServer/ContentDirectory/Event'
]
const deviceEventEndpoints = [
'/MediaRenderer/AVTransport/Event',
Expand Down
8 changes: 8 additions & 0 deletions lib/events/eventParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ EventParser.ParseAndEmitEvents = async function (endpoint, body, device) {
return EventParser._parseGroupRenderingControlEvent(body, device)
case '/MediaRenderer/Queue/Event':
return EventParser._parseQueueEvent(body, device)
case '/MediaServer/ContentDirectory/Event':
return EventParser._parseContentDirectoryEvent(body, device)
default:
return EventParser._genericEvent(endpoint, body, device)
}
Expand Down Expand Up @@ -103,6 +105,12 @@ EventParser._genericEvent = function (endpoint, body, device) {
return event
}

EventParser._parseContentDirectoryEvent = function (body, device) {
debug('ContentDirectory event %j', body)
const event = { name: 'ContentDirectory', eventBody: body }
return event
}

EventParser._parseAlarmEvent = function (body, device) {
debug('Alarm event %j', body)
const event = { name: 'AlarmClock', eventBody: body }
Expand Down
103 changes: 99 additions & 4 deletions lib/services/ContentDirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ class ContentDirectory extends Service {
this.SCPDURL = '/xml/ContentDirectory1.xml'
}

async Browse (options) { return this._request('Browse', options) }

async DestroyObject (options) { return this._request('DestroyObject', options) }

async _parseResult (input) {
input.Result = await Helpers.ParseXml(input.Result)
return input
Expand Down Expand Up @@ -66,6 +62,105 @@ class ContentDirectory extends Service {
}
})
}

async Browse (options) {
return this._request('Browse', options)
}

async DestroyObject (options) {
return this._request('DestroyObject', options)
}

/**
* See: http://docs.python-soco.com/en/latest/api/soco.music_library.html#soco.music_library.MusicLibrary.album_artist_display_option
*
* Possible values are:
* 'WMP' - use Album Artists
* 'ITUNES' - use iTunes® Compilations
* 'NONE' - do not group compilations
*/
async GetSearchCapabilities () {
return this._request('GetSearchCapabilities', {}).then(
(r) => r.SearchCaps
)
}

async GetSortCapabilities () {
return this._request('GetSortCapabilities', {}).then((r) => r.SortCaps)
}

async GetSystemUpdateID () {
return this._request('GetSystemUpdateID', {}).then((r) => r.Id)
}

async GetAlbumArtistDisplayOption () {
return this._request('GetAlbumArtistDisplayOption', {}).then(
(r) => r.AlbumArtistDisplayOption
)
}

async GetLastIndexChange () {
return this._request('GetLastIndexChange', {}).then(
(r) => r.LastIndexChange
)
}

async FindPrefix (ObjectID, Prefix) {
return this._request('FindPrefix', {
ObjectID,
Prefix
})
}

async GetAllPrefixLocations (ObjectID) {
return this._request('GetAllPrefixLocations', {
ObjectID
})
}

async CreateObject (ContainerID, Elements) {
return this._request('CreateObject', {
ContainerID,
Elements
})
}

async UpdateObject (ObjectID, CurrentTagValue) {
return this._request('UpdateObject', {
ObjectID,
CurrentTagValue
})
}

async RefreshShareIndex (AlbumArtistDisplayOption = '') {
return this._request('RefreshShareIndex', {
AlbumArtistDisplayOption
})
}

async RequestResort (SortOrder) {
return this._request('RequestResort', {
SortOrder
})
}

async GetShareIndexInProgress () {
return this._request('GetShareIndexInProgress', {}).then(
(r) => r.IsIndexing !== '0'
)
}

async GetBrowseable () {
return this._request('GetBrowseable', {}).then(
(r) => r.IsBrowseable !== '0'
)
}

async SetBrowseable (Browseable) {
return this._request('SetBrowseable', {
Browseable
})
}
}

module.exports = ContentDirectory
14 changes: 7 additions & 7 deletions lib/services/RenderingControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ class RenderingControl extends Service {
}

/**
* (Un)set bass of a speaker.
* @param {boolean} loudness Should it be with or without bass?
* Set bass of a speaker.
* @param {integer} bass desired level of bass, range from -10 to +10
*/
async SetBass (bass) {
return this._request('SetBass', {
InstanceID: 0,
DesiredBass: (bass ? '1' : '0')
DesiredBass: bass
})
}

Expand All @@ -131,13 +131,13 @@ class RenderingControl extends Service {
}

/**
* (Un)set treble of a speaker.
* @param {boolean} treble Should it be with or without treble?
* Set treble of a speaker.
* @param {integer} treble desired level of treble, range from -10 to +10
*/
async SetTreble (treble) {
return this._request('SetTreble', {
InstanceID: 0,
DesiredTreble: (treble ? '1' : '0')
DesiredTreble: treble
})
}

Expand All @@ -153,7 +153,7 @@ class RenderingControl extends Service {

/**
* (Un)set room calibration status (TruePlay) of a speaker.
* @param {boolean} enabled Should it be with or without treble?
* @param {boolean} enabled Should it be with or without truePlay?
*/
async SetRoomCalibrationStatus (enabled) {
return this._request('SetRoomCalibrationStatus', {
Expand Down
Loading

0 comments on commit a8674ff

Please sign in to comment.