I’d like to change a value in the settings map programmatically. It seems that I can change the value but it doesn’t stick.
For security reasons, the SmartThings platform does not allow it.
What’s your use case?
I forked the lock-manager app and am trying to add integration for my Airbnb calendar to change the userCode setting in lock-user based on phone number of my guests.
Here is a link to the current state of my attempt at that: https://github.com/tylerjw/lock-manager/blob/master/smartapps/ethayer/lock-user.src/lock-user.groovy
Code excerpt:
if (newCode) {
if (settings.userCode != newCode) {
settings.userEnabled = true
settings.userCode = newCode
debugger("setting code to ${newCode}, settings.userCode = ${settings.userCode}")
resetAllLocksUsage()
parent.setAccess()
if (settings.checkinNotify) {
settings.notifyAccess = true
}
}
} else {
// there is no guest today
userEnabled = false
resetAllLocksUsage()
parent.setAccess()
}
Here newCode is the value of a new code if found by my iCal parser and settings.userCode is the door lock code. I also want to disable/enable the user based on if there is a guest today and I want to enable notifyAccess if checkinNotify (bool) is enabled so that a notifyAccess notification is sent on the first use of the code (and in the notification settings filter code I check for checkinNotify is set, and if it is I clear notifyAccess).
I imagine the right way to do this is with state, however that would require me to change much more code as the other parent/children apps depend on that userCode setting value being the code for this user.
I got what I wanted by creating a getUserCode() method and tying the setting to state.userCode.