Getting Philips Hue Values

It seems that for some reason this is now working, I had tested extensively before and haven’t really made any changes.

The code below captures the state of all switches defined under settings.switches

Call it as below to store the state of all switches in a application level variable.

state.originalStates = captureStates()

And the functions:

def captureStates() {
	def states = [:]
	for (theDevice in settings.switches) {
		def deviceState = captureState(theDevice)
		def deviceID = theDevice.id
		states[deviceID] = deviceState
	}
	return states
}

def captureState(theDevice) {
	def deviceAttributes = theDevice.supportedAttributes
	def deviceAttrValue = [:]
	for ( attr in theDevice.supportedAttributes ) {
		def attrName = "${attr}"
		def attrValue = theDevice.currentValue(attrName)
		deviceAttrValue[attrName] = attrValue
	}
	return deviceAttrValue
}

I would love any feedback about how I could made this more efficient.