First Operand in an "input" statement, what is it?

When working with an app I'm trying to write, I stated to focus on the objects vs variables.
It made me consider what the first entry in an input statement was. It appears to have no other function than to identify the device to subscribe to.
I guess in the long run it doesn't really matter but I'm curious to know what it is. Like is it an object? If so what prosperities might it have that could be useful?

The entry I'm referring to; in the below code the entry is "tstatSet"

Thanks
John

def mainPage() {
	dynamicPage(name: "mainPage", title: " ", install: true, uninstall: true) {
		section {
            
			input "tstatSet", "capability.thermostat", title: "Select Thermostat to Ctrl", submitOnChange: true, required: true, multiple: false
}}}

def installed() {
	initialize()
}

def updated() {
	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(tstatSet, "thermostatSetpoint", currentSetPtHandler)

The first parameter is the name of the object to be created by the input. In the code you posted, "tstatSet" will be the name of the thermostat selected, and that name will be available throughout the app. For "capability.xxx" inputs like this, the created object is called a 'device wrapper', giving the app access to the selected device and all of its attributes and commands.

You could do things such as

tstatSet.setCoolingSetpoint(74.0)

which would send the setCoolingSetpoint command to the device.

Or,

if(tstatSet.currentTemperature < 75) .....

which tests the current value of the selected thermostat's temperature attribute.

2 Likes

Thank you very much for the Groovy lesson :slight_smile:
John