Skip to content

Commit

Permalink
fix: play/paus/prev/next PUTs not working (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 authored Mar 17, 2021
1 parent 2b024be commit 9c25f03
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = function(app) {
handleDelta
)

registerForPuts('entertainment.device.fusion1.')
registerForPuts('entertainment.device.fusion1')
}

function registerForPuts(prefix) {
Expand All @@ -129,30 +129,37 @@ 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
}
)

app.registerPutHandler(
self,
prefix + `output.${zone}.source`,
prefix + `.output.${zone}.source`,
(context, path, value, cb) => {
sendCommand(deviceid,{
action: 'setSource',
device: prefix,
value
})
return completed
Expand All @@ -162,54 +169,59 @@ 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
}
)

app.registerPutHandler(
self,
prefix + 'play',
prefix + '.play',
(context, path, value, cb) => {
sendCommand(deviceid,{
action: 'play'
action: 'play',
device: prefix
})
return completed
}
)

app.registerPutHandler(
self,
prefix + 'pause',
prefix + '.pause',
(context, path, value, cb) => {
sendCommand(deviceid,{
action: 'pause'
action: 'pause',
device: prefix
})
return completed
}
)

app.registerPutHandler(
self,
prefix + 'prev',
prefix + '.prev',
(context, path, value, cb) => {
sendCommand(deviceid,{
action: 'prev'
action: 'prev',
device: prefix
})
return completed
}
)

app.registerPutHandler(
self,
prefix + 'next',
prefix + '.next',
(context, path, value, cb) => {
sendCommand(deviceid,{
action: 'next'
action: 'next',
device: prefix
})
return completed
}
Expand Down

0 comments on commit 9c25f03

Please sign in to comment.