I just finished up building a VSCode extension that allows for the publishing of local files to the hubitat and I am looking for some folks to help test it out.
I haven’t published it out to the Visual Studio Marketplace (yet), but you can download the extension as a .vsix file on my github releases page and install it into VSCode manually. There is more documentation available on the README of the repo. GitHub - louisparks/vscode-hubitat-dev
Steps to install
Install the Free Visual Studio Code from Microsoft
While in VSCode, type in Control-Shift-P (Command-Shift-P) and then start typing “vsix”.
Select “Extensions: Install from vsix”.
Select the downloaded vsix file to install the extension.
Once it's installed, you can add a local folder with your drivers and apps in it to your VSCode workspace. With a document open, again type Control-Shift-P and this time type in Hubitat - Publish. It will prompt you for the address of your Hubitat and push the currently open file to your hub.
To be clear, this method of deploying drivers and apps is not officially published or supported by Hubitat, it was reverse engineered from the web app IDE. But, it works great, and many of us have been doing this for years though some CLI scripts. It’s my hope that if enough of us request it, Hubitat will hopefully codify some API’s for publishing.
This is use at your own risk, but there really isn’t too much trouble you can get yourself into.
I hope you enjoy this, it should be a massive time and hopefully overall improve the readability of all the wonderful apps and drivers out there. VSCode is great (and free) IDE and it has a wonderful groovy linter and code formatter. The linter is a great way to learn more idiomatic groovy. I have created a groovy lint config that make some exceptions to make Hubitat development easier.
Please provide bugs or feedback, I'll do my best to get a version 1.0.0 out and stable.
Installed and trying to push existing code, when I open the JSON file and indicate the ID number of the app or driver, when I try to push the new code to HE, it indicates "created new driver...", nothing was pushed and the JSON file goes back to ID= null.
BTW, on github release notes of the readme.md file, it indicates release 1.0.1 as the latest, yet the release link is 0.0.9
install the groovy lint extension then plop that config in the root of your folder(s).
beware, the linter is pretty opinionated, so when building a driver from scratch the results are beautiful groovy files.... however, most drivers out there generate dozens of warnings.
yes, i should handle the authorization error better. I will note that. I also would love to support auth and can, but its a really big hack and I wanted to gauge interest on it first. Also, would love for the hubitat team to give a proper token rather than cookie stealing
Hi @Iparks and thanks for this awesome extension. I'm facing an issue though and I am probably missing something elementary but for now I can't find how to resolve it:
I tested the app on one of my development hubs to be on the safe side of things and it did create a new copy of my app every time, instead of overwriting the last one it created. I checked the box "overwrite" in the extension's settings, to no avail.
Since it looks like it's working for other people in this forum, can you give me a hint of where I should look to sort this out? Clearly, my app seems to be missing something considered standard and that your extension needs for version control.
Let me know if you have something to lead me toward so I can figure this out.
Thanks again for the great work.
UPDATE: never mind, I just had to restart VSCode... I'm leaving this post here in case anybody else finds themselves in this ridiculous situation!
Thanks for giving it some mileage. There are a few tweaks I want to make regarding error handling and support for when security is enabled on the hub. Keep you eyes out for a new build soon, Ill post here.
Is everyone experiencing that you need to restart vscode to get the extension to work?
Well I had to restart as you know to get to the extension settings.
I also experience that each time I add new code and send it to the hub, if I don't have it added manually to the JSON file, it will create a new copy of the app. It would be nice if there would be a way to detect it and maybe ask if we want to create a new copy or overwrite the one already there when not already in the JSON file?