Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
marco79cgn authored Sep 14, 2022
1 parent 3701d8f commit e9fd6f5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions sonos-toggle-playback.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: orange; icon-glyph: play;
const SONOS_BASE_URL = "http://192.168.178.10:5005"
const SONOS_ROOM = "kitchen"

let widget = await createWidget()
Script.setWidget(widget)
Script.complete()
// widget.presentSmall()

async function createWidget() {

let widget = new ListWidget()

// load symbol image
let symbolSpeaker = widget.addImage(SFSymbol.named("playpause.fill").image)
symbolSpeaker.imageSize = new Size(45,45)
symbolSpeaker.centerAlignImage()

if(config.runsInApp) {
await togglePlayback()
}

return widget
}



// toggle playback by using node-sonos-http-api
async function togglePlayback() {
let request = new Request(SONOS_BASE_URL + "/" + SONOS_ROOM +"/playpause")
request.allowInsecureRequest = true
let json = await request.loadJSON()
return json
}

0 comments on commit e9fd6f5

Please sign in to comment.