How to change value in settings map?

(Tyler Weaver) #1

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.

( co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

For security reasons, the SmartThings platform does not allow it.

What’s your use case?

(Tyler Weaver) #3

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:

Code excerpt:

 if (newCode) {
    if (settings.userCode != newCode) {
      settings.userEnabled = true
      settings.userCode = newCode
      debugger("setting code to ${newCode}, settings.userCode = ${settings.userCode}")
      if (settings.checkinNotify) {
        settings.notifyAccess = true
  } else {
    // there is no guest today
    userEnabled = false

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.

(Tyler Weaver) #4

I got what I wanted by creating a getUserCode() method and tying the setting to state.userCode.