Device Types and preferences

(Shreddin Pb) #1

So, I have started writing my own device type. I need a way to input some information into the device.
I looked thru the code for the Nest thermostat and it appears to have something like that.

preferences {
    input("username", "text", title: "Username", description: "Your Nest username (usually an email address)")
    input("password", "password", title: "Password", description: "Your Nest password")
    input("serial", "text", title: "Serial #", description: "The serial number of your thermostat")

I copied the whole Nest code and pasted it into a test device type in the IDE, but cant figure out where you input that data. I am using the simulator with a virtual device since I dont have a nest thermostat. Clicking on the little gear in the bottom right of the main tile doesnt do anything in the simulator.
When does the device ask you for the input data?

Also, is there just a tile that is an input? Something where I can put a setting?
I saw this in the Aeon Outlet code

standardTile("configure", "device.power", inactiveLabel: false, decoration: "flat") {
    state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"

Cant seem to figure that one out either.

How can my Device type take some user input, some setting?


(Alex King) #2

I’m not sure where to find the settings in the simulator, but on your phone (I’ve only tested this on iOS) you can get to them with the preferences tile - under the name it’ll have a new section called “Set Device Preferences”.

I have found them to work a little differently from app preferences though, they can’t seem to accept input that contains “:” (it’s just cut off, so 2:00pm turns into 2), and I’ve had some trouble with enum types, but besides that they seem to work fine.

I’m not sure what the configuration tile is supposed to do btw - in the examples it always seems to send some messages to the device, but I can’t figure out what sort of configuration you do to a device with one button.

(Shreddin Pb) #3

I found the preferences on the website… you go to My Devices, click on the device name, then at the bottom is preferences, you can edit there.
It would still be helpfull to know if there is a tile that is a user input.

Also, when I click on the setting part of the tile on any custom tile (i tried mine, and the on/off sheild example) it crashes the smartthings app on android.

(Alex) #4


I’m trying to define device preferences as such:

    preferences {
    input "x", "string", title: "API Key", displayDuringSetup: true

When I try to use that setting like so


The value is always null.
This setting was entered and saved in the IDE.
What am I missing?

How do I enter settings in the simulator?
How about the mobile app (Android)?

Is there a way to add a custom device via the mobile app?