Hi,
I got some ideas to improve my hubitat setup, looking at developing apps/driver for that.
I got 15 years of software development behind me (mostly java), so I like to have my code organized and continuously integrated, tested and deployed.
Hubitat seems to need a single file per app, that does not mean it needs to be like that in the code repository.
- Curious about how you organize your code, in terms of module/folder/file. I mostly see apps in a giant single file of 7k lignes of code, my brain is kind of freezing on that.
- how do you isolate hubitat specific code from the business logic you want to build ?
- Do you necessarly use Hubitat Package Manager to deploy your product or is there any other integration ? Specially with private repositories.
- are you able to mock/stub the hub behaviour locally ?
- Any library or framework I should pay attention to that are massively used ?
- Any clean app/driver architecture I could look at as a example ?
I find the current documentation very light on those part. The accent is on the language particularity and how to develop in the UI of the hub, which is good for sandbox but not really for developpers with experience.
Lack of diagrams/schema to summaries all this text is also an improvement that could be done but that's another subject.
Thx for the feedback !
2 Likes
Hubitat (HE) does allow the use of custom libraries if you want to modularize your code - you'll need to use the
#include <nameSpace>.<libraryName>
statement to bring it into the app. HE also supports the use of child apps and child devices. While I tend to develop things in a modular fashion, by the time I publish it to my github it's generally consolidated into 1 source file unless I have both an app and driver(s) or child apps/drivers involved. I also occasionally will combine the code into a bundle and put that up in the github for distribution.
Hubitat Package Manager (HPM), while a community app, is pretty much the defacto standard for making apps/drivers available for the community. You don't have to use it, but many/most developers do.
I've never found a local way of simlulating the HE environment outside of the hub, but there are a couple of integrations (IntelliJ and VS Code come to mind) that allow you to develop on another platflorm and then push it up to a hub for testing.
3 Likes
Hi,
Thx for the feedback.
So i checked into the library aspect. Correct me if I am wrong :
- hubitat supports artifacts as single files
- The notion of library is not to be taken as a dependency manager: specifiying artifact versioning information and having hubitat make it available into the classpath.
So you use a regular local setup to develop with build tools, dependency manager, but when it comes to produce your artifact, you have a package stage that concatenates all the sources that you need, including dependencies, into one single file so that Hubitat can ingest it.
Regarding the HPM, i don t see any automation in the deployment of a new app/driver version. You have to manually navigate into its UI and then it will check on a configured public repository that some metadata indicates an update. As i can see it ok for end users, the lack of automation is problematic on a development side. Do you know any solution to programmatically update a app/driver ? i dont see any API, ssh connectivity, ...
Any possiblity you would share the architecture of your repository from the dev side ? like folder hierarchy ? Also, what do you use to concatenate all your files into a single one ?
I can see that
1 Like