getServices: function() { var that = this; var informationService = new Service.AccessoryInformation(); var yamaha = this.yamaha; informationService .setCharacteristic(Characteristic.Name, this.name) .setCharacteristic(Characteristic.Manufacturer, "Yamaha") .setCharacteristic(Characteristic.Model, this.sysConfig.YAMAHA_AV.System[0].Config[0].Model_Name[0]) .setCharacteristic(Characteristic.SerialNumber, this.sysConfig.YAMAHA_AV.System[0].Config[0].System_ID[0]); var switchService = new Service.Switch("Power State"); switchService.getCharacteristic(Characteristic.On) .on('get', function(callback, context){ yamaha.isOn().then(function(result){ callback(false, result); }.bind(this)); }.bind(this)) .on('set', function(powerOn, callback){ this.setPlaying(powerOn).then(function(){ callback(false, powerOn); }, function(error){ callback(error, !powerOn); //TODO: Actually determine and send real new status. }); }.bind(this)); var audioDeviceService = new YamahaAVRPlatform.AudioDeviceService("Audio Functions"); audioDeviceService.getCharacteristic(YamahaAVRPlatform.AudioVolume) .on('get', function(callback, context){ yamaha.getBasicInfo().done(function(basicInfo){ var v = basicInfo.getVolume()/10.0; var p = 100 * ((v - that.minVolume) / that.gapVolume); p = p < 0 ? 0 : p > 100 ? 100 : Math.round(p); debug("Got volume percent of " + p + "%"); callback(false, p); }); }) .on('set', function(p, callback){ var v = ((p / 100) * that.gapVolume) + that.minVolume; v = Math.round(v*10.0); debug("Setting volume to " + v); yamaha.setVolumeTo(v).then(function(){ callback(false, p); }); }) .getValue(null, null); // force an asynchronous get return [informationService, switchService, audioDeviceService]; }
getServices: function() { var switchService = new Service.Switch(this.name); var informationService = new Service.AccessoryInformation(); informationService .setCharacteristic(Characteristic.Manufacturer, this.manufacturer) .setCharacteristic(Characteristic.Model, this.model_name) .setCharacteristic(Characteristic.SerialNumber, this.id); switchService .getCharacteristic(Characteristic.On) .on('set', this.setPowerState.bind(this)); return [informationService, switchService]; }
getServices: function() { var informationService = new Service.AccessoryInformation(); informationService .setCharacteristic(Characteristic.Manufacturer, "MPD") .setCharacteristic(Characteristic.Model, "MPD Client") .setCharacteristic(Characteristic.SerialNumber, "81536334"); var switchService = new Service.Switch(); switchService.getCharacteristic(Characteristic.On) .on('get', this.getPowerState.bind(this)) .on('set', this.setPowerState.bind(this)); return [informationService, switchService]; }