Debugging Driver

What is a driver debugging technique for the Hubitat?

I need to create a relatively simple driver for my RGB Strip HubDuino project.
All what I need from a Driver - is to control values (0-255 range) for each individual
R G B (W) Channels and a global On/Off control.
The existing drivers for the RGB Control are over complicated. All of them have a lot of
buit-in smartness. My opinion, driver should/must be as simple as possible and
all that smartness should/must be Application responsibility.

I went through many driver codes and I guess, I got the idea how to create
my custom driver.

But how do I debug my creation?
As of now what I can think about - is attempting to load driver and deal with
all messages. This seems to be very time consuming and extremely inefficient
way to debug drivers and/or aps.

Any advice on how to speed up debugging will be very appreciated.

PS.
Unfortunately I am not a professional SW developer but I have enough
skills with C/C++ programming.
As a result, I don't have any sophisticated SW developing tools
installed and available. Is this a show stopper?

yes, that's it...

I figure out what events the device generates on its own if any (physical interaction)
then those generated in response to the commands i send it
then parse everything into events for commands that are of use...
ignore everything else...

the first step usually includes figuring out what configuration commands if any the device needs.

Thank you for clarification.

For the beginning I have few related examples handy.
Many things could be simply deleted (I guess).
But I will have to add few missing things such as setting R G B values.
"setLevel' is defaulted to 0-99 range but I need 0-255 range.
One quick question?
Will it work if I modify line (found in examples):
def level = Math.max(Math.min(valueaux, 99), 0)
to
def level = Math.max(Math.min(valueaux, 255), 0)
or I have to use something else?

If you are doing the driver for yourself only, then indeed, use the 0-255 and setRGB only. If you want general usability - especially with rules, I would use the Hubitat Driver Capabilities.

Below is a link to a driver that uses the Hubitat Capabilities and converts them to a straight RGB (0 - 255) implementation,using Hex code for the RGB. To use decimal, simply do not convert the Red255 (etc.) to Hex.

Dave

https://raw.githubusercontent.com/DaveGut/HubitatActive/master/bleBoxDevices/Drivers/wLightBoxRgb.groovy

Thank you very much for the hint.
Well, as of today I am planning to use my Driver/Project just for myself.
But you never know, somebody else could be willing to use it.
My goal is to do things absolutely right way and not to take any shortcuts.
Otherwise sooner or later there will be a problem
I will follow yours advice and I will use the Hubitat Driver Capabilities.
Thank you very much for the link.
I will learn from your driver how to get straight HEX RGB(W) values.

1 Like

If I install this:
https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-3.0.9
will it help with debugging?
I am asking this question because my PC is full with HW Design Tools.
I don't want to mess up with installing something what will not be used.

no, I don't think so, i write driver and app code directly in Hubitat code editor.
Groovy isn't that difficult, it's an extension of Java. Theres tons of examples on the web for the language itself.
We have a few driver and app examples in our public repo.

Honestly when writing zigbee and zwave drivers the hardest part when getting started is getting a grip on the zwave and zigbee spec/api, not learning groovy.

Very BIG Thank you for yours professional opinion.
And Thank you for the link to examples.
I went through many published custom drivers.
I can understand every line of code (I guess).
But writing something is a very different story.
I am glad, I have spare C5 for all my entertainments.