From 0b457f9b7f0c361ca58939ab83df7a9fdb27cfb1 Mon Sep 17 00:00:00 2001 From: bezzers Date: Thu, 23 Jul 2015 09:36:37 -0400 Subject: [PATCH] Create a Sonos Platform handler - first version Creates a platform for Sonos that scans for all Sonos boxes and adds any that are not bridges (type 11) as accessories. Reads the names of each box from the Sonos configuration and creates device names based on the Sonos room names. --- platforms/Sonos.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/platforms/Sonos.js b/platforms/Sonos.js index 47a078a..91bd04d 100644 --- a/platforms/Sonos.js +++ b/platforms/Sonos.js @@ -19,7 +19,7 @@ SonosPlatform.prototype = { if (description["zoneType"] != '11') { that.log("Found playable device - " + description["roomName"]); // device is an instance of sonos.Sonos - var accessory = new SonosAccessory(that.log, device, description); + var accessory = new SonosAccessory(that.log, that.config, device, description); callback([accessory]); } }); @@ -27,11 +27,15 @@ SonosPlatform.prototype = { } }; -function SonosAccessory(log, device, description) { +function SonosAccessory(log, config, device, description) { this.log = log; + this.config = config; + this.device = device; this.description = description; - this.name = description["roomName"] + " Sonos"; - this.playVolume = 25; + + this.name = this.description["roomName"] + " " + this.config["name"]; + this.serviceName = this.description["roomName"] + " Speakers"; + this.playVolume = this.config["play_volume"]; } SonosAccessory.prototype = { @@ -130,7 +134,7 @@ SonosAccessory.prototype = { onUpdate: null, perms: ["pr"], format: "string", - initialValue: this.description["roomName"] + " Speakers", + initialValue: this.serviceName, supportEvents: false, supportBonjour: false, manfDescription: "Name of service",