Newbie in Groovy, Need this and this before action is taken

New to writing code in Groovy, I usually write stuff in Powershell.
I need to create a app that turns on a light if there is motion OR the door is shut
then turn light off if no motion AND door open

What would be the argument to get this done?

If you want to learn Groovy, I cheerfully suggest loading up the SmartThings IDE and pulling in a few of a hundred free ooen source code samples.

There’s not many comments in the code, but if you can read Powershell, that helps.

The official SmartThings Documentation SmartApp Dev Guide is also good for a first example.

Message me for specific questions?

I did read some of the documentation. I tried a few IF statements, Is there a way to set a Variable then have a IF statement run against it?
Like

$ItsOn = “Yes”

if ($ItsOn -eq “Yes”) { Do this code}

???

Sure is!!! and I hope you understand my reasoning in having you hunt around the documentation a bit because I personally find that the best way to learn (makes our brains wrap around the concepts…).

See this example in the Docs (as well as many more examples in the surrounding chapters):
http://docs.smartthings.com/en/latest/smartapp-developers-guide/example-bon-voyage.html

private everyoneIsAway() {
    def result = true
    // iterate over our people variable that we defined
    // in the preferences method
    for (person in people) {
        if (person.currentPresence == "present") {
            // someone is present, so set our our result
            // variable to false and terminate the loop.
            result = false
            break
        }
    }
    log.debug "everyoneIsAway: $result"
    return result
}

And:
http://groovy.codehaus.org/

And:
Learn Groovy in Y Minutes is an excellent one page tutorial!

1 Like