Attempting to understand device capabilities via log.debug

capability
logging

(Christopher Bennage) #1

I’ve just started learning how to develop SmartApps.
I want to log.debug to dump out the values of device attributes. However, I can only get something like physicalgraph.app.AttributeWrapper@XXXXXX. I understand in general how wrapper classes are used, but I’m not clear on how to unwrap what I want.

For example,

    section("my example") {
    	input "myColoredBlub", "capability.colorControl", required: true
    }

    // then in a subsequent event handler
    log.debug "${myColoredBlub.color}"
    log.debug "${myColoredBlub.hue}"
    log.debug "${myColoredBlub.saturation}"

I’ve tried a couple of variations (i.e., omitting {}, etc.). I’ve gone through the tutorial and a few sample apps, but I don’t see examples of attributes being written out directly. I assume that I’m just making a dumb mistake. :stuck_out_tongue:
This is for exploration. I’m really just trying to understand the device. It’s not for a finished app.

  • Is there a syntax I’m missing?
  • Is there a better way to accomplish what I’m after?

(Kevin) #2

There are several ways to do it, but I find the easiest to just put current in front of the attribute like log.debug “${myColoredBulb.currentColor}”