Parse() log.debug


(Shreddin Pb) #1

Hi guys, can you use log.debug inside the parse() function for a device type?

I have this simple one to show as a test…

def parse(String description) {
	def value = zigbee.parse(description)?.text
    log.debug "testing"
	def name = value in ["on","off"] ? "switch" : null
	def result = createEvent(name: name, value: value)
	return result
}

the console never prints out the “testing” text…


(Richard Lee) #2

definitely works. perhaps parse() isn’t being called?


(Shreddin Pb) #3

I thought parse was called by smartthings?
Here is the code

def parse(String description) 
{
	log.debug "testing"

	def desc = zigbee.parse(description)?.text

    if(desc.endsWith('off'))
    {
    //def name = "state" + desc.substring(0,1)
      def name = "state1"
      //def value = desc.substring(1,2)
      def value = "off"
		log.debug "name "+name+" value "+value
        
      def result = createEvent(name: name, value: value) //set state1, state2, or state3 to on or off
      log.debug "Parse state ${result?.descriptionText}"
      return result
    }
    else
    {
       log.debug "Parse returned ${result?.descriptionText}"
       def name = "state1"
      //def value = desc.substring(1,2)
      def value = "on"
      log.debug "name "+name+" value "+value

      def result = createEvent(name: name, value: value) //set state1, state2, or state3 to on or off
      log.debug "Parse state ${result?.descriptionText}"
      return result
    }
}
// Commands sent to the device
def t1on() {
	log.debug "t1on"    
	zigbee.smartShield(text: "on"+settings.t1x10AlpaAddress+settings.t1X10NumericAddress).format()
}

def t1off() {
	log.debug "t1off"
	zigbee.smartShield(text: "off"+settings.t1x10AlpaAddress+settings.t1X10NumericAddress).format()
}

and here is the console

9:59:37 PM: debug Parse returned null
9:58:51 PM: debug Parse state X10 statet is 1
9:58:49 PM: debug Parse state X10 stateo is f
9:58:49 PM: debug Parse returned null
9:58:48 PM: debug t1off

by that it seems it is being called?