[RELEASE] Auto Lock

You could probably get rid of the ("battery") for both on that line but of it's working no need.

No errors on the Save so I assume it's not breaking anything.

K - so I'll wait until the next battery report (likely tomorrow AM) and I'll let you know what happens. :slight_smile:

Just change it real quick and see. You could copy that line into the contactContactHandler as an if statement and trigger it by opening the door.

1 Like

Code Change:

App unchanged:
image

It's still waiting on an event though try copying that line outside of the method like somewhere in the main page and see if it updates.

Change it to an if statement and close the bracket on the end.

Doesn't really matter where you stick it. Just insert a line after one of the input lines near the top. Then save and refresh device toggle.

Bingo, bingo, bingo, and bingo is the name-o. :wink:

Change: (Added line 58)

Result: Accurate battery info!

Man - you did this w/twins in your hands!! :wink:

They're both sitting in my lap.

1 Like

I'll add contactBattery to the next build.

1 Like

You mean currentBattery - twin's typo, I assume. :smiley:

Yea auto correct got me again.

1 Like

Gotta love how you can just make up stuff and it works.

3 Likes

Boom Thanks

1 Like

Well you know, the whole idea of locking doors in general was something I came up with back in the day...

:wink:

Added the change to 1.1.31 and published to HPM.

1 Like

Thanks for the update to replace my sloppy work. :wink:

Bingo is still bingo. :smiley:

image

1 Like

Per mode lock delay option complete. Working on per mode unlock. Both will be in the next release.

2 Likes

1.1.32 released.

Added per mode delay option for locking and unlocking.

1 Like

Thank you Lewis, this was implemented perfectly.

1 Like

I really struggled with getting the mode delay value from settings based on current mode. Particularly combining a string and a variable value to get a variable name that I could then reference to get the specific variable I was looking for to set the delay. I spent a couple of hours just working through this part...

def perModeLockDelay() {
if (settings.whenToLock?.contains("7") && (enablePerModeLockDelay == true) && modesLockStatus) {
    modesLockStatus.each { it ->
        variableName = ("modeDurationLock"+"${it}")
        input "${variableName}", "number", title: "${it} mode lock delay:", required: false, defaultValue: 10, submitOnChange: true
        if (it == location.mode) {
            variableValue = app.getSetting("${variableName}")
            app.updateSetting("durationLock",[value: variableValue, type: "number"])}
    }
}
}
2 Likes

Lol I'm really struggling to just understand what I just read.