How to use debug log

I am making my first attempt to do Hubitat coding. My first project is to modify an existing device driver to do something slightly different. Basically, the current driver supports the PushableButton capability and I want to make it support the HoldableButton capability. The application is described in another thread Sensing thermostat heating/cooling calls .
I have many questions and will likely have many more before I am done. Here is the first one. There are a number of log.debug $string statements in the code. I have tested a sample device and am pretty confident that I am executing the portion of the code that has the statement (the parse function). However, I don't see anything in the Hubitat logs. Debug logging is enabled. Am I looking in the wrong place?

Here is a sample line of code

log.debug “Output a ${variable}”

Make sure you have the brackets around the variable name if you want to log a variable

This is the code at the beginning of the parse function:
def parse(String description) {
log.debug "description: ${description}"

The original code didn't have the brackets. I added them after reading the above post. I still don't see anything showing up in the logs. But the log does show several events. Something other than log.debug statements in my code is printing to the log once per event.

Looking a little farther down the log output, I see a warning that debug logging is disabled. Any idea how I get it re-enabled?

That wouldn’t prevent that from showing. How do you know parse is being called? Sounds like it isn’t.

My understanding of device drivers is that the parse function always gets called when handling an event. I am causing it to handle events.
This is my first attempt at programming a device driver, so I won't be surprised if I am mistaken. My knowledge is based on a few hours of reading. Most of what I have read is for SmartThings since I could find very little Hubitat documentation.

That’s not correct. Is this a zwave or zigbee driver? It is called when a zwave or zigbee message is received. It’s kind of hard to help without seeing the code...

Unless the device is sending a message, the parse function will not be called. So, do you have the driver assigned to a device and are you pushing the button on the device?

The driver is a Zigbee driver. The device is paired and I am triggering the device to send messages. Hubitat recognizes that button presses have occurred which leads me to believe that I was successful in getting the device to send messages.

Please share the driver code and the community will help you debug it. It is hard to help without seeing the code.

I am starting with the code from trunzoc So far, the only editing I have done of that code is uncommenting the log.debug statements and inserting brackets as suggested in a message above.

Here are the tweaks I would make to the parse() routine to get debug logging to work. Once you edit the driver, please be sure to modify the Device's driver "Type" on the device details web page to use your new driver, instead of the default driver. After changing the driver TYPE and clicking SAVE, go back into the device details page and click CONFIGURE to make sure the new driver's settings are sent to the physical device.

def parse(String description) {
	log.debug "description: ${description}"
	Map map = [:]
	if (description?.startsWith('catchall:')) {
		map = parseCatchAllMessage(description)
    else if (description?.startsWith('read attr -')) {
		map = parseReportAttributeMessage(description)
	log.debug "Parse returned ${map}"
	def result = map ? createEvent(map) : null
    if (description?.startsWith('enroll request')) {
    	List cmds = enrollResponse()
        ////log.debug "enroll response: ${cmds}"
        result = cmds?.collect { new hubitat.device.HubAction(it) }
    return result
1 Like

Bingo. My device was using the default driver instead of my custom driver. I could have changed code all day with no impact.

1 Like

Glad to hear! The clue to me was when you stated that you saw a message in your logs that the "debug was disabled". When I saw the driver you were using did not have that functionality, I assumed that the device was still using Hubitat's built-in driver.

1 Like