Skip to content

Commit

Permalink
fix: Allow joining groups
Browse files Browse the repository at this point in the history
Fixes #22
  • Loading branch information
Stephan van Rooij committed Dec 27, 2019
1 parent 26b7926 commit d2d8a4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions examples/zones.js
@@ -0,0 +1,7 @@
const SonosDevice = require('../lib').SonosDevice

const sonos = new SonosDevice(process.env.SONOS_HOST || '192.168.96.56')

sonos.JoinGroup('keuken')
.then(console.log)
.catch(console.error)
4 changes: 2 additions & 2 deletions src/helpers/zone-helper.ts
Expand Up @@ -3,12 +3,12 @@ import { XmlHelper } from '../'
import { URL } from 'url'
export class ZoneHelper {
static ParseZoneGroupStateResponse(zoneGroupStateResponse: GetZoneGroupStateResponse): ZoneGroup[] {
return this.DecodedObjectToGroups(XmlHelper.DecodeAndParseXml(zoneGroupStateResponse.ZoneGroupState))
return ZoneHelper.DecodedObjectToGroups(XmlHelper.DecodeAndParseXml(zoneGroupStateResponse.ZoneGroupState))
}

static DecodedObjectToGroups(state: any): ZoneGroup[] {
const groups = Array.isArray(state.ZoneGroupState.ZoneGroups.ZoneGroup) ? state.ZoneGroupState.ZoneGroups.ZoneGroup : [state.ZoneGroupState.ZoneGroups.ZoneGroup]
return groups.map(this.ParseGroup)
return groups.map(ZoneHelper.ParseGroup)
}

private static ParseGroup(group: any): ZoneGroup {
Expand Down

0 comments on commit d2d8a4f

Please sign in to comment.