-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3701d8f
commit e9fd6f5
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |