From 9c25f03f24bfca074e5947648942be9a6b7a54c8 Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Wed, 17 Mar 2021 11:41:09 -0400 Subject: [PATCH] fix: play/paus/prev/next PUTs not working (#11) --- index.js | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 6da2238..e0781bd 100644 --- a/index.js +++ b/index.js @@ -116,7 +116,7 @@ module.exports = function(app) { handleDelta ) - registerForPuts('entertainment.device.fusion1.') + registerForPuts('entertainment.device.fusion1') } function registerForPuts(prefix) { @@ -129,19 +129,25 @@ module.exports = function(app) { ZONES.forEach(zone => { app.registerPutHandler( self, - prefix + `output.${zone}.volume.master`, + prefix + `.output.${zone}.volume.master`, (context, path, value, cb) => { - sendCommand(deviceid, { action: 'setVolume', zone, value}) + sendCommand(deviceid, { + action: 'setVolume', + device: prefix, + zone, + value + }) return completed } ) app.registerPutHandler( self, - prefix + `output.${zone}.isMuted`, + prefix + `.output.${zone}.isMuted`, (context, path, value, cb) => { sendCommand(deviceid,{ - action: value === true ? 'mute' : 'unmute' + action: value === true ? 'mute' : 'unmute', + device: prefix }) return completed } @@ -149,10 +155,11 @@ module.exports = function(app) { app.registerPutHandler( self, - prefix + `output.${zone}.source`, + prefix + `.output.${zone}.source`, (context, path, value, cb) => { sendCommand(deviceid,{ action: 'setSource', + device: prefix, value }) return completed @@ -162,10 +169,11 @@ module.exports = function(app) { app.registerPutHandler( self, - prefix + 'state', + prefix + '.state', (context, path, value, cb) => { sendCommand(deviceid,{ - action: value === 'on' ? 'poweron' : 'poweroff' + action: value === 'on' ? 'poweron' : 'poweroff', + device: prefix }) return completed } @@ -173,10 +181,11 @@ module.exports = function(app) { app.registerPutHandler( self, - prefix + 'play', + prefix + '.play', (context, path, value, cb) => { sendCommand(deviceid,{ - action: 'play' + action: 'play', + device: prefix }) return completed } @@ -184,10 +193,11 @@ module.exports = function(app) { app.registerPutHandler( self, - prefix + 'pause', + prefix + '.pause', (context, path, value, cb) => { sendCommand(deviceid,{ - action: 'pause' + action: 'pause', + device: prefix }) return completed } @@ -195,10 +205,11 @@ module.exports = function(app) { app.registerPutHandler( self, - prefix + 'prev', + prefix + '.prev', (context, path, value, cb) => { sendCommand(deviceid,{ - action: 'prev' + action: 'prev', + device: prefix }) return completed } @@ -206,10 +217,11 @@ module.exports = function(app) { app.registerPutHandler( self, - prefix + 'next', + prefix + '.next', (context, path, value, cb) => { sendCommand(deviceid,{ - action: 'next' + action: 'next', + device: prefix }) return completed }