[RELEASE] cast-web v1.2.1 - Chromecast Integration (EDGE Driver discussion begins in post 1668)

Nice…will give the beta a try. I’m actually using a ported webCoRE in Hubitat and would like to use the Make web request option. By using post i can send the request to the app - x.x.x.x:3000/playMedia. What other parameters do i need to add, say if i wanted to speak out “Hello World”?

Would it be something like this - 1.1.1.1:3000/playMedia?GoogleTTS=en&text=Hello World

This would be HTTP GET, the new api call for that is {api:port}/{cast-device-id}/playMediaGet/{JSON array object with all parameters}

I’d prefer using POST, since you don’t really need to HTTP encode/decode, thus the path is {api:port}/{cast-device-id}/playMedia and the post data is a JSON array object with all the media info, just like above.

The most minimal json object just for tts would be:
[{"mediaTitle":"Hello world, this is my text", "mediaSubtitle": "Audio notification", "mediaImageUrl":"http://example.com/image.jpg", "GoogleTTS":"en-US"}]

API v1 also supports queueing, so you can just append as many JSON objects you want, separated by commas:
[{"mediaTitle": .... }, {"mediaTitle": .... }, {"mediaTitle": .... }]

Since it’s json, you can always test for validity with something like an online parser. It’ll tell you if the syntax is wrong :slight_smile:

I think i get all of it except for the ‘cast-device-id’. What would this be? I ran the api and this is an example line that came out:-

E9AA146F-1B4F-4FA1-8FF3-83CA0D39D357 discover(): added device name: Home group, address: {"host":"10.14.122.179","port":42851}

which part of the above is the cast-device-id? or is it something completely different…

Just open {ip:port}/device/ in your browser. It will list all of your devices, names, ids and connection status. Its also JSON if you want it more readable, parse it online or install a browser extension.

Oh and that would be the id. But no need to hunt down terminal messages :slight_smile:

Update: it’s /device/ without s. Also check out the docs.

1 Like

Awesome! Once i play around and figure out how to include all those JSON objects into webCoRE (i hope it’s possible), i’ll let you know on the outcome.

1 Like

Out of curiosity, where can i get the ST smart app and DTH from?

From the repo https://github.com/vervallsweg/smartthings

If you want v1 dth, select the v1 branches.

  1. From the above it seems that 1.1.1.1:3000/abcd1234/playMediaGet/{JSON}
    But per your Github notes it seems we need to add “device” into every command? e.g. 1.1.1.1:3000/device/abcd1234/playMediaGet/{JSON}

  2. Last, is it /playMediaGet/{JSON} with the forward-slash between the API command and the JSON data or is it similar to the way it was in v0.30? e.g playMediaGet?mediatype=&mediaUrl=&mediaStreamType=&mediaTitle=&mediaSubtitle=&mediaImageUrl=

I tried a few things but i keep getting the below error:-

26374e30d8aea8bfcefc8ba082b49ae1 CastDevice.playMedia(): exception: TypeError: media.forEach is not a function

The response i got was ‘ok’

The url i used was - http://1.1.1.1:3000/device/1234abcd/playMedia?mediaTitle=Hello world&mediaSubtitle=Audio notification&mediaImageUrl=http://example.com/image.jpg&GoogleTTS=en-US

i also tried http://1.1.1.1:3000/device/1234abcd/playMedia?
and sending the parameters in the request header and separately in request body also gives back the same error.

Used POST.

Looks like “device” needed to be there…i think. Without /device i keep getting response error. Any advice?

Yup, my bad. Messed up /devices/ and /device/ should be /device/. Yes it’s actually quite simple /device/ lists them all /device/{id} shows just the selected and then /device/{id}/{command} controls the device.

Forward slash. You just dump a JSON array after the command /device/{id}/playMediaGet/[{"mediaTitle":"title", ...}]

Yeah, because your link is not json data. Should be in your case:
http://1.1.1.1:3000/device/1234abcd/playMediaGet/[{"mediaTitle":"Hello world", "mediaSubtitle":"Audio notification", "mediaImageUrl": "http://example.com/image.jpg", "GoogleTTS":"en-US"}]

And please don’t use example.com :joy: should link to an actual image.

For POST:
URL: http://1.1.1.1:3000/device/1234abcd/playMedia/
DATA: [{"mediaTitle":"Hello world", "mediaSubtitle":"Audio notification", "mediaImageUrl": "http://example.com/image.jpg", "GoogleTTS":"en-US"}] (same as above)

As said above to aniceberg, /device/ lists them /device/{id}/{command} controls them.

Hi. Still not having much luck. This is the piston used on webCoRE:

This was the error that i see from the console:

Just tested this and I can happily confirm it works. One “bug” I found is that it doesn’t update the device tile in ST with the current media status. For that you need to hit the “refresh” button, unlike in v0.30 where it refreshed automatically.

It’s a JSON array! []

Object = {}
Array = []

Array with objects: [ {}, {}, {} ]

You simply forgot to wrap it in [ ]

It calls data.forEach() . You cannot call forEach on a JSON object, only on arrays. This is why you get the error message from above :slight_smile:

Update: After you fixed this, there’ll be another error. Look at the data that webCoRE posts. Then look at the data that the API logs, it received. It seems like there’s something wrong with your GoogleTTS variable. Instead of posting the value, webCoRE posts an error message and adds that to the post data.

Yeah there’s a typo in your webCoRE variables. You define them with googleTTS line 20 with lowercase g and access GoogleTTS in line 27 with uppercase G. The later variable doesn’t exist and webCoRE posts an error message.

1 Like

My bad. As you can see, I’m nowhere close to being a programmer :yum:
Will check and see how that can be sent through with webCoRE.

2 Likes

On the version 1.0, using GoogleTTS, is there a limit on character count? I tried sending a pretty long string and i hear the chime on the GH’s come on, but nothing spoken. When shortening it, then it works.

Yes. I believe 200 characters. Will fix it in the future. For now, just split manually and queue them, if you really need more than 200.

Will do. The queuing works perfectly! Good stuff.

1 Like

When installing the cast-web-service-manager
I’m getting

Groovy.lang.MissingMethodException: No signature of method: script_dth_metadata_82bb8089_7489_4327_a02a_854760aacbea.appSetting() is applicable for argument types: (java.lang.String) values: [api] Possible solutions: typeSetting(java.lang.String), typeSetting(java.util.Map), typeSetting(java.lang.String, java.lang.String), getSettings(), setSettings(java.lang.Object), typeSetting(java.lang.String, java.lang.String, java.util.List)

Which instructions did you follow? And when do you get this message, after opening the SM or installing devices through it?

https://vervallsweg.github.io/smartthings/

When I try to paste the code into the following to make a new device handler.
https://graph-na04-useast2.api.smartthings.com