Hello,
I have this SmartApp that should turn on a simulated switch, but when i do “switch.on()” a NullPointerException is thrown, because switch is null.
Yet, the correct device and name are selected in the preferences. Let me link some code.
preferences { //Set the sensor and the relay
section("Choose devices"){
input "sensor", "capability.temperatureMeasurement", required: true, title: "Sensore di temperatura"
input "device", "capability.switch", required: true, title: "Relay"
}
//Cut out due to lenght, i have other 16 preferences...
}
And…
if (temperature < workTime1Temperature) device?.on();
else device?.off(); //Safe navigation to avoid exception
log.info("${device}"); //This prints "null"
}
Here are some screenshots from the SmartThings app.
I don’t get it. The device is configured correctly… selected in the list…
May the Virtual Device have an influence on this?
Thanks to everyone in advance