…to answer my own question, yes, setting state keys to null has not been working since yesterday (10/11).
This simple test app proves it; you don’t even need to publish it, just test it in the simulator associating it to a virtual switch. Clicking the switch you will see this kind of output:
8:53:51 AM: debug [switchHandler] - state set to null
8:53:51 AM: debug [switchHandler] - state is 87
8:53:45 AM: debug [switchHandler] - state set to null
8:53:45 AM: debug [switchHandler] - state is 87
You can see that the state (for the “Something” key) is set to 87 initially; the switchHandler sets it to null - which seems to be working fine while in the context of the switchHandler callback; but next time you click the button, switchHandler goes back to seeing 87. The problem exists only when setting the key to null; if I set it to a different (non null) value, then things would work as expected.
I’m reporting this to support.
definition(
name: “test”,
namespace: “”,
author: “Minollo”,
description: “test”,
category: “”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”
)
preferences {
section("A switch "){
input “aSwitch”, “capability.switch”, title: “Switch”, multiple: false, required: true
}
}
def installed() {
log.debug “Installed with settings: ${settings}”
initialize()
}
def updated() {
log.debug “Updated with settings: ${settings}”
unsubscribe()
initialize()
}
def initialize() {
subscribe(aSwitch, “switch”, switchHandler)
state.Something = 87
}
def switchHandler(evt) {
log.debug "[switchHandler] - state is ${state.Something}"
if (state.Something == null) {
state.Something = 87
} else {
state.Something = null
}
log.debug “[switchHandler] - state set to ${state.Something}”
}