Starting from firmware version 2.3.9, Hubitat supports Groovy development in IntelliJ Idea. Here's how to edit the code in the IDE and upload it in a single click using IDE's plugin.
Right click on the toolbar and select Customize Toolbar... from the menu.
Click (+) icon and select Add Action.
Enter "Hubitat" in the search bar and select Post Hubitat app or driver code to the hub.
Assign an icon of your choice and click Ok.
Double check that the icon appears on the toolbar.
The plugin looks for a set of comments with hub/app/driver information at the very beginning of the file. Copy/paste the sample code below as the first 5 lines of the app/driver groovy file and modify information as needed.
// hubitat start
// hub: 192.168.4.86 <- this is hub's IP address
// type: app <- valid values here are "app" and "device"
// id: 2551 <- this is app or driver's id
// hubitat end
Make sure that the information is correct, then click the button created in the first step to upload the code. That's it! A confirmation will pop up to indicate either success or failure of code upload. If there's a compilation error, more information will be provided.
I was unable to reproduce that. It doesn't work for me, the request is rejected, and no error message is shown. Which it should, and I'll get to it once dashboards are ironed out.
Plugin 'HubitatIntelliJPlugin' (version '1.0-SNAPSHOT') is not compatible with the current version of the IDE, because it requires build 242.* or older but the current build is IC-243.21565.193
Thanks, looking forward to this as I have somehow recently lost the Shift-Tab auto formatting in the browser editor when coding my groovy apps/drivers.
I am not sure where that Shift-Tab auto formatting functionality came from that was really helpful to align the {} brackets, but multiple recent upgrades on Apple M4 Hardware, Apple OS Sequoia, Brave/ChromeSafari, and Hubitat make it hard to track down the lost functionality.
I see this in the plugin.xml file (inside the jar):
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
<idea-plugin>
<version>1.0-SNAPSHOT</version>
<idea-version since-build="232" until-build="242.*" />
<!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. -->
It defines a until-build property which is optional.. seems like it could/should just be removed
Attributes
* `since-build` (required)
The lowest IDE version compatible with the plugin.
* `until-build` (optional)
The highest IDE version compatible with the plugin. Undefined value declares compatibility with all the IDEs since the version specified by the `since-build` (also with the future builds that may cause incompatibility errors).
I wonder if we can just edit the xml file, repack the jar and try again.. it didn't work on my first attempt but I'll do more digging
I got the plugin to install but I don't see the action show up so clearly there's more that's needed. I'm running IntelliJ IDEA 2024.3.2 (Ultimate Edition)
Here's how I got it to install if anyone wants to test:
extract the .jar file
edit META-INF/plugin.xml and change line 4 to:
<idea-version since-build="232" />
re-zip folder (I have a Mac and used the built-in compress option on folder)
leave this as a .zip file.. I tried renaming as .jar but that didn't work
I can't get this to work.. the plugin looks enabled but I can't find the action when trying to add it to the toolbar. I used the same syntax you did too -- until-build="342.*". Any pointers?
thanks.. I had it setup on an earlier version of IntelliJ but for some reason I can't find the action anymore.. nothing comes up when searching for "Hubitat" or Post
@gopher.ny, does the plugin work with libraries too?
If not, are you planning to add support for libraries?
Edit:
Another big improvement would be to find a way to avoid having the configuration inside the files. For code shared on github, it makes the plugin useless, or at least very hard to use, since you have to add and remove the header while using version control.
The hub address/IP could be configured in the plugin, and namespace and name seem to be unique for libraries, drivers and apps, making it possible to derive the id.
The way to determine which type of code that a file deals with is more challenging, but it's a nice challenge .
@gopher.ny - would you be able to update the plugin for a more recent version of IntelliJ?
Maybe even just remove that until-build attribute to not prevent it from working in newer versions?
* `until-build` (optional)
The highest IDE version compatible with the plugin. Undefined value declares compatibility with all the IDEs since the version specified by the `since-build` (also with the future builds that may cause incompatibility errors).
Yes, it's on the to do list. We don't provide estimates as a matter of policy, but probably sooner rather than later. We're using it, too, and would like to update the IDE.