Custom device logging issue

I am in the tail end of migrating from Smartthings and have run across a curious issue. I have been using the "Virtual Contact Sensor with Switch" implementation from ogiewan to control some things via Alexa. It has been working great and I have no reason to doubt it is still working because when manually triggered it works as expected. However, I've been trying to troubleshoot something with some of my apps and I come to find that it is not logging anything in the logs on state change (on/off/open/closed). I even tried another implementation that looks very simple by Stephan Hackett and I am experiencing the same issue. Looking at the driver code it looks dead simple and is performing the "sendEvent" commands which I assume would take the action and log the event? Is this an issue with Hubitat itself and custom drivers? Am I missing something simple?

There is an event log for each devices, and then the main "console" log of the hub. sendEvent will post it to the device event log. Go to the device's page and change to the Events tab at the top.

OK, I have seen that as well, but also noticed all of the events happening with other devices in the main log where you can also filter by device. For example, when an app like room lighting or rule machine triggers, I'm accustomed to seeing all the actions in the log on the various devices but these devices aren't showing up there. Is that to be expected? Without log entries from all the devices it's hard to see what an automation is and isn't doing to troubleshoot issues.

For example, for one of my lights using a normal switch I see things like this in the logs:

So you could either add your own logging to the driver, or you could also try this one which I just checked the code and it seems it has logging.

If you want to add your own logging you could add something like this right before the sendEvent

log.info "${device.displayName}: ${msg}"

${msg} could be replaced by static text, or you could just replace the 'msg' part with another variable. Whatever is being sent in the event as the description usually work well for the log message.

1 Like

Perfect, thank you!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.