Send custom commands from Google Assistant


I needed to send custom commands to custom devices, so I found a trick to achieve this.

I experienced this with a gate that can be either fully opened either ~20% open for pedestrians by the original remote. To bypass the remote I have mounted two relays on the gate to be able to control it. To control the relays I have an ESP8266 that OpenHAB can send any commands to, as I interpret them in the ESP82SS code. But it will work with any device supported by OpenHAB and not by Google Assistant.

The main difficulty was to be able to talk to Google Assistant (will be referred as GA from now) and catch the event in my OpenHAB to sent custom commends afterwards.

What you need before going further :

  • Some custom device to send commands to (for me it’s the ESP8266, but as said earlier any device will work).
    • There’s a great tuto here on how to connect devices to OpenHAB
  • Install the openHAB Cloud Connector add-on (Paper UI => Add-Ons => MISC. ==> openHAB Cloud Connector)
  • Make it work with GA. (It’s all explained here)

The trick now is pretty simple, you will need to add a proxy item in your .items :

Rollershutter	Gate_Rollershutter   "Gate"  {ga="Garage"}
  • Rollershutter => this is supported by GA.
  • "Gate" => the name you will see in your GA’s app.
  • {ga="Garage"} => make it available in your GA configuration.

Next step, create the rule to catch events and send custom commands.

rule "RuleGate"
    Item Portail_Rollershutter received command
    switch(Portail_Rollershutter.state) {
        case 0: {
        case 100: {
        case 80: {
            //Something else

Explanation is pretty straight forward, when the proxy item receive a command, it triggers the switch and then sends a command "OPEN" or "CLOSE" to Gate_Relay which is defined in my .items file as :

Number    Test_Relay   {channel="mqtt:topic:**********:*******"}

But here you can define whatever Item you want. You can also add multiple lines in one case to have multiple commands sent when the GA’s routine is triggered.

Talking about GA’s routine, the next step is to create a routine inside GA’s app to trigger the commands in the rule. For this example, one of the routines will be

This will trigger the case 80 in my .rules.

And that’s it. Now you can customize this example to have multiple commands sent by the .rule to any device by saying whatever you want to GA.

I encountered many issues while working on this trick. So feel free to ask if you have yourself an issue, or if I’m nor clear enough, I will edit this tuto. If you need help with the ESP8266 part I might help too.

1 Like

Can’t you use routines also? They let you define custom commands. I have one that is I am home. So I say hey google I am home and lights turn on.

1 Like

Hi @Playdric,

I appreciate you posting your solution. There are a lot of things that are specific to your needs, so I think it would help to simplify your tutorial down to the concepts so that others can see how to apply them.

If I understand correctly, this comes down to using proxy items (what you’ve called fake items) that can be exposed to Google Assistant, enabling you to pass commands to items that don’t have GA-friendly states (On/Off, Open/Closed, etc.). So, it doesn’t matter whether the endpoint devices are ESP8266 or something else entirely–what’s important is that the devices can’t directly be controlled in Google Assistant.

Using proxy items with rules is a good solution, not just for Google Assistant but for any case where it’s beneficial to have a binary switch that does something non-binary. For example, I have an “Away Mode” proxy item that unlocks my door and turns off the lights when I’m leaving my house. So as you note, this is a great way to have custom actions from a single GA command.

You can get very specific with your proxy item’s name, as you’ve done, but as @Thedannymullen points out you can also use GA’s routines for custom commands. I’ve set up one-word routines for my light switches so that I can say “bedroom” instead of “bedroom on” (yes, I’m that lazy). Personally, I prefer this approach since I can keep the item names short in the Google Home app. Plus, you can specify a lot of phrases in a single routine.

Thanks for sharing!


Thank you for this, now that IFTTT has limited its free users to 3 applets I was looking for another way of using custom commands and I wouldn’t have thought of this