Syntax for color chooser?

I’m playing around with the SmartThings Arduino shield and I’ve been having some trouble extending the basic examples with new controls. (I know this gets said a lot, but it would be so helpful if there were SOME organized developer API documentation!)

I just tried to add a color picker, but the method I’m calling doesn’t get actually used! What am I doing wrong here?

metadata {
	// Automatically generated. Make future change here.
	definition (name: "On/Off Shield2", namespace: "smartthings", author: "SmartThings") {
		capability "Switch Level"
		capability "Actuator"
		capability "Color Control"
		capability "Switch"
		capability "Polling"
		capability "Refresh"
		capability "Sensor"

		command "setAdjustedColor"
        
        attribute "color", "string"
	}
    
	// UI tile definitions
	tiles {
		standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
			state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
			state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
		}
		controlTile("rgbSelector", "device.color", "color", height: 2, width: 2, inactiveLabel: false) {
			state "color", action:"setAdjustedColor"
		}

		main(["switch"])
		details(["switch","rgbSelector"])
	}
}

// Parse incoming device messages to generate events
def parse(String description) {
	def value = zigbee.parse(description)?.text
	def name = value in ["on","off"] ? "switch" : null
	def result = createEvent(name: name, value: value)
	log.debug "Parse returned ${result?.descriptionText}"
	return result
}

// Commands sent to the device
def on() {
	log.debug "on()"
	zigbee.smartShield(text: "on").format()
}

def off() {
	log.debug "off()"
	zigbee.smartShield(text: "off").format()
}

def setAdjustedColor(value) {
	log.debug "setAdjustedColor"
	zigbee.smartShield(text: "setAdjustedColor").format()
}

I’m just trying to get “setAdjustedColor” to show up at all in my log, but it’s not even doing that. On and off work just fine.

I don’t think you need the line:
attribute “color”, "string"
The Hue Bulb device doesn’t have it, and I think it’s part of the Color Control capability.

If you added the color control after creating the device initially, I would delete the device and create a new one. I’ve definitely seen issues where changing things in the metadata doesn’t update until you recreate your device.

Thanks!! I tried copying and pasting the code into a new device, and miraculously it works :stuck_out_tongue:

And I’ve had the same problem with updating metadata… there doesn’t seem to be any mechanism by which they detect changes in metadata and push them to the phone. It makes debugging code really difficult.

BTW, adding the color attribute was one thing I tried early on to fix the problem and never took out. The code wasn’t updating even before I put that in there.

Instead of deleting device, you can log out of the mobile app, kill it, then log back in again. It’s also painful, but slightly less than re-creating device. Use IDE simulator as much as you can, although it’s also half-broken :frowning: