Opening/closing using google assistant

TL;DR “close the gate” doesn’t work with google assistant, but “close the gate down” works.

  • Platform information:
    • Hardware: x86_64
    • OS: Ubuntu 18.04.2 LTS
    • Java Runtime Environment: 1.8.0_181
    • openHAB version: openHAB 2.5.0.M1 Milestone Build

I am trying to control a gate using openhab and google assistant.
I have a gate controller that responds to “open” and “close” commands via MQTT.
I can control the gate manually using openhab by sending these commands.
I can also open the gate by saying “ok google, open the gate” with google assistant. This sends an “UP” command to Gate_Proxy which I translate to an “open” command.
When I say, “ok google, close the gate”, google assistant responds with “ok, I’m closing the gate” - but no command is sent to the server. I expect a “DOWN” command to be sent here.

items:

// send gate command (open/close)
String Gate_Command "Gate command" <garagedoor> {channel="mqtt:homie300:3854cdbc:kuromaru-gate:gate#command"}

// gate state (open/closed/opening/closing)
String Gate_State "Gate state" {channel="mqtt:homie300:3854cdbc:kuromaru-gate:gate#state"}

// gate position in percentage (0 = closed, 100 = open)
Number Gate_Position "Gate position" {channel="mqtt:homie300:3854cdbc:kuromaru-gate:gate#position"}

// gate proxy item, tracks state of gate and maps to UP/DOWN
// see also gate.rules
Rollershutter Gate_Proxy "Gate" [ "Rollershutter", "Blinds" ]

rules file:

rule "Update Gate_Proxy from Gate_State"
when
        Item Gate_State changed or System started
then
        if (Gate_State.state == NULL) return;

        if (Gate_State.state.toString == "open") {
                logInfo("org.openhab.rules", "Changing Gate_Proxy state to UP")
                Gate_Proxy.postUpdate("UP")
        } else if (Gate_State.state.toString == "closed") {
                logInfo("org.openhab.rules", "Changing Gate_Proxy state to DOWN")
                Gate_Proxy.postUpdate("DOWN")
        }
end

rule "Forward Gate_Proxy commands to Gate_Command item"
when
        Item Gate_Proxy received command
then
        logInfo("org.openhab.rules", "received Gate_Proxy command: " + receivedCommand.toString)
        if (receivedCommand.toString == "UP") {
                logInfo("org.openhab.rules", "Forwarding command UP to Gate command open")
                Gate_Command.sendCommand("open")
        } else if (receivedCommand.toString == "DOWN") {
                logInfo("org.openhab.rules", "Forwarding command DOWN to Gate command close")
                Gate_Command.sendCommand("close")
        } else {
                logInfo("org.openhab.rules", "unhandled gate command " + receivedCommand)
        }
end

Have a look in events.log to see what actually happens

Thanks rosko, I have been looking at events.log (and openhab.log). I can see an “UP” command come through when I ask Google to open the gate. Nothing appears in the logs for close gate.

Okay, so its not about rules or MQTT. You’ll need to be looking at the Google part.

I just looked at the documentation for the google assistant openhab service.
https://assistant.google.com/services/a/uid/000000f5c61c627e?hl=en-US
It has as example commands “open blinds” and “close blinds down”, but no “close blinds”.
I just tested “close gate down”, and that works - I receive a DOWN command. It would be nice if it would work without the “down” word though.

I believe you can setup a routine in google to do this. Look at routines in the app.

Google hasn´t released routines in all countries yet. We´re still waiting in Denmark… Dont know where Andrew is from though.

Hi guys, im in Australia and i have routines.
That’s a good workaround for the problem.
For some reason the assistant doesn’t speak its response to the routine command, but it works.

1 Like

today I am able to just say “Close the gate”, and it works. I receive the DOWN command. I haven’t changed anything. So that’s a bit of a mystery.

I’m gonna put that one on Google. As others have said, living with Google means living in a world where everything is in beta.

I’m generally forgiving of their constant tinkering, but sometimes it’s annoying when something you’re used to doing changes just enough to throw you off. On the flip side, I think they do themselves a disservice by constantly adding new features to Google Assistant and never actually telling users about them.

1 Like

Hello, i re-open this thread hope that someone can help me.
I’ve an item SWITCH on oh 3.4 defined as “gate” for google assistant to use “open” and not “power on or switch on (don’t know in english… i use it in Italian”. But open the gate doesn’t work. It works power on gate (accendi cancello).
This is my item definition :
Switch D2ApriCancello “Cancello” (grp1, Diagnostic) {ga=“Gate”, autoupdate=“false”, channel=“souliss:t14:71:23-0:pulse”}

Thanks for help

Ok door and NOT gate is the solution