Getting started with Groovy

I think I am ready to try and do some Groovy development. There is an app I like that the original developer no longer supports (Holiday Color Lights). Originally written for Smartthings, it was working for me until the last Hubitat update.

I wanted to change the operation of the app anyway but it was generally working for me. Now that it no longer works, I was wondering if I could attempt to update it myself. I've done some light coding and am a logical thinker. I am willing to attempt this myself but don't really know where to start.

I have learned you can use a variety of editors to edit Groovy code with Netbeans being one of them and VS Code another. Aside from learning Groovy syntax, how can you test the code without actually installing on the hub itself? Is there a simulator of some kind? Does anyone have any recommendation on where to start? For example, is there a tutorial on doing something like the classic "Hello world" that most programming languages use that is applicable to writing an app for Hubitat?

I have an idea of what I'd like to accomplish; I just need a little help to get started. Thanks, all.

No need for anything special..

All of my apps & drivers have been developed using the in house editor.
It will check your syntax for you as you go along, and will often tell you where you have gone wrong.

I believe all the in-built apps and drivers are also developed with the same editor.

Andy

2 Likes

I like Visual Studio Code. It's free and has support for almost every language out there and it works on Windows, Linux, OSX

3 Likes

I use IntelliJ from JetBrains - there's a community edition which is free. I prefer it over most of the other editors mentioned because of the refactoring support.

Unfortunately there's no test framework for Hubitat, you have to paste the code into the editor.

2 Likes

Wish I could help you @fischer1049 as my wife really liked that app too and noticed it quit working after last HE update. If you ever get it working again, let me know. Good luck!

1 Like

I'm testing a fix, @mojoman2600 and the code is no longer generating an error. I will report back in the next few days to see if I was successful.

I am also attempting a few other changes. For example, I would like to specify separate days before and days after a holiday to keep the holiday lights. For some holidays I prefer short periods while others (like Christmas), longer.

I'm happy to share my updates if I'm successful.

That's great @fischer1049 ! That is a great idea to be able to add days before & after holidays. I wish I knew how to code & could help you with it. My wife will be happy about that...seems like all she showed interest in HE was this app and the one that @Cobra is working on for "Countdown" that one could use for countdown to special events. Keep me posted on your progress @fischer1049
Thank you!

1 Like

Countdown just released.. :slight_smile:

Just as I posted the above message about @fischer1049 and his holiday app I then saw you just released countdown. Wife is eager to add countdown to birthdays & holiday now with tiles. I'm working on installing it now. Thanks @Cobra I'll try it out and let you know how it goes.

1 Like

Update: I have verified that the code updates are partially working. The app error is resolved. I have also been able to change the code to add selective days before and days after.

But alas, all is not well. The app no longer turns the lights off/on. I have confirmed that if the lights are manually turned on, the lights do change color based on the selected holiday. I plan on doing more troubleshooting this weekend.

I think I'm beginning to understand the code a little better. I do wish there was better documentation on writing apps. So far I have been relying more on the Smartthings app documentation than Hubitat's.

A quick update; I'm making progress. I thought I had everything working but then last night the lights came on at midnight for some reason. They turned off at the cycle time of 10 mins and did not come on again. I am testing to see if this repeats tonight.

In the meantime, for anyone who had the original Holiday Color Lights running, do you remember if you had a simple lighting rule to turn the lights on/off and used Holiday Color Lights to only change colors? I could not find any section of the code where the lights were turned on/off. Therefore, I added some code do that but that may now be a part of what I'm troubleshooting.