I just do it right in the web interface. Works well for me and is easy to quickly save and test code.
Its missing a few small features (I think there is no search and replace) but if I have to I just cut and paste to notepad and do the replace and paste it back.
Example code can be useful when someone else has already done what Iām trying to do, but it canāt substitute for full documentation when I need to do something new.
Specifically, Iām trying to adapt a Cooper Aspire Scene Controller driver so that instead of associating with scene-capable devices, it sends button events to the hub. So far Iāve managed to get it to log button events (in the form of BasicSet and SceneActivationSet commands,) but I have no idea how to tell it to send these events to the hub.
For either of these types of commands the driver executes the following statements:
The āindicatorGetā method is called in many places throughout the driver, but it isnāt defined there so I have no idea what it does. The āresponseā method isnāt used anywhere else or defined anywhere; I put in some log.debug statements and found that this apparently returns the number 8702 regardless of which indicators are lit on the switches. The āsendHubCommandā also isnāt defined anywhere, but I assume thatās something built into Hubitat ā itās mentioned in a community post from last October, but it isnāt documented.
I have a Simple Lighting rule thatās supposed to trigger when the first button on this scene controller is pressed. It isnāt doing anything, even though I can see the event being generated in the driver. So Iām pretty certain itās a matter of sending the right command to the hub, but I have no idea where to start.
This is just a specific example. My point is to illustrate how the lack of adequate documentation hinders development, and that just relying on public driver code as examples is insufficient.
Is there any hope of getting generated docs for Hubitat instead of looking at the ST docs and hoping they are right? Since this is all groovy having auto-generated groovydoc for each release would be WONDERFUL. I don't even need comments, just knowing all the method signatures would be huge.
Have you looked at the developer documentation at the following? It's not 100% complete, but compared to a year ago, Hubitat has come a very long way, IMHO.
Sure, there is some stuff there but the vast majority of the API has no docs.
For example the Hub Update 2.0.3 release notes say that HubMultiAction has been added. Searching the wiki for that class gets me to Driver Object but it just mentions HubMultiAction as a return type with no information on how to use it.
I understand. Did you come from SmartThings originally? Or another platform? Or is Hubitat your first home automation hub?
For many of us that are SmartThings refugees, we sometimes take for granted our previous experience on that platform with the very similar API. I still pop back over to ST to check their documentation from time to time.
I can say that if you have a specific issue, which the community cannot help with, the Hubitat staff is usually very quick to lend their expertise to help developers sort things out. Just tag @mike.maxwell (drivers), @bravenel (apps), @patrick (dashboard), @bobbyD (support), or @chuck.schwer (platform). They are a great team to work with!
Coming from ST and more so coming from ~20 years of open source software development. I just feel bad poking on here constantly when I run into things that I feel like I could sort out if I could dig into the API docs.
Currently I'm trying to figure out why my ported ST driver threw an error. I posted a dedicated thread about it: Modify sendHubCommand from ST?
If anything get familiar with the groovy syntax and the layout of the app structure. Then start looking at code for existing apps to understand how they work. Look for something simple.
The example I gave above is a very basic example. You can then start to add your own inputs and act on them from there.
Or a custom app. As mentioned above, the underlying issue is that a driver alone cannot do this (or at least I don't think so...I've never done it...EDIT: forgot that a driver can, but only on a specific port so probably not as useful unless you have control over the other end).
This is basically what HubConnect does if you use HTTP, but it's not exactly a minimal example app (and you can't reuse its code as licensed, but it may be a good reference).
A driver can listen for http requests. If device DNI needs to be set to the MAC address of the remote device and the calls are made to port http://hubip:39501, Hubitat will call parse() with the contents of the request.
The easiest approach is to create an oAuth-enabled app that will allow you to define endpoints that are mapped to functions within your app.
Have a look at the Remote Client code, it should provide some guidance on how Hubitat allows for http endpoint calls. There are probably simpler examples around here, I just can't think of any at the moment.
Looking at some examples, I don't see any uninstalled() code, what happens to event subscriptions when the user decides to delete the app? Is that all handled for us? Can it be overridden?