Cast-web porting help - SOLVED

Looking to port over the Cast-Web app from ST. Got the 3 pieces installed with the normal minor changes needed.

When running the app, it finds my devices but doesn't populate the dropdown box to select any of them. @rayzurbock has had the same problem in another thread (here).

Hoping to get some brilliant minds to take a look at the code and figure out how to populate the drop down. :slight_smile:

Appreciate any help...thanks!
@Cobra, @stephack, @rayzurbock, @bravenel, @mike.maxwell

All I can offer at this time is to find the code section that's supposed to populate the enum input, add some debug logging to catch the raw data being sent, then figure out why it's not updating the input element.
Specifically look at the data in state.devicesMap and how and if that structure is being created correctly within the parse method.

I'll take cast however I can get it. You two going to race? :wink:

Ummm, yeah, my race car has only three wheels currently, each of which is pointed in a different direction...

2 Likes

As long as they're not all in-line with one another, you're going in the right direction! :smiley:

This should get you set GitHub - jp0550/smartthings at hubitat

The key for the dropdown fix is below

                def options = [:]
                state.devicesMap.each {
                 	options[it.key] = it.value   
                }
                input "selectedDevices", "enum", required:false, title:"Select Cast Device ("+ state.devicesMap.size() +" found)", multiple:true, options: options

@mike.maxwell The best I can figure is that the options dropdown doesn't like to take a map straight from the state (maybe due to the deserialization process). Recreating it solves the issue.

Other hubitat patches to make the rest work are in the repo above. I didn't touch the group sync app code though.

3 Likes

Thank you, @jp0550! The drop down list now populates. I can select a speaker and move on to the next screen. Looks like there is now a problem when it's trying to create the device.

cast-web-api
[dev:1237](http://192.168.86.77/logs#dev1237)2018-07-14 16:17:32.982:errorgroovy.lang.MissingMethodException: No signature of method: dev1531596300248324077442.addChildDevice() is applicable for argument types: (java.lang.String, java.lang.String, java.lang.String, java.lang.Long, java.util.LinkedHashMap) values: [vervallsweg, cast-web-device, 521219da99bcca58d2dd1e52dc0f5806, ...] on line 146 (updated)

If I go into the cast-web-api driver and look at line 146....this is what I see.

Thoughts?

Sure thing, check out my repo above. I got this error fixed as well to the point of controlling devices and seeing their state.

The child device doesn't accept a hub id. Also sending the label caused some weird issues, so I removed it too:

addChildDevice("vervallsweg", "cast-web-device", it, ["apiHost": getDataValue("apiHost")])

Thank you so much, I went to your repo and updated the drivers and apps. Working GREAT! Now to play around with all the options. Thanks again!

2 Likes

If working, would you share the ported app please?

It's all in his repo.

2 Likes

Thanks. This resolved my issue with adding my Google Home devices.
PlayText and Speak functions still did not work for me.
I was getting the following error in Hubitat for the device when I tried these functions:
errorgroovy.lang.MissingMethodException: No signature of method: dev15316173436921026341192.textToSpeech() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [Testing, true] on line 418 (speak)

Line 418 in cast-web-device was the following:
return playTrack( textToSpeech(phrase, true).uri, 0, 0, true )
I modified to:
return playTrack( textToSpeech(phrase).uri, 0, 0, true )

and it is now working.

def speak(phrase, resume = false) {
    if(settings.googleTTS && settings.googleTTSLanguage){
        if(settings.googleTTS==true) {
            return playTrack( phrase, 0, 0, true, settings.googleTTSLanguage )
        }
    }
    //return playTrack( textToSpeech(phrase, true).uri, 0, 0, true )
    return playTrack( textToSpeech(phrase).uri, 0, 0, true )
}

Since I already have Google Assistant Relay working, I found this a bit more involved then I needed.
If anyone is looking for an alternate choice, I instead downloaded the latest nightly for MacOS VLC Player 3.0.4 which is able to Cast and have the HTTP web interface active at the same time.

NOTE: To get this working, I found it was necessary to first disable the HTTP web interface then quit and restart VLC Player. Once it's running again, set the cast device, and then go into the preferences and re-enable HTTP web interface.

Works great, and I now have both my door chime and a verbal announcement of the door that has been opened.

[Edit} I forgot to include something I did previously, and for some time couldn't get this working again. There's an important step after re-starting VLC Player, selecting the Cast device, and then re-enabling HTTP. You then must then go to the VLC menu, choose "Add Interface" and select "Web". It should then work to play a track from Hubitat.

Just wanted to say thanks to @jp0550. This is a nifty feature to have available. Thanks for porting over and sharing.

3 Likes

Question...

If I'm listening to a Google Music radio station and an announcement happens...How do I get it to continue playing the radio station after the announcement?

Hi putnamjwp,
thanks for porting this over to Hubitat. Installed the app & drivers from your repo but can't seem to get the dropdown populated with my cast devices.

  • My cast-web-api node server is working fine - I used it before for cast-web-api on ST
  • The Hubitat app doesn't even hit the node server - not for Test API connection and neither for Discover Devices

The log is inconclusive:

Would appreciate any hints.

Thanks,
Jan

Edit: bptworld -> putnamjwp :wink:

All credit goes to @jp0550. :smile: (I don't even have a repo)

Hi @jp0550,

I'm not sure if you received a notification for my first post a few days ago because I initially used the wrong recipient.

I'd be glad if you could give me a hint what might be wrong if Cast web - service manager doesn't list any devices, even though cast-web-api actually found the devices:

image

Would be glad if you could give me a hint.

Thanks,
Jan

I don't have this installed anymore so I'm not sure off the top of my head. The big thing about it not populating before was this code below which should be in the repo now:

def options = [:]
state.devicesMap.each {
     options[it.key] = it.value   
}
input "selectedDevices", "enum", required:false, title:"Select Cast Device ("+ state.devicesMap.size() +" found)", multiple:true, options: options

For the chromecast fans out there, I finally got some time to poke at our chromecast integration again.
What I have so far is play/pause/stop/set volume, mute/unmute.

The only other possible rev 1 inclusion would be speak (ie TTS), however I have no time to dig into play track, restore/resume types of functionality at this time.

So if I add speak, and you have something already running and you send a speak command, it will not be restored.

Add it?, leave it out, thoughts?

4 Likes