Custom commands and Google Assistant

I’m working on creating a device handler for my Roku TV with multiple custom commands (as device.button).

Is it possible to trigger these custom commands with Google Assistant? I can turn the TV on and off using a device.switch but I can’t seem to trigger a device.button with GA.

For example:

command "home"
...
standardTile("buttonHome","device.button", width: 2, height: 1, canChangeIcon: true, decoration: "flat") {
  state "default", label: 'Home', action: "home", icon: "st.security.alarm.on", backgroundColor: "#79b821"
}
...
def home() {
  sendKeypress("Home")
}

I tried various Google Assistant commands such as “set TV to home” and “press TV home button” which fail.

Thanks for the help

I’ve only found two ways of getting google assistant to interact with my ST devices; using switches - leading to awkward command where everything is “OK Google, switch on …”, or the more involved approach where you build a smartapp that exposes a REST API and then send messages to that from IFTTT. This has allowed me to have much more intuitive voice commands like “OK Google, tell the Sitting Room player to play” for device types not currently supported by the GA integration. It’s a bit of a pain getting the OAuth token for the smartapp but once you’ve got it you can just include it in the URL you invoke from IFTTT.

If you’re interested here’s my code for the REST service. You could adapt it to invoke any commands you wanted easily enough. I’ve also done some fairly crude fuzzy logic to help the device name matching when GA doesn’t hear you quite right.

If you can trigger what you want using WebCore, you might try this…

You can activate SmartThings routines with Google Assistant. You might create a routine, maybe “TV home”, then use WebCore to do the custom commands you need whenever that routine is activated. Then you say, “Hey Google, Activate ‘TV home’”.

Thanks for providing alternative solutions and some sample code! I’m going to try to implement the REST method.

I wonder if Google plans on integrating with custom commands in the future…

I’m not too familiar with WebCore yet, but this looks like a great option. Thanks for the info; I’ll be digging into this

You may not be interested in a “packaged” approach, but using the Harmony hub/remote combo will allow you voice and webCore control over your TV activities, including starting your Roku activity (turning all devices on that need to be on, setting inputs, etc.) pausing and playing, volume, etc. It also provides control over SmartThings devices (e.g., you could create an activity in Harmony that starts up your Roku activity and also turns certain lights on or off, and (if you have a TTS speaker) says “I"m watching Roku - silence in the house!” :smiley: