Oauth access to smartapp - not devices


(Eric R) #1

I’m not sure exactly what I am missing. I have an app where I don’t want to access devices, but I want to access logic in the program. I’m not really sure how to go about that though. This is the mapping and code I would like to use, but am not sure how to access it.

mappings {
	
    path("/currentTemp") {
    	action: [GET: "listTemps"]
    }
    
    path("/currentTemp/:room") {
    	action: [GET: "getRoomTemp"]
    }
    
    path("/setTemp/:room/:newSetTemp") {
    	action: [PUT: "setRoomTemp"]
    }
    
}

def listTemps() {
	for (int n = 0; n < state.numRooms; n++) {
    	roomTemp(n)
    }
}

def getRoomTemp() {
	roomTemp(params.room)
}

def roomTemp(n) {
	def room = state.rooms[n]
    def devices = getRoomDevices(n)
    def setTemp = room.setTemp.toInteger()
    def currentTemp = devices.tempMonitor.currentTemperature
    
    [roomNum: n, room: room.name, currentTemp: currentTemp, setTemp: setTemp]
}

def setRoomTemp() {
	def n = params.room
    def newSetTemp = params.newSetTemp
	def room = state.rooms[n]
    
    room.setTemp = newSetTemp
    
    onOrOffCheck(n)
}