Help: Problem with Garage Door opener when power goes out

First - thanks in advance -

First venture in the imp, found this how to video on Geekbeat: http://geekbeat.tv/control-garage-door-internet and everything worked the first time.

The one problem I have is one Sears door opener I have comes with its own battery backup. Should power go out, the relay flips to ‘closed’ I think and triggers the garage door. The opener without batter backup works fine in a power out situation.

I think the sample code supplied above (I just copied, pasted, and changed the login password) might be missing some default settings for the Sainsmart 2 Channel Relay Board, but I’m not an engineer and am posting for help.

Is there a default setting to sent the relay board to stay at the closed position?

Here’s the agent code I copied and pasted:

`// Code by Lewis Callaway for Geekbeat TV. Code is in Creative Commons. 

///////////////
// Pin Setup //
///////////////
// Setup reference variables for our pins:
garages <- [ hardware.pin5, hardware.pin9 ];

// Configure our pins:
foreach(garage in garages) {
    garage.configure(DIGITAL_OUT, 0);
}

/////////////////////////////////
// Agent Function Declarations //
/////////////////////////////////.
// This function will be called by the agent.
function toggleGarage(garage) 
{
    // make sure it's a garage that exists:
    if (garage < 0 || garage >= garages.len()) return;
    
    // set pin high, then low again in 1 second
    garages[garage].write(1);
    imp.wakeup(1.0, function() { garages[garage].write(0); });
}


///////////////////////////////////
// Important Agent Handler Stuff //
///////////////////////////////////
// Each object that the agent can send us needs a handler, which we define with
// the agent.on function.  The first parameter in agent.on is an identifier 
// string which must be matched by the sending agent. The second parameter is
// the name of a function to be called. These functions are already defined up
// above.
agent.on("toggleGarage", toggleGarage);

//////////////////////
// Helper Functions //
//////////////////////

// ledsOff just turns all LEDs off.
function garagesOff()
{
    foreach(garage in garages) {
        garages[garage].write(0);
    }
}`

And the client code:

`/****************************** HTML ******************************/
const html = @"
<!DOCTYPE html>
<html lang='en'>
  <head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <title>Garage Door</title>
    
    <link rel='stylesheet' href='https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css'>
  </head>
  <body>
    <div class='container col-xs-12 col-sm-4 col-sm-offset-4 text-center'>
      <h1>Garage Door Controller</h1>
      <div class='well'>
          <button type='button' class='btn btn-default' onclick='toggleGarage(0);'>Left Door</button>
          <button type='button' class='btn btn-default' onclick='toggleGarage(1);'>Right Door</button>
          
        <input type='password' class='form-control' style='margin-top:15px; text-align:center;' id='pw' placeholder='Password'>
      </div>
      <div class='text-left'>
        <h2>Log:</h2>
        <div id='logs'></div>
      </div>
    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'></script>
    <script src='https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js'></script>
    <script>
        function toggleGarage(s) {
            var pw = $('#pw').val();
            var url = document.URL + '?pw=' + pw + '&garage=' + s;
            if (pw) {
                $.get(url)
                    .done(function(data) {
                        $('#logs').prepend('<span style=\\'color: green;\\'>' + new Date().toLocaleString() + '</span><span> - Toggled Garage ' + (parseInt(s)+1) + '</span><br />');
                    })
                    .fail(function(data) {
                        $('#logs').prepend('<span style=\\'color: red;\\'>' + new Date().toLocaleString() + '</span><span> - ' + data.responseText  + '</span><br />');
                    });
            } else {
                $('#logs').prepend('<span style=\\'color: red;\\'>' + new Date().toLocaleString() + '</span><span> - Missing Password.</span><br />');
            }
        }
    </script>
  </body>
</html>
";

/****************************** HTTP Handler ******************************/

const PASSWORD = "xxxxxxxx"

function requestHandler(request, response)  {

    try { // Try provides us with exception handling, in case a runtime error occurs

		// if they passed garage as a query parameter
        if ("garage" in request.query) {
            
            /////////////////////////
            // add the ajax header //
            /////////////////////////
            response.header("Access-Control-Allow-Origin", "*");

            ////////////////////////
            // Check the password //
            ////////////////////////
            // password variable
            local pw = null;
            
            // if they passed a password
            if ("pw" in request.query) {
                // grab the pw parameter
                pw = request.query["pw"];
            }
    
            // if the password was wrong
            if (pw != PASSWORD) {
                // send back an angry message
                response.send(401, "UNAUTHORIZED");
                return;
            }
            
			////////////////////////////////
	        // check the garage parameter //
    	    ////////////////////////////////

            // convert the garage query parameter to an integer
            local garage = request.query.garage.tointeger();

            // send "toggleGarage" message to device, and send garage as the data
            device.send("toggleGarage", garage); 
            
            // send an http response
            response.send(200, "OK");
        } 
        
        ////////////////////////////////////////////
        // send html if no garage query parameter //
        ////////////////////////////////////////////
        else {
            response.send(200, html);
        }
    
    }  
    catch (ex) {
        // if there was an error send a response back with the error
        response.send(500, "Internal Server Error: " + ex);
    }
}

// Code by Geekbeat TV. Code is in Creative Commons. 
server.log("Garage Control: " + http.agenturl());

// Set up a handler for HTTP requests. This is the function that we defined above.
// https://electricimp.com/docs/api/http/onrequest/
http.onrequest(requestHandler);
// Set up a handler for HTTP requests. This is the function that we defined above.
// https://electricimp.com/docs/api/http/onrequest/
http.onrequest(requestHandler);`

Isn’t the imp just closing a dry-contact relay across the pushbutton in the garage?
So the opener has no idea if the imp pushed the button, or a human pushed it?
That’s the way I’ve been doing it. No modifications were made to the opener at all.

I do not understand the problem you are having. Can you reword and try it again?