Thanks for the pointers. Getting closer. Just need to read more and peck away... Groovy is just different enough from other languages I use that I need to simply spend some time with the syntax.
@gavincampbell Finished my vent/temp balancing app, seems to be working well.
I appreciate your help. It is amazing what just a few pointers in the right direction can do in terms of moving things forward.
I still have a number of things to look into/read up on to make writing the next app a little more efficient, but full steam ahead. For instance I figured out the absolute value function, but didn't see a MIN or MAX function so just did it in conditional code. There may be a few other math functions that would speed up coding versus doing it the long way.
I remember seeing that in one of my drivers... this should help.
def onTime = Math.max(Math.min(onTime, 720), 8)
I've learned a lot by pulling apart other apps/drivers. I've also rewritten some of them as I found certain drivers were just done really bad and weren't working properly and some apps I wanted to add more features too. Most of my stuff is all custom written now and I know it inside out. I keep the features basic and add as I need.
The next thing you will probably want to look at is subscribing to device events. This is the fun stuff. Having methods launch when your contact is opened or a switch is turned on. Then you can get really creative.
Just curious -
Anyone have a preferred groovy editor? I've just been using Notepad++ with a groovy language plugin. It works, but was curious what others use.
emacs ... my text editor for everything, even docs LOL.
I'd recommend IntelliJ from Jetbrains - the community edition is free and supports Groovy
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:
cmds << response(zwave.indicatorV1.indicatorGet()) sendHubCommand(cmds)
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.
Most, if not all of these can be found in the SmartThings developer docs API Documentation — SmartThings Classic Developer Documentation
The ZWave stuff requires you to log in with a Samsung or Smartthings account