Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getPresetObject error if an array of presets is posted #58

Open
carl34 opened this issue Jun 11, 2020 · 1 comment
Open

getPresetObject error if an array of presets is posted #58

carl34 opened this issue Jun 11, 2020 · 1 comment

Comments

@carl34
Copy link

carl34 commented Jun 11, 2020

Ran into this error and found a few instances in the forum, for example: https://community.smartthings.com/t/release-cast-web-v1-2-1-chromecast-device-handler-smartapp/88038/1164

It appears to have been introduced when support for an array of media elements was added, I'm not sure if the candidate fix introduces any regressions, but arrays and single media elements are working for me after the code change below.

Test Preset object to cause the error:

{"preset1":[{"mediaTitle":"mp3test","mediaSubtitle":"testing mp3 preset","mediaType":"audio/mp3","mediaUrl":"http://host:3000/test.mp3","mediaStreamType":"LIVE","mediaImageUrl":""}],"preset2":[{"mediaTitle":"Preset 2","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""}],"preset3":[{"mediaTitle":"Preset 3","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""}],"preset4":[{"mediaTitle":"Preset 4","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""}],"preset5":[{"mediaTitle":"Preset 5","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""}],"preset6":[{"mediaTitle":"Preset 6","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""}]}

Error:

error groovy.lang.MissingPropertyException: No such property: mediaTitle for class: org.json.JSONArray @line 352 (getPresetObject)
debug Executing 'playPreset': 1, key: preset1, defaultMediaTitle: Preset 1
debug Executing 'preset1'

A workaround discussed in the forum to avoid the error involved removing the brackets so that arrays aren't used (this is an incomplete workaround though because an array of media elements can't be used):

{"preset1":{"mediaTitle":"mp3test","mediaSubtitle":"testing mp3 preset","mediaType":"audio/mp3","mediaUrl":"http://host:3000/test.mp3","mediaStreamType":"LIVE","mediaImageUrl":""},"preset2":{"mediaTitle":"Preset 2","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""},"preset3":{"mediaTitle":"Preset 3","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""},"preset4":{"mediaTitle":"Preset 4","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""},"preset5":{"mediaTitle":"Preset 5","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""},"preset6":{"mediaTitle":"Preset 6","mediaSubtitle":"","mediaType":"","mediaUrl":"","mediaStreamType":"","mediaImageUrl":""}}

The goal is to find a way to retain the ability to provide an array for each preset.

@carl34
Copy link
Author

carl34 commented Jun 11, 2020

Candidate PR, #59

carl34 added a commit to carl34/smartthings that referenced this issue Jun 11, 2020
carl34 added a commit to carl34/smartthings that referenced this issue Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant