Dumping object properties and values?

(trac starr) #1

Trying to figure out how to dump object properties to log. I’ve tried dump() without any luck.

Specifically, I’m trying to figure out how to get the device type from a device class.

(Linda Thomas-Fowler) #2

I went through the same thing. Not sure where dump() ends up but it’s not int he IDE’s log. Here’s some code I have that responds to a request to list configured sensors. The property you want is typeName.

def listSensors() {
    log.trace "in listSensors"
    def sensors = [:]
    def devs = getChildDevices()
    devs.each {
    	def name = it.displayName
        def zone = it.getZone()
        def id = it.deviceNetworkId
        def type = it.typeName
	def sensor = [zone: zone, name: name, type: type, networkID: id]
	sensors[zone] = sensor
    	log.debug "device is *${name}*, zone: *${zone}*, id: *${id}*, type: *${type}"
    log.debug "child devices: $devs"

(trac starr) #3

Thanks Linda. Seems so obvious now, I’ll give it a try.