Redefine or delete input values?

I am writing a simple SmartApp with some dynamic preferences. I have some inputs for devices and user-defined numbers. I can’t seem to find out how to “remove” these devices and numbers if they are no longer relevant. I’d like to redefine them to be null, if possible.

Abbreviated version of my preferences are below to illustrate what I’m trying to do:

section("Select Mode for Heating, Cooling, or Both..."){
		input("mode", "enum", title: "Heat or Cool?", options: ["Heat","Cool","Both"], required: true, submitOnChange: true)
    if (mode == "Heat" || mode == "Both") {
    	section("Details for Heating... ") {
    		input("heatSwitch", "capability.switch", title: "Heater", required: true, multiple: false)
            input("heatTemp", "decimal", title: "Set min temp for heater", description: "min temp", required: true)
    if (mode == "Cool" || mode == "Both") {
		section("Details for Cooling... ") {
        	input("coolSwitch", "capability.switch", title: "Cooling Device", required: true, multiple: false)
            input("coolTemp", "decimal", title: "Set max temp for cooler", description: "max temp", required: true)

Basically, if the user selects mode = “Both” for heating and cooling, they have to define all 4 variables. If they later change to just cooling, the device and temperature for the heating application remain unchanged. It would make it much easier if I could redefine those both to null either inside the preferences, or in my update/initialize method.

Thanks for the help!

1 Like