JSON variable type?

Hi,

I have music playing on several Sonos speakers and a rule for door contacts that plays a chime on the Sonos speakers.

I setup a rule to capture the last track and volume into 2 variables:

If a add second rule to check for 'TTS' (Text To Speech) being played:

Rule machine complains of JSON vs. string mismatch.

That's a bit odd since the hub variable 'Sonos_LastTrackData' is created as a String.
Is there some casting to JSON happening behind the scene?

How do I check for values in this variable in Rule Machine?

The attribute has the type indicated, and RM doesn't like comparing two different attribute types (since usually it makes no sense). Try putting that attribute into a String variable first, and then do the comparison.

Doesn't seem like I can do what I want, what's the limit on string variables?

Blockquote
Variable length limit exceeded for Sonos_LastTrackData, value truncated, disposed: i-hls-static:ALkSOiEMib4caR-Lucs-6ejyCwOtsUWqmVhogjBHX_bYZyuw?sid=284&flags=8&sn=5","transportUri":"x-rincon-queue:RINCON_7828CAF404FE01400#0","enqueuedUri":"x-rincon-cpcontainer:0006002cALkSOiGp1ht9n_tIPhWYArzvTjlWBD1PFh3oZdwKLC0RZ5q2?sid=284&flags=44&sn=5","metaData":"Wintertime Warmth<\/dc:title>object.container.playlistContainer<\/upnp:class>Playlist<\/dc:creator>https:\/\/lh3.googleusercontent.com\/9CcRQ3Ez6tNGWSr8e2GvZihgOd_3IgLEldrGHIDXQpwTC4k78z3FuCIuXAznp32PR5EGSOorNeH9Cw=w544-h544-l90-rj<\/upnp:albumArtURI>Recently Played<\/r:description>SA_RINCON72711_X_#Svc72711-0-Token<\/desc><\/item><\/DIDL-Lite>","trackMetaData":"x-sonosapi-hls-static:ALkSOiEMib4caR-Lucs-6ejyCwOtsUWqmVhogjBHX_bYZyuw?sid=284&flags=8&sn=5<\/res><\/r:streamContent><\/r:radioShowMd>bd:0,sr:0,c:0,l:0,d:0<\/r:streamInfo>\/getaa?s=1&u=x-sonosapi-hls-static%3aALkSOiEMib4caR-Lucs-6ejyCwOtsUWqmVhogjBHX_bYZyuw%3fsid%3d284%26flags%3d8%26sn%3d5<\/upnp:albumArtURI>Let's Stay Together<\/dc:title>object.item.audioItem.musicTrack<\/upnp:class>Al Green<\/dc:creator>Let's Stay Together<\/upnp:album><\/item><\/DIDL-Lite>"}

I think I'm going to end up writing my own Sonos driver, I'd want crossfade as well.
https://developer.sonos.com/reference/types/play-modes/

Building a "smart home" sure isn't easy :frowning:

1 Like