[SOLVED] Google Assistant responding to question about garage door

I have been able to create a rule that Google Assistant will tell me if my garage door is open. I will be traveling for a few weeks this summer. I want to be able to ask Google Assistant from my phone if the the garage door is open or not. Any suggestions.

Use a Switch item to reflect the garage door state. ON if open and OFF if closed. Tag the item as [" Lighting "] then ask GA “Is my garage door ON?”

1 Like

I didn’t even know google can answer such questions :wink:
Using the shortcuts you can even ask correctly: is my garage door open?
but I assume if it will respond back saying something like, lamp garage door is turned on.

Correct it only supports switches so far

I tried changing Contact to Switch, but then the sensor is always off. I can’t query the relay because only in the off then on position will it trigger the garage to open. Using a rule I need to switch the relay switch to off. If it is in the on position, it doesn’t allow the physical garage button to work.
This code works for me to check if it is open. But how do I query Assistant to trigger this query?
rule “close Main reminder”
when
Time cron “0 */30 * ? * *”
then
logInfo(“org.openhab.rules”,“checking open garage door every 30 minutes”)
if (MainDoorSensor.state.toString == “OPEN”) {
say (“The main garage door has been left open”)
}
end

You need another item. Changing your item to switch won’t work as you found out.

What do you mean? Do I need to add one that is a duplicate of my sensor?
Contact MainDoorSensor “Door Sensor [%s]” { gpio=“pin:16 debounce:10 activelow:yes” }

I think he means you will need a dummy switch that will be toggled on/off by a rule depending on your contact status.

I’ll try that. Thanks.

I got it to work.
This is for anyone else who comes this way with same problem.

Switch MainDoorSensorDummy "Door Sensor Dummy" [ "Switchable" ]
//Garage Door Sensor Dummy rule
rule "Manual: Set Door Sensor Dummy to true Door Sensor position"
when
    Item MainDoorSensor changed
then
    if(MainDoorSensor.state.toString == "OPEN") {  
        logInfo("org.openhab.rules","Changing Main Garage dummy sensor to open because real sensor is open")    
        MainDoorSensorDummy.sendCommand(ON)
    } else 
    {
        logInfo("org.openhab.rules","Changing Main Garage dummy sensor to open because real sensor is closed")
        MainDoorSensorDummy.sendCommand(OFF)
    }
end

Glad you got it!
Couple of bits, because your else clause doesn’t have a test, the switch could be turned off if OH restarts or the item file is updated so I have added the first line.
Also because your proxy item doesn’t have a binding, a postUpdate in sufficient.
Finally because the item MainDoorSensor is a Contact Item, OPEN is a valid state so you don’t need the toString and the quotes in your if statement.

//Garage Door Sensor Dummy rule
rule “Manual: Set Door Sensor Dummy to true Door Sensor position”
when
    Item MainDoorSensor changed
then
    if (MainDoorSensor.state == NULL) return; // Avoid running the rule on restart or update of item file
    if (MainDoorSensor.state == OPEN) {
        logInfo("org.openhab.rules","Changing Main Garage dummy sensor to open because real sensor is open")
        MainDoorSensorDummy.postUpdate(ON)
    } else {
        logInfo("org.openhab.rules","Changing Main Garage dummy sensor to open because real sensor is closed")
        MainDoorSensorDummy.postUpdate(OFF)
    }
end

Last but not least, when publishing code, please use the codes fences, thanks.

Hi Guys, I have a very similar project. I have a magnetic reed switch connected to Gpio 14 on a Sonoff basic running Tasmota. After running “cant remember” commands in the console to change on/off to open/close, I now see in the logs “SB_02_P1 changed from CLOSED to OPEN” when the door is opened.
The basic is setup as a contact in things and items and has the “Blind” Tag for google assistant.
Everything seems to work fine in the Openhab eco but GA sais “Cant reach openhab” when I ask “Is the Shed door closed”. Everything else reaches openhab just fine.
I dont want to say is the Shed Door ON or OFF but thats all GA seems to understand.

Any clues?
Cheers