Update ST tile based on Sonons 'audioTrackData' - can't


#1

Hi Community,

I am trying to create the following automation:
When Sonos changes to ‘Line In - Home Theater’ -> turn On a virtual ‘TV’ tile in SmartThings.

I can see in the IDE that the Sonos device has a audioTrackData parameter, and it is changing to {"mediaSource": "Line-in - Home Theater"}, but I can’t seem to use the ‘audioTrackData’ in an IF statement, as the ‘what kind of comparison?’ drop down is empty (for some odd reason):



#2

95% of the time, attributes that begin with “$” or pic cannot be used as a trigger .


pic

They usually work as a condition, though.


#3

Sonos is an exception to that, although I’ve never tried to use the audioTrackData as a trigger.

Edit: Also, I see that in his example he’s trying to use it as a condition. There might be other issues in the piston causing it to fail.


#4

Actually just tested it. image audioTrackData can be used as a trigger.


#5

Always nice to see an exception. Thanks for the update


#6

Thank you both.

It seems like I am missing something crucial (I just started playing with WebCore recently).
How can I add a trigger instead of a condition? I am not seeing this under the If statement… :thinking:


#7

Quick answer:

  • + add a new statement
  • Add an if
  • Add a condition
  • Select “What to compare”

Every device is different, but under “What kind of comparison”,
conditions will always be at the top, followed by triggers.


#8

This is quite strange.
I am following the exact steps, and when selecting the ‘Sonos’ Physical Device, the ‘what kind of comparison’ dropdown is just blank.


#9

Normally, this is simple as webCoRE can treat conditions as triggers if no actual triggers are present, or you can choose a trigger as @WCmore suggests. However, when the data returned is in json format, as in [Sonos : audioTrackData], webCoRE gets confused and doesn’t give you the options you need. Similarly, it can’t convert conditions containing such expressions to triggers.

The workaround I’ve used is to use an “On Event” statement as a trigger, then evaluate the data using an IF statement and an expression as in this example:

Note that you will have to replace “Unknown Device 4” with your Sonos device name, and replace “Sonos Family” in the expression with that same name. Finally, be sure the text in the “contains” matches what you need in terms of capitalization, etc. To keep it simple, I’m only matching the text inside the quotes, as matching strings with embedded quotes gets a little more tricky.


#10

Works beautifully.
Thanks for the assistance and time.