Hey everyone. It’s been a very long time since I’ve attempted to write a SmartApp and am having trouble with how to begin, let alone the code necessary to accomplish it.
I’m trying to write an app that monitors the Now Playing field (trackDescription) of a specific Sonos speaker and whenever it changes, to send off that value of the now playing track as a string via an HTTP Post request to another web service I have running. The goal is to show the now playing track at all times on a separate display that is near the speaker. The web service works no problem and I can manually trigger http requests with hardcoded strings and it displays with no issue.
The HTTP request I need to send out is (the access keys and URI are not real, just need to understand the syntax):
URL:
https://somewebservice.com/api/v1/dev/widget/update/com.webservice.a6a323440f15fabab44392352343245
Headers:
accept: application/json
X-Access-Token: YjE4ZWga3M2NmYmI1YTcyZjFkYmI3ZWVjMzY0OThkZjJiMaeHDJWQ2NTIwMDY2ZTQwYWUxNmNiN2I0MGQ5ODE2Mw==
Cache-Control: no-cache
Body:
{
“frames”: [
{
“text”: " Now Playing",
“icon”: “null”
},
{
“text”:" Song Title - Song Band", //<-----now playing track string goes here
“icon”:“null”
}
]
}
Any help here would be absolutely completely appreciated. It is a very simple app in that when a value changes, to just send off that value in a webhook, but I can’t for the life of me even think about where to begin, let alone the syntax of how to write it.
Thanks everyone!